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.

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