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.

917 lines
27KB

  1. /*
  2. * Carla Native Plugins
  3. * Copyright (C) 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. #include "CarlaNative.hpp"
  18. using namespace juce;
  19. #include "vex/cArp.h"
  20. #include "vex/cChorus.h"
  21. #include "vex/cDelay.h"
  22. #include "vex/cReverb.h"
  23. #include "vex/cSyntModule.h"
  24. // -----------------------------------------------------------------------
  25. class VexArpPlugin : public PluginClass
  26. {
  27. public:
  28. enum Params {
  29. kParamOnOff = 0,
  30. kParamLength,
  31. kParamTimeMode,
  32. kParamSyncMode,
  33. kParamFailMode,
  34. kParamVelMode,
  35. kParamCount
  36. };
  37. VexArpPlugin(const HostDescriptor* const host)
  38. : PluginClass(host),
  39. fSettings(),
  40. fArp(&fSettings)
  41. {
  42. for (int i=0; i < 8; ++i)
  43. fSettings.grid[i*10] = true;
  44. fSettings.grid[1] = true;
  45. fSettings.grid[2] = true;
  46. fSettings.grid[3] = true;
  47. fSettings.grid[41] = true;
  48. fSettings.grid[42] = true;
  49. fSettings.grid[43] = true;
  50. fSettings.grid[44] = true;
  51. fSettings.grid[45] = true;
  52. fArp.setSampleRate(getSampleRate());
  53. fMidiInBuffer.ensureSize(512*4);
  54. }
  55. protected:
  56. // -------------------------------------------------------------------
  57. // Plugin parameter calls
  58. uint32_t getParameterCount() const override
  59. {
  60. return kParamCount;
  61. }
  62. const Parameter* getParameterInfo(const uint32_t index) const override
  63. {
  64. static Parameter paramInfo;
  65. static ParameterScalePoint scalePoints[4];
  66. int hints = PARAMETER_IS_ENABLED|PARAMETER_IS_AUTOMABLE|PARAMETER_IS_INTEGER;
  67. paramInfo.name = nullptr;
  68. paramInfo.unit = nullptr;
  69. paramInfo.ranges.def = 0.0f;
  70. paramInfo.ranges.min = 0.0f;
  71. paramInfo.ranges.max = 1.0f;
  72. paramInfo.ranges.step = 1.0f;
  73. paramInfo.ranges.stepSmall = 1.0f;
  74. paramInfo.ranges.stepLarge = 1.0f;
  75. paramInfo.scalePointCount = 0;
  76. paramInfo.scalePoints = nullptr;
  77. switch (index)
  78. {
  79. case kParamOnOff:
  80. hints |= PARAMETER_IS_BOOLEAN;
  81. paramInfo.name = "On/Off";
  82. paramInfo.ranges.def = 0.0f;
  83. paramInfo.ranges.min = 0.0f;
  84. paramInfo.ranges.max = 1.0f;
  85. break;
  86. case kParamLength:
  87. paramInfo.name = "Length";
  88. paramInfo.ranges.def = 8.0f;
  89. paramInfo.ranges.min = 1.0f;
  90. paramInfo.ranges.max = 16.0f;
  91. break;
  92. case kParamTimeMode:
  93. hints |= PARAMETER_USES_SCALEPOINTS;
  94. paramInfo.name = "Time Signature";
  95. paramInfo.ranges.def = 2.0f;
  96. paramInfo.ranges.min = 1.0f;
  97. paramInfo.ranges.max = 3.0f;
  98. paramInfo.scalePointCount = 3;
  99. paramInfo.scalePoints = scalePoints;
  100. scalePoints[0].label = "8";
  101. scalePoints[1].label = "16";
  102. scalePoints[2].label = "32";
  103. scalePoints[0].value = 1.0f;
  104. scalePoints[1].value = 2.0f;
  105. scalePoints[2].value = 3.0f;
  106. break;
  107. case kParamSyncMode:
  108. hints |= PARAMETER_USES_SCALEPOINTS;
  109. paramInfo.name = "Sync Mode";
  110. paramInfo.ranges.def = 1.0f;
  111. paramInfo.ranges.min = 1.0f;
  112. paramInfo.ranges.max = 2.0f;
  113. paramInfo.scalePointCount = 2;
  114. paramInfo.scalePoints = scalePoints;
  115. scalePoints[0].label = "Key Sync";
  116. scalePoints[1].label = "Bar Sync";
  117. scalePoints[0].value = 1.0f;
  118. scalePoints[1].value = 2.0f;
  119. break;
  120. case kParamFailMode:
  121. hints |= PARAMETER_USES_SCALEPOINTS;
  122. paramInfo.name = "Fail Mode";
  123. paramInfo.ranges.def = 1.0f;
  124. paramInfo.ranges.min = 1.0f;
  125. paramInfo.ranges.max = 3.0f;
  126. paramInfo.scalePointCount = 3;
  127. paramInfo.scalePoints = scalePoints;
  128. scalePoints[0].label = "Silent Step";
  129. scalePoints[1].label = "Skip One";
  130. scalePoints[2].label = "Skip Two";
  131. scalePoints[0].value = 1.0f;
  132. scalePoints[1].value = 2.0f;
  133. scalePoints[2].value = 3.0f;
  134. break;
  135. case kParamVelMode:
  136. hints |= PARAMETER_USES_SCALEPOINTS;
  137. paramInfo.name = "Velocity Mode";
  138. paramInfo.ranges.def = 1.0f;
  139. paramInfo.ranges.min = 1.0f;
  140. paramInfo.ranges.max = 3.0f;
  141. paramInfo.scalePointCount = 3;
  142. paramInfo.scalePoints = scalePoints;
  143. scalePoints[0].label = "Pattern Velocity";
  144. scalePoints[1].label = "Input Velocity";
  145. scalePoints[2].label = "Sum Velocities";
  146. scalePoints[0].value = 1.0f;
  147. scalePoints[1].value = 2.0f;
  148. scalePoints[2].value = 3.0f;
  149. break;
  150. }
  151. paramInfo.hints = static_cast<ParameterHints>(hints);
  152. return &paramInfo;
  153. }
  154. float getParameterValue(const uint32_t index) const override
  155. {
  156. switch (index)
  157. {
  158. case kParamOnOff:
  159. return fSettings.on ? 1.0f : 0.0f;
  160. case kParamLength:
  161. return fSettings.length;
  162. case kParamTimeMode:
  163. return fSettings.timeMode;
  164. case kParamSyncMode:
  165. return fSettings.syncMode;
  166. case kParamFailMode:
  167. return fSettings.failMode;
  168. case kParamVelMode:
  169. return fSettings.velMode;
  170. default:
  171. return 0.0f;
  172. }
  173. }
  174. // -------------------------------------------------------------------
  175. // Plugin state calls
  176. void setParameterValue(const uint32_t index, const float value) override
  177. {
  178. switch (index)
  179. {
  180. case kParamOnOff:
  181. fSettings.on = (value >= 0.5f);
  182. break;
  183. case kParamLength:
  184. fSettings.length = value;
  185. break;
  186. case kParamTimeMode:
  187. fSettings.timeMode = value;
  188. break;
  189. case kParamSyncMode:
  190. fSettings.syncMode = value;
  191. break;
  192. case kParamFailMode:
  193. fSettings.failMode = value;
  194. break;
  195. case kParamVelMode:
  196. fSettings.velMode = value;
  197. break;
  198. }
  199. }
  200. // -------------------------------------------------------------------
  201. // Plugin process calls
  202. void process(float**, float**, const uint32_t frames, const MidiEvent* const midiEvents, const uint32_t midiEventCount) override
  203. {
  204. if (! fSettings.on)
  205. {
  206. for (uint32_t i=0; i < midiEventCount; ++i)
  207. writeMidiEvent(&midiEvents[i]);
  208. return;
  209. }
  210. const TimeInfo* const timeInfo(getTimeInfo());
  211. double ppqPos, barStartPos, bpm;
  212. if (timeInfo->bbt.valid)
  213. {
  214. ppqPos = 0.0;
  215. barStartPos = 0.0;
  216. bpm = timeInfo->bbt.beatsPerMinute;
  217. }
  218. else
  219. {
  220. double ppqBar = double(timeInfo->bbt.bar - 1) * timeInfo->bbt.beatsPerBar;
  221. double ppqBeat = double(timeInfo->bbt.beat - 1);
  222. double ppqTick = double(timeInfo->bbt.tick) / timeInfo->bbt.ticksPerBeat;
  223. ppqPos = ppqBar + ppqBeat + ppqTick;
  224. barStartPos = ppqBar;
  225. bpm = 120.0;
  226. }
  227. fMidiInBuffer.clear();
  228. for (uint32_t i=0; i < midiEventCount; ++i)
  229. {
  230. const MidiEvent* const midiEvent(&midiEvents[i]);
  231. fMidiInBuffer.addEvent(MidiMessage(midiEvent->data, midiEvent->size, midiEvent->time), timeInfo->frame);
  232. }
  233. const MidiBuffer& outMidiBuffer(fArp.processMidi(fMidiInBuffer, timeInfo->playing, ppqPos, barStartPos, bpm, frames));
  234. MidiBuffer::Iterator outBufferIterator(outMidiBuffer);
  235. MidiMessage midiMessage(0xf4);
  236. int sampleNumber;
  237. MidiEvent tmpEvent;
  238. tmpEvent.port = 0;
  239. while (outBufferIterator.getNextEvent(midiMessage, sampleNumber))
  240. {
  241. tmpEvent.size = midiMessage.getRawDataSize();
  242. tmpEvent.time = midiMessage.getTimeStamp();
  243. if (tmpEvent.size > 4)
  244. continue;
  245. std::memcpy(tmpEvent.data, midiMessage.getRawData(), sizeof(uint8_t)*tmpEvent.size);
  246. writeMidiEvent(&tmpEvent);
  247. }
  248. }
  249. // -------------------------------------------------------------------
  250. // Plugin dispatcher calls
  251. void sampleRateChanged(const double sampleRate) override
  252. {
  253. fArp.setSampleRate(sampleRate);
  254. }
  255. private:
  256. VexArpSettings fSettings;
  257. VexArp fArp;
  258. MidiBuffer fMidiInBuffer;
  259. PluginClassEND(VexArpPlugin)
  260. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(VexArpPlugin)
  261. };
  262. // -----------------------------------------------------------------------
  263. class VexChorusPlugin : public PluginClass
  264. {
  265. public:
  266. enum Params {
  267. kParamDepth = 0,
  268. kParamRate,
  269. kParamCount
  270. };
  271. VexChorusPlugin(const HostDescriptor* const host)
  272. : PluginClass(host),
  273. chorus(parameters)
  274. {
  275. parameters[0] = 0.6f;
  276. parameters[1] = 0.3f;
  277. chorus.setSampleRate(getSampleRate());
  278. }
  279. protected:
  280. // -------------------------------------------------------------------
  281. // Plugin parameter calls
  282. uint32_t getParameterCount() const override
  283. {
  284. return kParamCount;
  285. }
  286. const Parameter* getParameterInfo(const uint32_t index) const override
  287. {
  288. static Parameter paramInfo;
  289. int hints = PARAMETER_IS_ENABLED|PARAMETER_IS_AUTOMABLE;
  290. paramInfo.name = nullptr;
  291. paramInfo.unit = nullptr;
  292. paramInfo.ranges.def = 0.0f;
  293. paramInfo.ranges.min = 0.0f;
  294. paramInfo.ranges.max = 1.0f;
  295. paramInfo.ranges.step = 1.0f;
  296. paramInfo.ranges.stepSmall = 1.0f;
  297. paramInfo.ranges.stepLarge = 1.0f;
  298. paramInfo.scalePointCount = 0;
  299. paramInfo.scalePoints = nullptr;
  300. switch (index)
  301. {
  302. case kParamDepth:
  303. paramInfo.name = "Depth";
  304. paramInfo.ranges.def = 0.6f;
  305. paramInfo.ranges.min = 0.0f;
  306. paramInfo.ranges.max = 1.0f;
  307. break;
  308. case kParamRate:
  309. paramInfo.name = "Rate";
  310. paramInfo.ranges.def = 0.3f;
  311. paramInfo.ranges.min = 0.0f;
  312. paramInfo.ranges.max = 1.0f;
  313. break;
  314. }
  315. paramInfo.hints = static_cast<ParameterHints>(hints);
  316. return &paramInfo;
  317. }
  318. float getParameterValue(const uint32_t index) const override
  319. {
  320. if (index < kParamCount)
  321. return parameters[index];
  322. return 0.0f;
  323. }
  324. // -------------------------------------------------------------------
  325. // Plugin state calls
  326. void setParameterValue(const uint32_t index, const float value) override
  327. {
  328. if (index < kParamCount)
  329. parameters[index] = value;
  330. }
  331. // -------------------------------------------------------------------
  332. // Plugin process calls
  333. void process(float** const inBuffer, float** const outBuffer, const uint32_t frames, const MidiEvent* const, const uint32_t) override
  334. {
  335. if (inBuffer[0] != outBuffer[0])
  336. carla_copyFloat(outBuffer[0], inBuffer[0], frames);
  337. if (inBuffer[1] != outBuffer[1])
  338. carla_copyFloat(outBuffer[1], inBuffer[1], frames);
  339. chorus.processBlock(outBuffer[0], outBuffer[1], frames);
  340. }
  341. // -------------------------------------------------------------------
  342. // Plugin dispatcher calls
  343. void sampleRateChanged(const double sampleRate) override
  344. {
  345. chorus.setSampleRate(sampleRate);
  346. }
  347. private:
  348. VexChorus chorus;
  349. float parameters[2];
  350. PluginClassEND(VexChorusPlugin)
  351. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(VexChorusPlugin)
  352. };
  353. // -----------------------------------------------------------------------
  354. class VexDelayPlugin : public PluginClass
  355. {
  356. public:
  357. enum Params {
  358. kParamTime = 0,
  359. kParamFeedback,
  360. kParamCount
  361. };
  362. VexDelayPlugin(const HostDescriptor* const host)
  363. : PluginClass(host),
  364. delay(parameters)
  365. {
  366. parameters[0] = 4.0f;
  367. parameters[1] = 40.0f;
  368. delay.setSampleRate(getSampleRate());
  369. }
  370. protected:
  371. // -------------------------------------------------------------------
  372. // Plugin parameter calls
  373. uint32_t getParameterCount() const override
  374. {
  375. return kParamCount;
  376. }
  377. const Parameter* getParameterInfo(const uint32_t index) const override
  378. {
  379. static Parameter paramInfo;
  380. int hints = PARAMETER_IS_ENABLED|PARAMETER_IS_AUTOMABLE;
  381. paramInfo.name = nullptr;
  382. paramInfo.unit = nullptr;
  383. paramInfo.ranges.def = 0.0f;
  384. paramInfo.ranges.min = 0.0f;
  385. paramInfo.ranges.max = 1.0f;
  386. paramInfo.ranges.step = 1.0f;
  387. paramInfo.ranges.stepSmall = 1.0f;
  388. paramInfo.ranges.stepLarge = 1.0f;
  389. paramInfo.scalePointCount = 0;
  390. paramInfo.scalePoints = nullptr;
  391. switch (index)
  392. {
  393. case kParamTime:
  394. hints |= PARAMETER_IS_INTEGER;
  395. paramInfo.name = "Time";
  396. paramInfo.ranges.def = 4.0f;
  397. paramInfo.ranges.min = 0.0f;
  398. paramInfo.ranges.max = 8.0f;
  399. break;
  400. case kParamFeedback:
  401. paramInfo.name = "Feedback";
  402. paramInfo.unit = "%";
  403. paramInfo.ranges.def = 40.0f;
  404. paramInfo.ranges.min = 0.0f;
  405. paramInfo.ranges.max = 100.0f;
  406. break;
  407. }
  408. paramInfo.hints = static_cast<ParameterHints>(hints);
  409. return &paramInfo;
  410. }
  411. float getParameterValue(const uint32_t index) const override
  412. {
  413. if (index < kParamCount)
  414. return parameters[index];
  415. return 0.0f;
  416. }
  417. // -------------------------------------------------------------------
  418. // Plugin state calls
  419. void setParameterValue(const uint32_t index, const float value) override
  420. {
  421. if (index < kParamCount)
  422. parameters[index] = value;
  423. }
  424. // -------------------------------------------------------------------
  425. // Plugin process calls
  426. void process(float** const inBuffer, float** const outBuffer, const uint32_t frames, const MidiEvent* const, const uint32_t) override
  427. {
  428. if (inBuffer[0] != outBuffer[0])
  429. carla_copyFloat(outBuffer[0], inBuffer[0], frames);
  430. if (inBuffer[1] != outBuffer[1])
  431. carla_copyFloat(outBuffer[1], inBuffer[1], frames);
  432. const TimeInfo* const timeInfo(getTimeInfo());
  433. const double bpm(timeInfo->bbt.valid ? timeInfo->bbt.beatsPerMinute : 120.0);
  434. delay.processBlock(outBuffer[0], outBuffer[1], frames, bpm);
  435. }
  436. // -------------------------------------------------------------------
  437. // Plugin dispatcher calls
  438. void sampleRateChanged(const double sampleRate) override
  439. {
  440. delay.setSampleRate(sampleRate);
  441. }
  442. private:
  443. VexDelay delay;
  444. float parameters[2];
  445. PluginClassEND(VexDelayPlugin)
  446. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(VexDelayPlugin)
  447. };
  448. // -----------------------------------------------------------------------
  449. class VexReverbPlugin : public PluginClass
  450. {
  451. public:
  452. enum Params {
  453. kParamSize = 0,
  454. kParamWidth,
  455. kParamDamp,
  456. kParamCount
  457. };
  458. VexReverbPlugin(const HostDescriptor* const host)
  459. : PluginClass(host),
  460. reverb(parameters)
  461. {
  462. parameters[0] = 0.6f;
  463. parameters[1] = 0.7f;
  464. parameters[2] = 0.6f;
  465. }
  466. protected:
  467. // -------------------------------------------------------------------
  468. // Plugin parameter calls
  469. uint32_t getParameterCount() const override
  470. {
  471. return kParamCount;
  472. }
  473. const Parameter* getParameterInfo(const uint32_t index) const override
  474. {
  475. static Parameter paramInfo;
  476. int hints = PARAMETER_IS_ENABLED|PARAMETER_IS_AUTOMABLE;
  477. paramInfo.name = nullptr;
  478. paramInfo.unit = nullptr;
  479. paramInfo.ranges.def = 0.0f;
  480. paramInfo.ranges.min = 0.0f;
  481. paramInfo.ranges.max = 1.0f;
  482. paramInfo.ranges.step = 1.0f;
  483. paramInfo.ranges.stepSmall = 1.0f;
  484. paramInfo.ranges.stepLarge = 1.0f;
  485. paramInfo.scalePointCount = 0;
  486. paramInfo.scalePoints = nullptr;
  487. switch (index)
  488. {
  489. case kParamSize:
  490. paramInfo.name = "Size";
  491. paramInfo.ranges.def = 0.6f;
  492. paramInfo.ranges.min = 0.0f;
  493. paramInfo.ranges.max = 1.0f;
  494. break;
  495. case kParamWidth:
  496. paramInfo.name = "Width";
  497. paramInfo.ranges.def = 0.7f;
  498. paramInfo.ranges.min = 0.0f;
  499. paramInfo.ranges.max = 1.0f;
  500. break;
  501. case kParamDamp:
  502. paramInfo.name = "Damp";
  503. paramInfo.ranges.def = 0.6f;
  504. paramInfo.ranges.min = 0.0f;
  505. paramInfo.ranges.max = 1.0f;
  506. break;
  507. }
  508. paramInfo.hints = static_cast<ParameterHints>(hints);
  509. return &paramInfo;
  510. }
  511. float getParameterValue(const uint32_t index) const override
  512. {
  513. if (index < kParamCount)
  514. return parameters[index];
  515. return 0.0f;
  516. }
  517. // -------------------------------------------------------------------
  518. // Plugin state calls
  519. void setParameterValue(const uint32_t index, const float value) override
  520. {
  521. if (index < kParamCount)
  522. parameters[index] = value;
  523. }
  524. // -------------------------------------------------------------------
  525. // Plugin process calls
  526. void process(float** const inBuffer, float** const outBuffer, const uint32_t frames, const MidiEvent* const, const uint32_t) override
  527. {
  528. for (uint32_t i=0; i< frames; ++i)
  529. outBuffer[0][i] = inBuffer[0][i]/2.0f;
  530. for (uint32_t i=0; i< frames; ++i)
  531. outBuffer[1][i] = inBuffer[1][i]/2.0f;
  532. reverb.processBlock(outBuffer[0], outBuffer[1], frames);
  533. }
  534. private:
  535. VexReverb reverb;
  536. float parameters[3];
  537. PluginClassEND(VexReverbPlugin)
  538. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(VexReverbPlugin)
  539. };
  540. // -----------------------------------------------------------------------
  541. class VexSynthPlugin : public PluginClass
  542. {
  543. public:
  544. static const unsigned int kParamCount = 1;
  545. VexSynthPlugin(const HostDescriptor* const host)
  546. : PluginClass(host),
  547. synth(parameters)
  548. {
  549. std::memset(parameters, 0, sizeof(float)*92);
  550. for (int i = 0; i < 3; ++i)
  551. {
  552. const int offset = i * 24;
  553. parameters[offset + 1] = 0.5f;
  554. parameters[offset + 2] = 0.5f;
  555. parameters[offset + 3] = 0.5f;
  556. parameters[offset + 4] = 0.5f;
  557. parameters[offset + 5] = 0.9f;
  558. parameters[offset + 6] = 0.0f;
  559. parameters[offset + 7] = 1.0f;
  560. parameters[offset + 8] = 0.5f;
  561. parameters[offset + 9] = 0.0f;
  562. parameters[offset + 10] = 0.2f;
  563. parameters[offset + 11] = 0.0f;
  564. parameters[offset + 12] = 0.5f;
  565. parameters[offset + 13] = 0.5f;
  566. parameters[offset + 14] = 0.0f;
  567. parameters[offset + 15] = 0.3f;
  568. parameters[offset + 16] = 0.7f;
  569. parameters[offset + 17] = 0.1f;
  570. parameters[offset + 18] = 0.5f;
  571. parameters[offset + 19] = 0.5f;
  572. parameters[offset + 20] = 0.0f;
  573. parameters[offset + 21] = 0.0f;
  574. parameters[offset + 22] = 0.5f;
  575. parameters[offset + 23] = 0.5f;
  576. parameters[offset + 24] = 0.5f;
  577. }
  578. parameters[89] = 1.0f;
  579. synth.setSampleRate(getSampleRate());
  580. synth.update(89);
  581. }
  582. protected:
  583. // -------------------------------------------------------------------
  584. // Plugin parameter calls
  585. uint32_t getParameterCount() const override
  586. {
  587. return kParamCount;
  588. }
  589. const Parameter* getParameterInfo(const uint32_t index) const override
  590. {
  591. static Parameter paramInfo;
  592. int hints = PARAMETER_IS_ENABLED|PARAMETER_IS_AUTOMABLE;
  593. paramInfo.name = nullptr;
  594. paramInfo.unit = nullptr;
  595. paramInfo.ranges.def = 0.0f;
  596. paramInfo.ranges.min = 0.0f;
  597. paramInfo.ranges.max = 1.0f;
  598. paramInfo.ranges.step = 1.0f;
  599. paramInfo.ranges.stepSmall = 1.0f;
  600. paramInfo.ranges.stepLarge = 1.0f;
  601. paramInfo.scalePointCount = 0;
  602. paramInfo.scalePoints = nullptr;
  603. switch (index)
  604. {
  605. case 0:
  606. hints |= PARAMETER_IS_INTEGER;
  607. paramInfo.name = "Wave";
  608. paramInfo.ranges.def = 0.0f;
  609. paramInfo.ranges.min = 0.0f;
  610. paramInfo.ranges.max = WaveRenderer::getWaveTableSize();
  611. break;
  612. }
  613. paramInfo.hints = static_cast<ParameterHints>(hints);
  614. return &paramInfo;
  615. }
  616. float getParameterValue(const uint32_t index) const override
  617. {
  618. if (index < kParamCount)
  619. return parameters[index];
  620. return 0.0f;
  621. }
  622. // -------------------------------------------------------------------
  623. // Plugin state calls
  624. void setParameterValue(const uint32_t index, const float value) override
  625. {
  626. if (index < kParamCount)
  627. {
  628. parameters[index] = value;
  629. synth.setWaveLater(1, WaveRenderer::getWaveTableName(value));
  630. //synth.update(index);
  631. }
  632. }
  633. // -------------------------------------------------------------------
  634. // Plugin process calls
  635. void process(float**, float** outBuffer, const uint32_t frames, const MidiEvent* const midiEvents, const uint32_t midiEventCount) override
  636. {
  637. for (uint32_t i=0; i < midiEventCount; ++i)
  638. {
  639. const MidiEvent* const midiEvent(&midiEvents[i]);
  640. const uint8_t status(MIDI_GET_STATUS_FROM_DATA(midiEvent->data));
  641. if (status == MIDI_STATUS_NOTE_ON)
  642. {
  643. synth.playNote(midiEvent->data[1], midiEvent->data[2], 0, 1);
  644. }
  645. else if (status == MIDI_STATUS_NOTE_OFF)
  646. {
  647. synth.releaseNote(midiEvent->data[1], 0, 1);
  648. }
  649. else if (status == MIDI_STATUS_CONTROL_CHANGE)
  650. {
  651. const uint8_t control(midiEvent->data[1]);
  652. if (control == MIDI_CONTROL_ALL_SOUND_OFF)
  653. synth.kill();
  654. else if (control == MIDI_CONTROL_ALL_NOTES_OFF)
  655. synth.releaseAll(1);
  656. }
  657. }
  658. carla_zeroFloat(outBuffer[0], frames);
  659. carla_zeroFloat(outBuffer[1], frames);
  660. synth.doProcess(outBuffer[0], outBuffer[1], frames);
  661. }
  662. // -------------------------------------------------------------------
  663. // Plugin dispatcher calls
  664. void sampleRateChanged(const double sampleRate) override
  665. {
  666. synth.setSampleRate(sampleRate);
  667. }
  668. private:
  669. VexSyntModule synth;
  670. float parameters[92];
  671. PluginClassEND(VexSynthPlugin)
  672. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(VexSynthPlugin)
  673. };
  674. // -----------------------------------------------------------------------
  675. static const PluginDescriptor vexArpDesc = {
  676. /* category */ PLUGIN_CATEGORY_UTILITY,
  677. /* hints */ static_cast<PluginHints>(0x0),
  678. /* supports */ static_cast<PluginSupports>(PLUGIN_SUPPORTS_EVERYTHING),
  679. /* audioIns */ 0,
  680. /* audioOuts */ 0,
  681. /* midiIns */ 1,
  682. /* midiOuts */ 1,
  683. /* paramIns */ VexArpPlugin::kParamCount,
  684. /* paramOuts */ 0,
  685. /* name */ "VexArp",
  686. /* label */ "vexArp",
  687. /* maker */ "falkTX",
  688. /* copyright */ "GNU GPL v2+",
  689. PluginDescriptorFILL(VexArpPlugin)
  690. };
  691. static const PluginDescriptor vexChorusDesc = {
  692. /* category */ PLUGIN_CATEGORY_MODULATOR,
  693. /* hints */ static_cast<PluginHints>(PLUGIN_IS_RTSAFE),
  694. /* supports */ static_cast<PluginSupports>(0x0),
  695. /* audioIns */ 2,
  696. /* audioOuts */ 2,
  697. /* midiIns */ 0,
  698. /* midiOuts */ 0,
  699. /* paramIns */ VexChorusPlugin::kParamCount,
  700. /* paramOuts */ 0,
  701. /* name */ "VexChorus",
  702. /* label */ "vexChorus",
  703. /* maker */ "falkTX",
  704. /* copyright */ "GNU GPL v2+",
  705. PluginDescriptorFILL(VexChorusPlugin)
  706. };
  707. static const PluginDescriptor vexDelayDesc = {
  708. /* category */ PLUGIN_CATEGORY_DELAY,
  709. /* hints */ static_cast<PluginHints>(PLUGIN_IS_RTSAFE),
  710. /* supports */ static_cast<PluginSupports>(0x0),
  711. /* audioIns */ 2,
  712. /* audioOuts */ 2,
  713. /* midiIns */ 0,
  714. /* midiOuts */ 0,
  715. /* paramIns */ VexDelayPlugin::kParamCount,
  716. /* paramOuts */ 0,
  717. /* name */ "VexDelay",
  718. /* label */ "vexDelay",
  719. /* maker */ "falkTX",
  720. /* copyright */ "GNU GPL v2+",
  721. PluginDescriptorFILL(VexDelayPlugin)
  722. };
  723. static const PluginDescriptor vexReverbDesc = {
  724. /* category */ PLUGIN_CATEGORY_DELAY,
  725. /* hints */ static_cast<PluginHints>(PLUGIN_IS_RTSAFE),
  726. /* supports */ static_cast<PluginSupports>(0x0),
  727. /* audioIns */ 2,
  728. /* audioOuts */ 2,
  729. /* midiIns */ 0,
  730. /* midiOuts */ 0,
  731. /* paramIns */ VexReverbPlugin::kParamCount,
  732. /* paramOuts */ 0,
  733. /* name */ "VexReverb",
  734. /* label */ "vexReverb",
  735. /* maker */ "falkTX",
  736. /* copyright */ "GNU GPL v2+",
  737. PluginDescriptorFILL(VexReverbPlugin)
  738. };
  739. static const PluginDescriptor vexSynthDesc = {
  740. /* category */ PLUGIN_CATEGORY_SYNTH,
  741. /* hints */ static_cast<PluginHints>(0x0),
  742. /* supports */ static_cast<PluginSupports>(0x0),
  743. /* audioIns */ 0,
  744. /* audioOuts */ 2,
  745. /* midiIns */ 1,
  746. /* midiOuts */ 0,
  747. /* paramIns */ VexSynthPlugin::kParamCount,
  748. /* paramOuts */ 0,
  749. /* name */ "VexSynth",
  750. /* label */ "vexSynth",
  751. /* maker */ "falkTX",
  752. /* copyright */ "GNU GPL v2+",
  753. PluginDescriptorFILL(VexSynthPlugin)
  754. };
  755. // -----------------------------------------------------------------------
  756. CARLA_EXPORT
  757. void carla_register_native_plugin_vex()
  758. {
  759. carla_register_native_plugin(&vexArpDesc);
  760. carla_register_native_plugin(&vexChorusDesc);
  761. carla_register_native_plugin(&vexDelayDesc);
  762. carla_register_native_plugin(&vexReverbDesc);
  763. carla_register_native_plugin(&vexSynthDesc);
  764. }
  765. // -----------------------------------------------------------------------
  766. #include "vex/freeverb/allpass.cpp"
  767. #include "vex/freeverb/comb.cpp"
  768. #include "vex/freeverb/revmodel.cpp"
  769. #include "vex/cVoice.cpp"
  770. #include "vex/cWaveRenderer.cpp"
  771. #include "vex/ResourceFile.cpp"
  772. // -----------------------------------------------------------------------