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.

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