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.

957 lines
28KB

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