Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

zynaddsubfx-synth.cpp 21KB

10 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818
  1. /*
  2. * Carla Native Plugins
  3. * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. // for UINT32_MAX
  18. #define __STDC_LIMIT_MACROS
  19. #include <cstdint>
  20. #include "CarlaNative.hpp"
  21. #include "CarlaMIDI.h"
  22. #include "CarlaThread.hpp"
  23. #include "LinkedList.hpp"
  24. #include "CarlaMathUtils.hpp"
  25. #include "zynaddsubfx/DSP/FFTwrapper.h"
  26. #include "zynaddsubfx/Misc/Master.h"
  27. #include "zynaddsubfx/Misc/Part.h"
  28. #include "zynaddsubfx/Misc/Util.h"
  29. #ifdef WANT_ZYNADDSUBFX_UI
  30. # ifdef override
  31. # define override_hack
  32. # undef override
  33. # endif
  34. # include "zynaddsubfx/UI/common.H"
  35. # include "zynaddsubfx/UI/MasterUI.h"
  36. # include <FL/Fl_Shared_Image.H>
  37. # include <FL/Fl_Tiled_Image.H>
  38. # include <FL/Fl_Theme.H>
  39. # ifdef override_hack
  40. # define override
  41. # undef override_hack
  42. # endif
  43. #endif
  44. #include <ctime>
  45. #include <set>
  46. #include <string>
  47. #ifdef WANT_ZYNADDSUBFX_UI
  48. static Fl_Tiled_Image* gModuleBackdrop = nullptr;
  49. static CarlaString gPixmapPath;
  50. extern CarlaString gUiPixmapPath;
  51. void set_module_parameters(Fl_Widget* o)
  52. {
  53. CARLA_ASSERT(gModuleBackdrop != nullptr);
  54. o->box(FL_DOWN_FRAME);
  55. o->align(o->align() | FL_ALIGN_IMAGE_BACKDROP);
  56. o->color(FL_BLACK);
  57. o->labeltype(FL_SHADOW_LABEL);
  58. if (gModuleBackdrop != nullptr)
  59. o->image(gModuleBackdrop);
  60. }
  61. #endif
  62. // -----------------------------------------------------------------------
  63. class ZynAddSubFxPrograms
  64. {
  65. public:
  66. ZynAddSubFxPrograms()
  67. : fInitiated(false)
  68. {
  69. }
  70. ~ZynAddSubFxPrograms()
  71. {
  72. if (! fInitiated)
  73. return;
  74. for (auto it = fPrograms.begin(); it.valid(); it.next())
  75. {
  76. const ProgramInfo* const& pInfo(it.getValue());
  77. delete pInfo;
  78. }
  79. fPrograms.clear();
  80. FFT_cleanup();
  81. }
  82. void init()
  83. {
  84. if (fInitiated)
  85. return;
  86. fInitiated = true;
  87. fPrograms.append(new ProgramInfo(0, 0, "default"));
  88. Master& master(Master::getInstance());
  89. pthread_mutex_lock(&master.mutex);
  90. // refresh banks
  91. master.bank.rescanforbanks();
  92. for (uint32_t i=0, size = master.bank.banks.size(); i < size; ++i)
  93. {
  94. if (master.bank.banks[i].dir.empty())
  95. continue;
  96. master.bank.loadbank(master.bank.banks[i].dir);
  97. for (unsigned int instrument = 0; instrument < BANK_SIZE; ++instrument)
  98. {
  99. const std::string insName(master.bank.getname(instrument));
  100. if (insName.empty() || insName[0] == '\0' || insName[0] == ' ')
  101. continue;
  102. fPrograms.append(new ProgramInfo(i+1, instrument, insName.c_str()));
  103. }
  104. }
  105. pthread_mutex_unlock(&master.mutex);
  106. }
  107. void load(Master* const master, const uint8_t channel, const uint32_t bank, const uint32_t program)
  108. {
  109. if (bank == 0)
  110. {
  111. pthread_mutex_lock(&master->mutex);
  112. master->partonoff(channel, 1);
  113. master->part[channel]->defaults();
  114. master->part[channel]->applyparameters(false);
  115. pthread_mutex_unlock(&master->mutex);
  116. return;
  117. }
  118. const std::string& bankdir(master->bank.banks[bank-1].dir);
  119. if (! bankdir.empty())
  120. {
  121. pthread_mutex_lock(&master->mutex);
  122. master->partonoff(channel, 1);
  123. master->bank.loadbank(bankdir);
  124. master->bank.loadfromslot(program, master->part[channel]);
  125. master->part[channel]->applyparameters(false);
  126. pthread_mutex_unlock(&master->mutex);
  127. }
  128. }
  129. uint32_t count()
  130. {
  131. return fPrograms.count();
  132. }
  133. const NativeMidiProgram* getInfo(const uint32_t index)
  134. {
  135. if (index >= fPrograms.count())
  136. return nullptr;
  137. const ProgramInfo*& pInfo(fPrograms.getAt(index));
  138. fRetProgram.bank = pInfo->bank;
  139. fRetProgram.program = pInfo->prog;
  140. fRetProgram.name = pInfo->name;
  141. return &fRetProgram;
  142. }
  143. private:
  144. struct ProgramInfo {
  145. uint32_t bank;
  146. uint32_t prog;
  147. const char* name;
  148. ProgramInfo(uint32_t bank_, uint32_t prog_, const char* name_)
  149. : bank(bank_),
  150. prog(prog_),
  151. name(carla_strdup(name_)) {}
  152. ~ProgramInfo()
  153. {
  154. if (name != nullptr)
  155. {
  156. delete[] name;
  157. name = nullptr;
  158. }
  159. }
  160. #ifdef CARLA_PROPER_CPP11_SUPPORT
  161. ProgramInfo() = delete;
  162. ProgramInfo(ProgramInfo&) = delete;
  163. ProgramInfo(const ProgramInfo&) = delete;
  164. ProgramInfo& operator=(ProgramInfo&);
  165. ProgramInfo& operator=(const ProgramInfo&);
  166. #endif
  167. };
  168. bool fInitiated;
  169. NativeMidiProgram fRetProgram;
  170. LinkedList<const ProgramInfo*> fPrograms;
  171. CARLA_DECLARE_NON_COPY_CLASS(ZynAddSubFxPrograms)
  172. };
  173. static ZynAddSubFxPrograms sPrograms;
  174. // -----------------------------------------------------------------------
  175. class ZynAddSubFxInstanceCount
  176. {
  177. public:
  178. ZynAddSubFxInstanceCount()
  179. : fCount(0)
  180. {
  181. }
  182. ~ZynAddSubFxInstanceCount()
  183. {
  184. CARLA_ASSERT(fCount == 0);
  185. }
  186. void addOne(const NativeHostDescriptor* const host)
  187. {
  188. if (fCount++ == 0)
  189. {
  190. CARLA_ASSERT(synth == nullptr);
  191. CARLA_ASSERT(denormalkillbuf == nullptr);
  192. reinit(host);
  193. #ifdef WANT_ZYNADDSUBFX_UI
  194. if (gPixmapPath.isEmpty())
  195. {
  196. gPixmapPath = host->resourceDir;
  197. gPixmapPath += "/zynaddsubfx/";
  198. gUiPixmapPath = gPixmapPath;
  199. }
  200. #endif
  201. }
  202. }
  203. void removeOne()
  204. {
  205. if (--fCount == 0)
  206. {
  207. CARLA_ASSERT(synth != nullptr);
  208. CARLA_ASSERT(denormalkillbuf != nullptr);
  209. Master::deleteInstance();
  210. delete[] denormalkillbuf;
  211. denormalkillbuf = nullptr;
  212. delete synth;
  213. synth = nullptr;
  214. }
  215. }
  216. void reinit(const NativeHostDescriptor* const host)
  217. {
  218. Master::deleteInstance();
  219. if (denormalkillbuf != nullptr)
  220. {
  221. delete[] denormalkillbuf;
  222. denormalkillbuf = nullptr;
  223. }
  224. if (synth != nullptr)
  225. {
  226. delete synth;
  227. synth = nullptr;
  228. }
  229. synth = new SYNTH_T();
  230. synth->buffersize = host->get_buffer_size(host->handle);
  231. synth->samplerate = host->get_sample_rate(host->handle);
  232. if (synth->buffersize > 32)
  233. synth->buffersize = 32;
  234. synth->alias();
  235. config.init();
  236. config.cfg.SoundBufferSize = synth->buffersize;
  237. config.cfg.SampleRate = synth->samplerate;
  238. config.cfg.GzipCompression = 0;
  239. sprng(std::time(nullptr));
  240. denormalkillbuf = new float[synth->buffersize];
  241. for (int i=0; i < synth->buffersize; ++i)
  242. denormalkillbuf[i] = (RND - 0.5f) * 1e-16;
  243. Master::getInstance();
  244. }
  245. void maybeReinit(const NativeHostDescriptor* const host)
  246. {
  247. if (host->get_buffer_size(host->handle) == static_cast<uint32_t>(synth->buffersize) &&
  248. host->get_sample_rate(host->handle) == static_cast<double>(synth->samplerate))
  249. return;
  250. reinit(host);
  251. }
  252. private:
  253. int fCount;
  254. CARLA_DECLARE_NON_COPY_CLASS(ZynAddSubFxInstanceCount)
  255. };
  256. static ZynAddSubFxInstanceCount sInstanceCount;
  257. // -----------------------------------------------------------------------
  258. class ZynAddSubFxThread : public CarlaThread
  259. {
  260. public:
  261. ZynAddSubFxThread(Master* const master, const NativeHostDescriptor* const host)
  262. : CarlaThread("ZynAddSubFxThread"),
  263. fMaster(master),
  264. kHost(host),
  265. #ifdef WANT_ZYNADDSUBFX_UI
  266. fUi(nullptr),
  267. fUiClosed(0),
  268. fNextUiAction(-1),
  269. #endif
  270. fChangeProgram(false),
  271. fNextChannel(0),
  272. fNextBank(0),
  273. fNextProgram(0)
  274. {
  275. }
  276. ~ZynAddSubFxThread()
  277. {
  278. #ifdef WANT_ZYNADDSUBFX_UI
  279. // must be closed by now
  280. CARLA_ASSERT(fUi == nullptr);
  281. #endif
  282. }
  283. void loadProgramLater(const uint8_t channel, const uint32_t bank, const uint32_t program)
  284. {
  285. fNextChannel = channel;
  286. fNextBank = bank;
  287. fNextProgram = program;
  288. fChangeProgram = true;
  289. }
  290. void stopLoadProgramLater()
  291. {
  292. fChangeProgram = false;
  293. fNextChannel = 0;
  294. fNextBank = 0;
  295. fNextProgram = 0;
  296. }
  297. void setMaster(Master* const master)
  298. {
  299. fMaster = master;
  300. }
  301. #ifdef WANT_ZYNADDSUBFX_UI
  302. void uiHide()
  303. {
  304. fNextUiAction = 0;
  305. }
  306. void uiShow()
  307. {
  308. fNextUiAction = 1;
  309. }
  310. void uiRepaint()
  311. {
  312. if (fUi != nullptr)
  313. fNextUiAction = 2;
  314. }
  315. void uiChangeName(const char* const name)
  316. {
  317. if (fUi != nullptr)
  318. {
  319. Fl::lock();
  320. fUi->masterwindow->label(name);
  321. Fl::unlock();
  322. }
  323. }
  324. #endif
  325. protected:
  326. void run() override
  327. {
  328. while (! shouldExit())
  329. {
  330. #ifdef WANT_ZYNADDSUBFX_UI
  331. Fl::lock();
  332. if (fNextUiAction == 2) // repaint
  333. {
  334. CARLA_ASSERT(fUi != nullptr);
  335. if (fUi != nullptr)
  336. fUi->refresh_master_ui();
  337. }
  338. else if (fNextUiAction == 1) // init/show
  339. {
  340. static bool initialized = false;
  341. if (! initialized)
  342. {
  343. initialized = true;
  344. fl_register_images();
  345. Fl_Dial::default_style(Fl_Dial::PIXMAP_DIAL);
  346. if (Fl_Shared_Image* const img = Fl_Shared_Image::get(gPixmapPath + "knob.png"))
  347. Fl_Dial::default_image(img);
  348. if (Fl_Shared_Image* const img = Fl_Shared_Image::get(gPixmapPath + "window_backdrop.png"))
  349. Fl::scheme_bg(new Fl_Tiled_Image(img));
  350. if(Fl_Shared_Image* const img = Fl_Shared_Image::get(gPixmapPath + "module_backdrop.png"))
  351. gModuleBackdrop = new Fl_Tiled_Image(img);
  352. Fl::background(50, 50, 50);
  353. Fl::background2(70, 70, 70);
  354. Fl::foreground(255, 255, 255);
  355. Fl_Theme::set("Cairo");
  356. }
  357. CARLA_ASSERT(fUi == nullptr);
  358. if (fUi == nullptr)
  359. {
  360. fUiClosed = 0;
  361. fUi = new MasterUI(fMaster, &fUiClosed);
  362. fUi->masterwindow->label(kHost->uiName);
  363. fUi->showUI();
  364. }
  365. }
  366. else if (fNextUiAction == 0) // close
  367. {
  368. CARLA_ASSERT(fUi != nullptr);
  369. if (fUi != nullptr)
  370. {
  371. delete fUi;
  372. fUi = nullptr;
  373. }
  374. }
  375. fNextUiAction = -1;
  376. if (fUiClosed != 0)
  377. {
  378. fUiClosed = 0;
  379. fNextUiAction = 0;
  380. kHost->ui_closed(kHost->handle);
  381. }
  382. Fl::check();
  383. Fl::unlock();
  384. #endif
  385. if (fChangeProgram)
  386. {
  387. fChangeProgram = false;
  388. sPrograms.load(fMaster, fNextChannel, fNextBank, fNextProgram);
  389. fNextChannel = 0;
  390. fNextBank = 0;
  391. fNextProgram = 0;
  392. #ifdef WANT_ZYNADDSUBFX_UI
  393. if (fUi != nullptr)
  394. {
  395. Fl::lock();
  396. fUi->refresh_master_ui();
  397. Fl::unlock();
  398. }
  399. #endif
  400. carla_msleep(15);
  401. }
  402. else
  403. {
  404. carla_msleep(30);
  405. }
  406. }
  407. #ifdef WANT_ZYNADDSUBFX_UI
  408. if (shouldExit() || fUi != nullptr)
  409. {
  410. Fl::lock();
  411. delete fUi;
  412. fUi = nullptr;
  413. Fl::check();
  414. Fl::unlock();
  415. }
  416. #endif
  417. }
  418. private:
  419. Master* fMaster;
  420. const NativeHostDescriptor* const kHost;
  421. #ifdef WANT_ZYNADDSUBFX_UI
  422. MasterUI* fUi;
  423. int fUiClosed;
  424. volatile int fNextUiAction;
  425. #endif
  426. volatile bool fChangeProgram;
  427. volatile uint8_t fNextChannel;
  428. volatile uint32_t fNextBank;
  429. volatile uint32_t fNextProgram;
  430. };
  431. // -----------------------------------------------------------------------
  432. class ZynAddSubFxPlugin : public NativePluginClass
  433. {
  434. public:
  435. ZynAddSubFxPlugin(const NativeHostDescriptor* const host)
  436. : NativePluginClass(host),
  437. fMaster(new Master()),
  438. fSampleRate(getSampleRate()),
  439. fIsActive(false),
  440. fThread(fMaster, host)
  441. {
  442. fThread.start();
  443. for (int i = 0; i < NUM_MIDI_PARTS; ++i)
  444. fMaster->partonoff(i, 1);
  445. sPrograms.init();
  446. }
  447. ~ZynAddSubFxPlugin() override
  448. {
  449. deleteMaster();
  450. }
  451. protected:
  452. // -------------------------------------------------------------------
  453. // Plugin midi-program calls
  454. uint32_t getMidiProgramCount() const override
  455. {
  456. return sPrograms.count();
  457. }
  458. const NativeMidiProgram* getMidiProgramInfo(const uint32_t index) const override
  459. {
  460. return sPrograms.getInfo(index);
  461. }
  462. // -------------------------------------------------------------------
  463. // Plugin state calls
  464. void setMidiProgram(const uint8_t channel, const uint32_t bank, const uint32_t program) override
  465. {
  466. if (bank >= fMaster->bank.banks.size())
  467. return;
  468. if (program >= BANK_SIZE)
  469. return;
  470. if (isOffline() || ! fIsActive)
  471. {
  472. sPrograms.load(fMaster, channel, bank, program);
  473. #ifdef WANT_ZYNADDSUBFX_UI
  474. fThread.uiRepaint();
  475. #endif
  476. }
  477. else
  478. fThread.loadProgramLater(channel, bank, program);
  479. }
  480. void setCustomData(const char* const key, const char* const value) override
  481. {
  482. CARLA_SAFE_ASSERT_RETURN(key != nullptr,);
  483. CARLA_SAFE_ASSERT_RETURN(value != nullptr,);
  484. if (std::strcmp(key, "CarlaAlternateFile1") == 0) // xmz
  485. fMaster->loadXML(value);
  486. else if (std::strcmp(key, "CarlaAlternateFile2") == 0) // xiz
  487. fMaster->part[0]->loadXMLinstrument(value);
  488. }
  489. // -------------------------------------------------------------------
  490. // Plugin process calls
  491. void activate() override
  492. {
  493. fIsActive = true;
  494. }
  495. void deactivate() override
  496. {
  497. fIsActive = false;
  498. }
  499. void process(float**, float** const outBuffer, const uint32_t frames, const NativeMidiEvent* const midiEvents, const uint32_t midiEventCount) override
  500. {
  501. if (pthread_mutex_trylock(&fMaster->mutex) != 0)
  502. {
  503. FLOAT_CLEAR(outBuffer[0], frames);
  504. FLOAT_CLEAR(outBuffer[1], frames);
  505. return;
  506. }
  507. for (uint32_t i=0; i < midiEventCount; ++i)
  508. {
  509. const NativeMidiEvent* const midiEvent(&midiEvents[i]);
  510. const uint8_t status = MIDI_GET_STATUS_FROM_DATA(midiEvent->data);
  511. const uint8_t channel = MIDI_GET_CHANNEL_FROM_DATA(midiEvent->data);
  512. if (MIDI_IS_STATUS_NOTE_OFF(status))
  513. {
  514. const uint8_t note = midiEvent->data[1];
  515. fMaster->noteOff(channel, note);
  516. }
  517. else if (MIDI_IS_STATUS_NOTE_ON(status))
  518. {
  519. const uint8_t note = midiEvent->data[1];
  520. const uint8_t velo = midiEvent->data[2];
  521. fMaster->noteOn(channel, note, velo);
  522. }
  523. else if (MIDI_IS_STATUS_POLYPHONIC_AFTERTOUCH(status))
  524. {
  525. const uint8_t note = midiEvent->data[1];
  526. const uint8_t pressure = midiEvent->data[2];
  527. fMaster->polyphonicAftertouch(channel, note, pressure);
  528. }
  529. else if (MIDI_IS_STATUS_CONTROL_CHANGE(status))
  530. {
  531. const uint8_t control = midiEvent->data[1];
  532. const uint8_t value = midiEvent->data[2];
  533. fMaster->setController(channel, control, value);
  534. }
  535. else if (MIDI_IS_STATUS_PITCH_WHEEL_CONTROL(status))
  536. {
  537. const uint8_t lsb = midiEvent->data[1];
  538. const uint8_t msb = midiEvent->data[2];
  539. const int value = ((msb << 7) | lsb) - 8192;
  540. fMaster->setController(channel, C_pitchwheel, value);
  541. }
  542. }
  543. fMaster->GetAudioOutSamples(frames, fSampleRate, outBuffer[0], outBuffer[1]);
  544. pthread_mutex_unlock(&fMaster->mutex);
  545. }
  546. #ifdef WANT_ZYNADDSUBFX_UI
  547. // -------------------------------------------------------------------
  548. // Plugin UI calls
  549. void uiShow(const bool show) override
  550. {
  551. if (show)
  552. fThread.uiShow();
  553. else
  554. fThread.uiHide();
  555. }
  556. #endif
  557. // -------------------------------------------------------------------
  558. // Plugin state calls
  559. char* getState() const override
  560. {
  561. config.save();
  562. char* data = nullptr;
  563. fMaster->getalldata(&data);
  564. return data;
  565. }
  566. void setState(const char* const data) override
  567. {
  568. fThread.stopLoadProgramLater();
  569. fMaster->putalldata((char*)data, 0);
  570. fMaster->applyparameters(true);
  571. }
  572. // -------------------------------------------------------------------
  573. // Plugin dispatcher
  574. // TODO - save&load current state
  575. void bufferSizeChanged(const uint32_t) final
  576. {
  577. deleteMaster();
  578. sInstanceCount.maybeReinit(getHostHandle());
  579. initMaster();
  580. }
  581. void sampleRateChanged(const double sampleRate) final
  582. {
  583. fSampleRate = sampleRate;
  584. deleteMaster();
  585. sInstanceCount.maybeReinit(getHostHandle());
  586. initMaster();
  587. }
  588. void initMaster()
  589. {
  590. fMaster = new Master();
  591. fThread.setMaster(fMaster);
  592. fThread.start();
  593. for (int i = 0; i < NUM_MIDI_PARTS; ++i)
  594. fMaster->partonoff(i, 1);
  595. }
  596. void deleteMaster()
  597. {
  598. //ensure that everything has stopped
  599. pthread_mutex_lock(&fMaster->mutex);
  600. pthread_mutex_unlock(&fMaster->mutex);
  601. fThread.stop(-1);
  602. delete fMaster;
  603. fMaster = nullptr;
  604. }
  605. #ifdef WANT_ZYNADDSUBFX_UI
  606. void uiNameChanged(const char* const uiName) override
  607. {
  608. fThread.uiChangeName(uiName);
  609. }
  610. #endif
  611. // -------------------------------------------------------------------
  612. private:
  613. Master* fMaster;
  614. unsigned fSampleRate;
  615. bool fIsActive;
  616. ZynAddSubFxThread fThread;
  617. public:
  618. static NativePluginHandle _instantiate(const NativeHostDescriptor* host)
  619. {
  620. sInstanceCount.addOne(host);
  621. return new ZynAddSubFxPlugin(host);
  622. }
  623. static void _cleanup(NativePluginHandle handle)
  624. {
  625. delete (ZynAddSubFxPlugin*)handle;
  626. sInstanceCount.removeOne();
  627. }
  628. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ZynAddSubFxPlugin)
  629. };
  630. // -----------------------------------------------------------------------
  631. static const NativePluginDescriptor zynaddsubfxDesc = {
  632. /* category */ PLUGIN_CATEGORY_SYNTH,
  633. #ifdef WANT_ZYNADDSUBFX_UI
  634. /* hints */ static_cast<NativePluginHints>(PLUGIN_IS_SYNTH|PLUGIN_HAS_UI|PLUGIN_USES_STATE),
  635. #else
  636. /* hints */ static_cast<NativePluginHints>(PLUGIN_IS_SYNTH|PLUGIN_USES_STATE),
  637. #endif
  638. /* supports */ static_cast<NativePluginSupports>(PLUGIN_SUPPORTS_CONTROL_CHANGES|PLUGIN_SUPPORTS_NOTE_AFTERTOUCH|PLUGIN_SUPPORTS_PITCHBEND|PLUGIN_SUPPORTS_ALL_SOUND_OFF),
  639. /* audioIns */ 0,
  640. /* audioOuts */ 2,
  641. /* midiIns */ 1,
  642. /* midiOuts */ 0,
  643. /* paramIns */ 0,
  644. /* paramOuts */ 0,
  645. /* name */ "ZynAddSubFX",
  646. /* label */ "zynaddsubfx",
  647. /* maker */ "falkTX",
  648. /* copyright */ "GNU GPL v2+",
  649. PluginDescriptorFILL(ZynAddSubFxPlugin)
  650. };
  651. // -----------------------------------------------------------------------
  652. CARLA_EXPORT
  653. void carla_register_native_plugin_zynaddsubfx_synth()
  654. {
  655. carla_register_native_plugin(&zynaddsubfxDesc);
  656. }
  657. // -----------------------------------------------------------------------