The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

1885 lines
84KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE examples.
  4. Copyright (c) 2020 - Raw Material Software Limited
  5. The code included in this file is provided under the terms of the ISC license
  6. http://www.isc.org/downloads/software-support-policy/isc-license. Permission
  7. To use, copy, modify, and/or distribute this software for any purpose with or
  8. without fee is hereby granted provided that the above copyright notice and
  9. this permission notice appear in all copies.
  10. THE SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES,
  11. WHETHER EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR
  12. PURPOSE, ARE DISCLAIMED.
  13. ==============================================================================
  14. */
  15. /*******************************************************************************
  16. The block below describes the properties of this PIP. A PIP is a short snippet
  17. of code that can be read by the Projucer and used to generate a JUCE project.
  18. BEGIN_JUCE_PIP_METADATA
  19. name: DSPModulePluginDemo
  20. version: 1.0.0
  21. vendor: JUCE
  22. website: http://juce.com
  23. description: An audio plugin using the DSP module.
  24. dependencies: juce_audio_basics, juce_audio_devices, juce_audio_formats,
  25. juce_audio_plugin_client, juce_audio_processors,
  26. juce_audio_utils, juce_core, juce_data_structures, juce_dsp,
  27. juce_events, juce_graphics, juce_gui_basics, juce_gui_extra
  28. exporters: xcode_mac, vs2019, linux_make
  29. moduleFlags: JUCE_STRICT_REFCOUNTEDPOINTER=1
  30. type: AudioProcessor
  31. mainClass: DspModulePluginDemoAudioProcessor
  32. useLocalCopy: 1
  33. END_JUCE_PIP_METADATA
  34. *******************************************************************************/
  35. #pragma once
  36. #include "../Assets/DemoUtilities.h"
  37. namespace ID
  38. {
  39. #define PARAMETER_ID(str) constexpr const char* str { #str };
  40. PARAMETER_ID (inputGain)
  41. PARAMETER_ID (outputGain)
  42. PARAMETER_ID (pan)
  43. PARAMETER_ID (distortionEnabled)
  44. PARAMETER_ID (distortionType)
  45. PARAMETER_ID (distortionOversampler)
  46. PARAMETER_ID (distortionLowpass)
  47. PARAMETER_ID (distortionHighpass)
  48. PARAMETER_ID (distortionInGain)
  49. PARAMETER_ID (distortionCompGain)
  50. PARAMETER_ID (distortionMix)
  51. PARAMETER_ID (multiBandEnabled)
  52. PARAMETER_ID (multiBandFreq)
  53. PARAMETER_ID (multiBandLowVolume)
  54. PARAMETER_ID (multiBandHighVolume)
  55. PARAMETER_ID (compressorEnabled)
  56. PARAMETER_ID (compressorThreshold)
  57. PARAMETER_ID (compressorRatio)
  58. PARAMETER_ID (compressorAttack)
  59. PARAMETER_ID (compressorRelease)
  60. PARAMETER_ID (noiseGateEnabled)
  61. PARAMETER_ID (noiseGateThreshold)
  62. PARAMETER_ID (noiseGateRatio)
  63. PARAMETER_ID (noiseGateAttack)
  64. PARAMETER_ID (noiseGateRelease)
  65. PARAMETER_ID (limiterEnabled)
  66. PARAMETER_ID (limiterThreshold)
  67. PARAMETER_ID (limiterRelease)
  68. PARAMETER_ID (directDelayEnabled)
  69. PARAMETER_ID (directDelayType)
  70. PARAMETER_ID (directDelayValue)
  71. PARAMETER_ID (directDelaySmoothing)
  72. PARAMETER_ID (directDelayMix)
  73. PARAMETER_ID (delayEffectEnabled)
  74. PARAMETER_ID (delayEffectType)
  75. PARAMETER_ID (delayEffectValue)
  76. PARAMETER_ID (delayEffectSmoothing)
  77. PARAMETER_ID (delayEffectLowpass)
  78. PARAMETER_ID (delayEffectFeedback)
  79. PARAMETER_ID (delayEffectMix)
  80. PARAMETER_ID (phaserEnabled)
  81. PARAMETER_ID (phaserRate)
  82. PARAMETER_ID (phaserDepth)
  83. PARAMETER_ID (phaserCentreFrequency)
  84. PARAMETER_ID (phaserFeedback)
  85. PARAMETER_ID (phaserMix)
  86. PARAMETER_ID (chorusEnabled)
  87. PARAMETER_ID (chorusRate)
  88. PARAMETER_ID (chorusDepth)
  89. PARAMETER_ID (chorusCentreDelay)
  90. PARAMETER_ID (chorusFeedback)
  91. PARAMETER_ID (chorusMix)
  92. PARAMETER_ID (ladderEnabled)
  93. PARAMETER_ID (ladderCutoff)
  94. PARAMETER_ID (ladderResonance)
  95. PARAMETER_ID (ladderDrive)
  96. PARAMETER_ID (ladderMode)
  97. #undef PARAMETER_ID
  98. }
  99. template <typename Func, typename... Items>
  100. constexpr void forEach (Func&& func, Items&&... items)
  101. noexcept (noexcept (std::initializer_list<int> { (func (std::forward<Items> (items)), 0)... }))
  102. {
  103. (void) std::initializer_list<int> { ((void) func (std::forward<Items> (items)), 0)... };
  104. }
  105. template <typename... Components>
  106. void addAllAndMakeVisible (Component& target, Components&... children)
  107. {
  108. forEach ([&] (Component& child) { target.addAndMakeVisible (child); }, children...);
  109. }
  110. template <typename... Processors>
  111. void prepareAll (const dsp::ProcessSpec& spec, Processors&... processors)
  112. {
  113. forEach ([&] (auto& proc) { proc.prepare (spec); }, processors...);
  114. }
  115. template <typename... Processors>
  116. void resetAll (Processors&... processors)
  117. {
  118. forEach ([] (auto& proc) { proc.reset(); }, processors...);
  119. }
  120. //==============================================================================
  121. class DspModulePluginDemo : public AudioProcessor,
  122. private ValueTree::Listener
  123. {
  124. public:
  125. DspModulePluginDemo()
  126. {
  127. apvts.state.addListener (this);
  128. forEach ([] (dsp::Gain<float>& gain) { gain.setRampDurationSeconds (0.05); },
  129. dsp::get<inputGainIndex> (chain),
  130. dsp::get<outputGainIndex> (chain));
  131. dsp::get<pannerIndex> (chain).setRule (dsp::PannerRule::linear);
  132. }
  133. //==============================================================================
  134. void prepareToPlay (double sampleRate, int samplesPerBlock) override
  135. {
  136. if (jmin (getTotalNumInputChannels(), getTotalNumOutputChannels()) == 0)
  137. return;
  138. chain.prepare ({ sampleRate, (uint32) samplesPerBlock, (uint32) getTotalNumOutputChannels() });
  139. reset();
  140. }
  141. void reset() override
  142. {
  143. chain.reset();
  144. update();
  145. }
  146. void releaseResources() override {}
  147. void processBlock (AudioBuffer<float>& buffer, MidiBuffer&) override
  148. {
  149. if (jmin (getTotalNumInputChannels(), getTotalNumOutputChannels()) == 0)
  150. return;
  151. ScopedNoDenormals noDenormals;
  152. if (requiresUpdate.load())
  153. update();
  154. const auto totalNumInputChannels = getTotalNumInputChannels();
  155. const auto totalNumOutputChannels = getTotalNumOutputChannels();
  156. const auto numChannels = jmax (totalNumInputChannels, totalNumOutputChannels);
  157. auto inoutBlock = dsp::AudioBlock<float> (buffer).getSubsetChannelBlock (0, (size_t) numChannels);
  158. chain.process (dsp::ProcessContextReplacing<float> (inoutBlock));
  159. }
  160. void processBlock (AudioBuffer<double>&, MidiBuffer&) override {}
  161. //==============================================================================
  162. AudioProcessorEditor* createEditor() override { return nullptr; }
  163. bool hasEditor() const override { return false; }
  164. //==============================================================================
  165. const String getName() const override { return "DSPModulePluginDemo"; }
  166. bool acceptsMidi() const override { return false; }
  167. bool producesMidi() const override { return false; }
  168. bool isMidiEffect() const override { return false; }
  169. double getTailLengthSeconds() const override { return 0.0; }
  170. //==============================================================================
  171. int getNumPrograms() override { return 1; }
  172. int getCurrentProgram() override { return 0; }
  173. void setCurrentProgram (int) override {}
  174. const String getProgramName (int) override { return {}; }
  175. void changeProgramName (int, const String&) override {}
  176. //==============================================================================
  177. void getStateInformation (MemoryBlock& destData) override
  178. {
  179. copyXmlToBinary (*apvts.copyState().createXml(), destData);
  180. }
  181. void setStateInformation (const void* data, int sizeInBytes) override
  182. {
  183. apvts.replaceState (ValueTree::fromXml (*getXmlFromBinary (data, sizeInBytes)));
  184. }
  185. //==============================================================================
  186. AudioProcessorValueTreeState apvts { *this, nullptr, "state", createParameters() };
  187. // We store this here so that the editor retains its state if it is closed and reopened
  188. int indexTab = 0;
  189. private:
  190. //==============================================================================
  191. void valueTreePropertyChanged (ValueTree&, const Identifier&) override
  192. {
  193. requiresUpdate.store (true);
  194. }
  195. // This struct holds references to the raw parameter values, so that we don't have to look up
  196. // the parameters (involving string comparisons and map lookups!) every time a parameter
  197. // changes.
  198. struct ParameterValues
  199. {
  200. explicit ParameterValues (AudioProcessorValueTreeState& state)
  201. : inputGain (*state.getRawParameterValue (ID::inputGain)),
  202. outputGain (*state.getRawParameterValue (ID::outputGain)),
  203. pan (*state.getRawParameterValue (ID::pan)),
  204. distortionEnabled (*state.getRawParameterValue (ID::distortionEnabled)),
  205. distortionType (*state.getRawParameterValue (ID::distortionType)),
  206. distortionOversampler (*state.getRawParameterValue (ID::distortionOversampler)),
  207. distortionLowpass (*state.getRawParameterValue (ID::distortionLowpass)),
  208. distortionHighpass (*state.getRawParameterValue (ID::distortionHighpass)),
  209. distortionInGain (*state.getRawParameterValue (ID::distortionInGain)),
  210. distortionCompGain (*state.getRawParameterValue (ID::distortionCompGain)),
  211. distortionMix (*state.getRawParameterValue (ID::distortionMix)),
  212. multiBandEnabled (*state.getRawParameterValue (ID::multiBandEnabled)),
  213. multiBandFreq (*state.getRawParameterValue (ID::multiBandFreq)),
  214. multiBandLowVolume (*state.getRawParameterValue (ID::multiBandLowVolume)),
  215. multiBandHighVolume (*state.getRawParameterValue (ID::multiBandHighVolume)),
  216. compressorEnabled (*state.getRawParameterValue (ID::compressorEnabled)),
  217. compressorThreshold (*state.getRawParameterValue (ID::compressorThreshold)),
  218. compressorRatio (*state.getRawParameterValue (ID::compressorRatio)),
  219. compressorAttack (*state.getRawParameterValue (ID::compressorAttack)),
  220. compressorRelease (*state.getRawParameterValue (ID::compressorRelease)),
  221. noiseGateEnabled (*state.getRawParameterValue (ID::noiseGateEnabled)),
  222. noiseGateThreshold (*state.getRawParameterValue (ID::noiseGateThreshold)),
  223. noiseGateRatio (*state.getRawParameterValue (ID::noiseGateRatio)),
  224. noiseGateAttack (*state.getRawParameterValue (ID::noiseGateAttack)),
  225. noiseGateRelease (*state.getRawParameterValue (ID::noiseGateRelease)),
  226. limiterEnabled (*state.getRawParameterValue (ID::limiterEnabled)),
  227. limiterThreshold (*state.getRawParameterValue (ID::limiterThreshold)),
  228. limiterRelease (*state.getRawParameterValue (ID::limiterRelease)),
  229. directDelayEnabled (*state.getRawParameterValue (ID::directDelayEnabled)),
  230. directDelayType (*state.getRawParameterValue (ID::directDelayType)),
  231. directDelayValue (*state.getRawParameterValue (ID::directDelayValue)),
  232. directDelaySmoothing (*state.getRawParameterValue (ID::directDelaySmoothing)),
  233. directDelayMix (*state.getRawParameterValue (ID::directDelayMix)),
  234. delayEffectEnabled (*state.getRawParameterValue (ID::delayEffectEnabled)),
  235. delayEffectType (*state.getRawParameterValue (ID::delayEffectType)),
  236. delayEffectValue (*state.getRawParameterValue (ID::delayEffectValue)),
  237. delayEffectSmoothing (*state.getRawParameterValue (ID::delayEffectSmoothing)),
  238. delayEffectLowpass (*state.getRawParameterValue (ID::delayEffectLowpass)),
  239. delayEffectFeedback (*state.getRawParameterValue (ID::delayEffectFeedback)),
  240. delayEffectMix (*state.getRawParameterValue (ID::delayEffectMix)),
  241. phaserEnabled (*state.getRawParameterValue (ID::phaserEnabled)),
  242. phaserRate (*state.getRawParameterValue (ID::phaserRate)),
  243. phaserDepth (*state.getRawParameterValue (ID::phaserDepth)),
  244. phaserCentreFrequency (*state.getRawParameterValue (ID::phaserCentreFrequency)),
  245. phaserFeedback (*state.getRawParameterValue (ID::phaserFeedback)),
  246. phaserMix (*state.getRawParameterValue (ID::phaserMix)),
  247. chorusEnabled (*state.getRawParameterValue (ID::chorusEnabled)),
  248. chorusRate (*state.getRawParameterValue (ID::chorusRate)),
  249. chorusDepth (*state.getRawParameterValue (ID::chorusDepth)),
  250. chorusCentreDelay (*state.getRawParameterValue (ID::chorusCentreDelay)),
  251. chorusFeedback (*state.getRawParameterValue (ID::chorusFeedback)),
  252. chorusMix (*state.getRawParameterValue (ID::chorusMix)),
  253. ladderEnabled (*state.getRawParameterValue (ID::ladderEnabled)),
  254. ladderCutoff (*state.getRawParameterValue (ID::ladderCutoff)),
  255. ladderResonance (*state.getRawParameterValue (ID::ladderResonance)),
  256. ladderDrive (*state.getRawParameterValue (ID::ladderDrive)),
  257. ladderMode (*state.getRawParameterValue (ID::ladderMode))
  258. {}
  259. std::atomic<float>& inputGain;
  260. std::atomic<float>& outputGain;
  261. std::atomic<float>& pan;
  262. std::atomic<float>& distortionEnabled;
  263. std::atomic<float>& distortionType;
  264. std::atomic<float>& distortionOversampler;
  265. std::atomic<float>& distortionLowpass;
  266. std::atomic<float>& distortionHighpass;
  267. std::atomic<float>& distortionInGain;
  268. std::atomic<float>& distortionCompGain;
  269. std::atomic<float>& distortionMix;
  270. std::atomic<float>& multiBandEnabled;
  271. std::atomic<float>& multiBandFreq;
  272. std::atomic<float>& multiBandLowVolume;
  273. std::atomic<float>& multiBandHighVolume;
  274. std::atomic<float>& compressorEnabled;
  275. std::atomic<float>& compressorThreshold;
  276. std::atomic<float>& compressorRatio;
  277. std::atomic<float>& compressorAttack;
  278. std::atomic<float>& compressorRelease;
  279. std::atomic<float>& noiseGateEnabled;
  280. std::atomic<float>& noiseGateThreshold;
  281. std::atomic<float>& noiseGateRatio;
  282. std::atomic<float>& noiseGateAttack;
  283. std::atomic<float>& noiseGateRelease;
  284. std::atomic<float>& limiterEnabled;
  285. std::atomic<float>& limiterThreshold;
  286. std::atomic<float>& limiterRelease;
  287. std::atomic<float>& directDelayEnabled;
  288. std::atomic<float>& directDelayType;
  289. std::atomic<float>& directDelayValue;
  290. std::atomic<float>& directDelaySmoothing;
  291. std::atomic<float>& directDelayMix;
  292. std::atomic<float>& delayEffectEnabled;
  293. std::atomic<float>& delayEffectType;
  294. std::atomic<float>& delayEffectValue;
  295. std::atomic<float>& delayEffectSmoothing;
  296. std::atomic<float>& delayEffectLowpass;
  297. std::atomic<float>& delayEffectFeedback;
  298. std::atomic<float>& delayEffectMix;
  299. std::atomic<float>& phaserEnabled;
  300. std::atomic<float>& phaserRate;
  301. std::atomic<float>& phaserDepth;
  302. std::atomic<float>& phaserCentreFrequency;
  303. std::atomic<float>& phaserFeedback;
  304. std::atomic<float>& phaserMix;
  305. std::atomic<float>& chorusEnabled;
  306. std::atomic<float>& chorusRate;
  307. std::atomic<float>& chorusDepth;
  308. std::atomic<float>& chorusCentreDelay;
  309. std::atomic<float>& chorusFeedback;
  310. std::atomic<float>& chorusMix;
  311. std::atomic<float>& ladderEnabled;
  312. std::atomic<float>& ladderCutoff;
  313. std::atomic<float>& ladderResonance;
  314. std::atomic<float>& ladderDrive;
  315. std::atomic<float>& ladderMode;
  316. };
  317. ParameterValues parameters { apvts };
  318. //==============================================================================
  319. void update()
  320. {
  321. {
  322. DistortionProcessor& distortion = dsp::get<distortionIndex> (chain);
  323. if (distortion.currentIndexOversampling != parameters.distortionOversampler.load())
  324. {
  325. distortion.currentIndexOversampling = roundToInt (parameters.distortionOversampler.load());
  326. prepareToPlay (getSampleRate(), getBlockSize());
  327. return;
  328. }
  329. distortion.currentIndexWaveshaper = roundToInt (parameters.distortionType.load());
  330. distortion.lowpass .setCutoffFrequency (parameters.distortionLowpass);
  331. distortion.highpass.setCutoffFrequency (parameters.distortionHighpass);
  332. distortion.distGain.setGainDecibels (parameters.distortionInGain);
  333. distortion.compGain.setGainDecibels (parameters.distortionCompGain);
  334. distortion.mixer.setWetMixProportion (parameters.distortionMix / 100.0f);
  335. dsp::setBypassed<distortionIndex> (chain, parameters.distortionEnabled.load() == 0.0f);
  336. }
  337. dsp::get<inputGainIndex> (chain).setGainDecibels (parameters.inputGain);
  338. dsp::get<outputGainIndex> (chain).setGainDecibels (parameters.outputGain);
  339. dsp::get<pannerIndex> (chain).setPan (parameters.pan / 100.0f);
  340. {
  341. MultiBandProcessor& multiband = dsp::get<multiBandIndex> (chain);
  342. const auto multibandFreq = parameters.multiBandFreq.load();
  343. multiband.lowpass .setCutoffFrequency (multibandFreq);
  344. multiband.highpass.setCutoffFrequency (multibandFreq);
  345. const auto enabled = parameters.multiBandEnabled.load() != 0.0f;
  346. multiband.lowVolume .setGainDecibels (enabled ? parameters.multiBandLowVolume .load() : 0.0f);
  347. multiband.highVolume.setGainDecibels (enabled ? parameters.multiBandHighVolume.load() : 0.0f);
  348. dsp::setBypassed<multiBandIndex> (chain, ! enabled);
  349. }
  350. {
  351. dsp::Compressor<float>& compressor = dsp::get<compressorIndex> (chain);
  352. compressor.setThreshold (parameters.compressorThreshold);
  353. compressor.setRatio (parameters.compressorRatio);
  354. compressor.setAttack (parameters.compressorAttack);
  355. compressor.setRelease (parameters.compressorRelease);
  356. dsp::setBypassed<compressorIndex> (chain, parameters.compressorEnabled.load() == 0.0f);
  357. }
  358. {
  359. dsp::NoiseGate<float>& noiseGate = dsp::get<noiseGateIndex> (chain);
  360. noiseGate.setThreshold (parameters.noiseGateThreshold);
  361. noiseGate.setRatio (parameters.noiseGateRatio);
  362. noiseGate.setAttack (parameters.noiseGateAttack);
  363. noiseGate.setRelease (parameters.noiseGateRelease);
  364. dsp::setBypassed<noiseGateIndex> (chain, parameters.noiseGateEnabled.load() == 0.0f);
  365. }
  366. {
  367. dsp::Limiter<float>& limiter = dsp::get<limiterIndex> (chain);
  368. limiter.setThreshold (parameters.limiterThreshold);
  369. limiter.setRelease (parameters.limiterRelease);
  370. dsp::setBypassed<limiterIndex> (chain, parameters.limiterEnabled.load() == 0.0f);
  371. }
  372. {
  373. DirectDelayProcessor& delay = dsp::get<directDelayIndex> (chain);
  374. delay.delayLineDirectType = roundToInt (parameters.directDelayType.load());
  375. std::fill (delay.delayDirectValue.begin(),
  376. delay.delayDirectValue.end(),
  377. (double) parameters.directDelayValue);
  378. delay.smoothFilter.setCutoffFrequency (1000.0 / parameters.directDelaySmoothing);
  379. delay.mixer.setWetMixProportion (parameters.directDelayMix / 100.0f);
  380. dsp::setBypassed<directDelayIndex> (chain, parameters.directDelayEnabled.load() == 0.0f);
  381. }
  382. {
  383. DelayEffectProcessor& delay = dsp::get<delayEffectIndex> (chain);
  384. delay.delayEffectType = roundToInt (parameters.delayEffectType.load());
  385. std::fill (delay.delayEffectValue.begin(),
  386. delay.delayEffectValue.end(),
  387. (double) parameters.delayEffectValue / 1000.0 * getSampleRate());
  388. const auto feedbackGain = Decibels::decibelsToGain (parameters.delayEffectFeedback.load(), -100.0f);
  389. for (auto& volume : delay.delayFeedbackVolume)
  390. volume.setTargetValue (feedbackGain);
  391. delay.smoothFilter.setCutoffFrequency (1000.0 / parameters.delayEffectSmoothing);
  392. delay.lowpass.setCutoffFrequency (parameters.delayEffectLowpass);
  393. delay.mixer.setWetMixProportion (parameters.delayEffectMix / 100.0f);
  394. dsp::setBypassed<delayEffectIndex> (chain, parameters.delayEffectEnabled.load() == 0.0f);
  395. }
  396. {
  397. dsp::Phaser<float>& phaser = dsp::get<phaserIndex> (chain);
  398. phaser.setRate (parameters.phaserRate);
  399. phaser.setDepth (parameters.phaserDepth / 100.0f);
  400. phaser.setCentreFrequency (parameters.phaserCentreFrequency);
  401. phaser.setFeedback (parameters.phaserFeedback / 100.0f * 0.95f);
  402. phaser.setMix (parameters.phaserMix / 100.0f);
  403. dsp::setBypassed<phaserIndex> (chain, parameters.phaserEnabled.load() == 0.0f);
  404. }
  405. {
  406. dsp::Chorus<float>& chorus = dsp::get<chorusIndex> (chain);
  407. chorus.setRate (parameters.chorusRate);
  408. chorus.setDepth (parameters.chorusDepth / 100.0f);
  409. chorus.setCentreDelay (parameters.chorusCentreDelay);
  410. chorus.setFeedback (parameters.chorusFeedback / 100.0f * 0.95f);
  411. chorus.setMix (parameters.chorusMix / 100.0f);
  412. dsp::setBypassed<chorusIndex> (chain, parameters.chorusEnabled.load() == 0.0f);
  413. }
  414. {
  415. dsp::LadderFilter<float>& ladder = dsp::get<ladderIndex> (chain);
  416. ladder.setCutoffFrequencyHz (parameters.ladderCutoff);
  417. ladder.setResonance (parameters.ladderResonance / 100.0f);
  418. ladder.setDrive (Decibels::decibelsToGain (parameters.ladderDrive.load()));
  419. ladder.setMode ([&]
  420. {
  421. switch (roundToInt (parameters.ladderMode.load()))
  422. {
  423. case 0: return dsp::LadderFilterMode::LPF12;
  424. case 1: return dsp::LadderFilterMode::LPF24;
  425. case 2: return dsp::LadderFilterMode::HPF12;
  426. case 3: return dsp::LadderFilterMode::HPF24;
  427. case 4: return dsp::LadderFilterMode::BPF12;
  428. }
  429. return dsp::LadderFilterMode::BPF24;
  430. }());
  431. dsp::setBypassed<ladderIndex> (chain, parameters.ladderEnabled.load() == 0.0f);
  432. }
  433. requiresUpdate.store (false);
  434. }
  435. //==============================================================================
  436. static String getPanningTextForValue (float value)
  437. {
  438. if (value == 0.5f)
  439. return "center";
  440. if (value < 0.5f)
  441. return String (roundToInt ((0.5f - value) * 200.0f)) + "%L";
  442. return String (roundToInt ((value - 0.5f) * 200.0f)) + "%R";
  443. }
  444. static float getPanningValueForText (String strText)
  445. {
  446. if (strText.compareIgnoreCase ("center") == 0 || strText.compareIgnoreCase ("c") == 0)
  447. return 0.5f;
  448. strText = strText.trim();
  449. if (strText.indexOfIgnoreCase ("%L") != -1)
  450. {
  451. auto percentage = (float) strText.substring (0, strText.indexOf ("%")).getDoubleValue();
  452. return (100.0f - percentage) / 100.0f * 0.5f;
  453. }
  454. if (strText.indexOfIgnoreCase ("%R") != -1)
  455. {
  456. auto percentage = (float) strText.substring (0, strText.indexOf ("%")).getDoubleValue();
  457. return percentage / 100.0f * 0.5f + 0.5f;
  458. }
  459. return 0.5f;
  460. }
  461. static AudioProcessorValueTreeState::ParameterLayout createParameters()
  462. {
  463. using Parameter = AudioProcessorValueTreeState::Parameter;
  464. auto valueToTextFunction = [] (float x) { return String (x, 2); };
  465. auto textToValueFunction = [] (const String& str) { return str.getFloatValue(); };
  466. auto valueToTextPanFunction = [] (float x) { return getPanningTextForValue ((x + 100.0f) / 200.0f); };
  467. auto textToValuePanFunction = [] (const String& str) { return getPanningValueForText (str) * 200.0f - 100.0f; };
  468. AudioProcessorValueTreeState::ParameterLayout layout;
  469. layout.add (std::make_unique<Parameter> (ID::inputGain,
  470. "Input",
  471. "dB",
  472. NormalisableRange<float> (-40.0f, 40.0f),
  473. 0.0f,
  474. valueToTextFunction,
  475. textToValueFunction));
  476. layout.add (std::make_unique<Parameter> (ID::outputGain,
  477. "Output",
  478. "dB",
  479. NormalisableRange<float> (-40.0f, 40.0f),
  480. 0.0f,
  481. valueToTextFunction,
  482. textToValueFunction));
  483. layout.add (std::make_unique<Parameter> (ID::pan,
  484. "Panning",
  485. "",
  486. NormalisableRange<float> (-100.0f, 100.0f),
  487. 0.0f,
  488. valueToTextPanFunction,
  489. textToValuePanFunction));
  490. layout.add (std::make_unique<AudioParameterBool> (ID::distortionEnabled, "Distortion", true, ""));
  491. layout.add (std::make_unique<AudioParameterChoice> (ID::distortionType,
  492. "Waveshaper",
  493. StringArray { "std::tanh", "Approx. tanh" },
  494. 0));
  495. layout.add (std::make_unique<Parameter> (ID::distortionInGain,
  496. "Gain",
  497. "dB",
  498. NormalisableRange<float> (-40.0f, 40.0f),
  499. 0.0f,
  500. valueToTextFunction,
  501. textToValueFunction));
  502. layout.add (std::make_unique<Parameter> (ID::distortionLowpass,
  503. "Post Low-pass",
  504. "Hz",
  505. NormalisableRange<float> (20.0f, 22000.0f, 0.0f, 0.25f),
  506. 22000.0f,
  507. valueToTextFunction,
  508. textToValueFunction));
  509. layout.add (std::make_unique<Parameter> (ID::distortionHighpass,
  510. "Pre High-pass",
  511. "Hz",
  512. NormalisableRange<float> (20.0f, 22000.0f, 0.0f, 0.25f),
  513. 20.0f,
  514. valueToTextFunction,
  515. textToValueFunction));
  516. layout.add (std::make_unique<Parameter> (ID::distortionCompGain,
  517. "Compensat.",
  518. "dB",
  519. NormalisableRange<float> (-40.0f, 40.0f),
  520. 0.0f,
  521. valueToTextFunction,
  522. textToValueFunction));
  523. layout.add (std::make_unique<Parameter> (ID::distortionMix,
  524. "Mix",
  525. "%",
  526. NormalisableRange<float> (0.0f, 100.0f),
  527. 100.0f,
  528. valueToTextFunction,
  529. textToValueFunction));
  530. layout.add (std::make_unique<AudioParameterChoice> (ID::distortionOversampler,
  531. "Oversampling",
  532. StringArray { "2X",
  533. "4X",
  534. "8X",
  535. "2X compensated",
  536. "4X compensated",
  537. "8X compensated" },
  538. 1));
  539. layout.add (std::make_unique<AudioParameterBool> (ID::multiBandEnabled, "Multi-band", false, ""));
  540. layout.add (std::make_unique<Parameter> (ID::multiBandFreq,
  541. "Sep. Freq.",
  542. "Hz",
  543. NormalisableRange<float> (20.0f, 22000.0f, 0.0f, 0.25f),
  544. 2000.0f,
  545. valueToTextFunction,
  546. textToValueFunction));
  547. layout.add (std::make_unique<Parameter> (ID::multiBandLowVolume,
  548. "Low volume",
  549. "dB",
  550. NormalisableRange<float> (-40.0f, 40.0f),
  551. 0.0f,
  552. valueToTextFunction,
  553. textToValueFunction));
  554. layout.add (std::make_unique<Parameter> (ID::multiBandHighVolume,
  555. "High volume",
  556. "dB",
  557. NormalisableRange<float> (-40.0f, 40.0f),
  558. 0.0f,
  559. valueToTextFunction,
  560. textToValueFunction));
  561. layout.add (std::make_unique<AudioParameterBool> (ID::compressorEnabled, "Comp.", false, ""));
  562. layout.add (std::make_unique<Parameter> (ID::compressorThreshold,
  563. "Threshold",
  564. "dB",
  565. NormalisableRange<float> (-100.0f, 0.0f),
  566. 0.0f,
  567. valueToTextFunction,
  568. textToValueFunction));
  569. layout.add (std::make_unique<Parameter> (ID::compressorRatio,
  570. "Ratio",
  571. ":1",
  572. NormalisableRange<float> (1.0f, 100.0f, 0.0f, 0.25f),
  573. 1.0f,
  574. valueToTextFunction,
  575. textToValueFunction));
  576. layout.add (std::make_unique<Parameter> (ID::compressorAttack,
  577. "Attack",
  578. "ms",
  579. NormalisableRange<float> (0.01f, 1000.0f, 0.0f, 0.25f),
  580. 1.0f,
  581. valueToTextFunction,
  582. textToValueFunction));
  583. layout.add (std::make_unique<Parameter> (ID::compressorRelease,
  584. "Release",
  585. "ms",
  586. NormalisableRange<float> (10.0f, 10000.0f, 0.0f, 0.25f),
  587. 100.0f,
  588. valueToTextFunction,
  589. textToValueFunction));
  590. layout.add (std::make_unique<AudioParameterBool> (ID::noiseGateEnabled, "Gate", false, ""));
  591. layout.add (std::make_unique<Parameter> (ID::noiseGateThreshold,
  592. "Threshold",
  593. "dB",
  594. NormalisableRange<float> (-100.0f, 0.0f),
  595. -100.0f,
  596. valueToTextFunction,
  597. textToValueFunction));
  598. layout.add (std::make_unique<Parameter> (ID::noiseGateRatio,
  599. "Ratio",
  600. ":1",
  601. NormalisableRange<float> (1.0f, 100.0f, 0.0f, 0.25f),
  602. 10.0f,
  603. valueToTextFunction,
  604. textToValueFunction));
  605. layout.add (std::make_unique<Parameter> (ID::noiseGateAttack,
  606. "Attack",
  607. "ms",
  608. NormalisableRange<float> (0.01f, 1000.0f, 0.0f, 0.25f),
  609. 1.0f,
  610. valueToTextFunction,
  611. textToValueFunction));
  612. layout.add (std::make_unique<Parameter> (ID::noiseGateRelease,
  613. "Release",
  614. "ms",
  615. NormalisableRange<float> (10.0f, 10000.0f, 0.0f, 0.25f),
  616. 100.0f,
  617. valueToTextFunction,
  618. textToValueFunction));
  619. layout.add (std::make_unique<AudioParameterBool> (ID::limiterEnabled, "Limiter", false, ""));
  620. layout.add (std::make_unique<Parameter> (ID::limiterThreshold,
  621. "Threshold",
  622. "dB",
  623. NormalisableRange<float> (-40.0f, 0.0f),
  624. 0.0f,
  625. valueToTextFunction,
  626. textToValueFunction));
  627. layout.add (std::make_unique<Parameter> (ID::limiterRelease,
  628. "Release",
  629. "ms",
  630. NormalisableRange<float> (10.0f, 10000.0f, 0.0f, 0.25f),
  631. 100.0f,
  632. valueToTextFunction,
  633. textToValueFunction));
  634. layout.add (std::make_unique<AudioParameterBool> (ID::directDelayEnabled, "DL Dir.", false, ""));
  635. layout.add (std::make_unique<AudioParameterChoice> (ID::directDelayType,
  636. "DL Type",
  637. StringArray { "None",
  638. "Linear",
  639. "Lagrange",
  640. "Thiran" },
  641. 1));
  642. layout.add (std::make_unique<Parameter> (ID::directDelayValue,
  643. "Delay",
  644. "smps",
  645. NormalisableRange<float> (0.0f, 44100.0f),
  646. 0.0f,
  647. valueToTextFunction,
  648. textToValueFunction));
  649. layout.add (std::make_unique<Parameter> (ID::directDelaySmoothing,
  650. "Smooth",
  651. "ms",
  652. NormalisableRange<float> (20.0f, 10000.0f, 0.0f, 0.25f),
  653. 200.0f,
  654. valueToTextFunction,
  655. textToValueFunction));
  656. layout.add (std::make_unique<Parameter> (ID::directDelayMix,
  657. "Delay Mix",
  658. "%",
  659. NormalisableRange<float> (0.0f, 100.0f),
  660. 50.0f,
  661. valueToTextFunction,
  662. textToValueFunction));
  663. layout.add (std::make_unique<AudioParameterBool> (ID::delayEffectEnabled, "DL Effect", false, ""));
  664. layout.add (std::make_unique<AudioParameterChoice> (ID::delayEffectType,
  665. "DL Type",
  666. StringArray { "None",
  667. "Linear",
  668. "Lagrange",
  669. "Thiran" },
  670. 1));
  671. layout.add (std::make_unique<Parameter> (ID::delayEffectValue,
  672. "Delay",
  673. "ms",
  674. NormalisableRange<float> (0.01f, 1000.0f),
  675. 100.0f,
  676. valueToTextFunction,
  677. textToValueFunction));
  678. layout.add (std::make_unique<Parameter> (ID::delayEffectSmoothing,
  679. "Smooth",
  680. "ms",
  681. NormalisableRange<float> (20.0f, 10000.0f, 0.0f, 0.25f),
  682. 400.0f,
  683. valueToTextFunction,
  684. textToValueFunction));
  685. layout.add (std::make_unique<Parameter> (ID::delayEffectLowpass,
  686. "Low-pass",
  687. "Hz",
  688. NormalisableRange<float> (20.0f, 22000.0f, 0.0f, 0.25f),
  689. 22000.0f,
  690. valueToTextFunction,
  691. textToValueFunction));
  692. layout.add (std::make_unique<Parameter> (ID::delayEffectMix,
  693. "Delay Mix",
  694. "%",
  695. NormalisableRange<float> (0.0f, 100.0f),
  696. 50.0f,
  697. valueToTextFunction,
  698. textToValueFunction));
  699. layout.add (std::make_unique<Parameter> (ID::delayEffectFeedback,
  700. "Feedback",
  701. "dB",
  702. NormalisableRange<float> (-100.0f, 0.0f),
  703. -100.0f,
  704. valueToTextFunction,
  705. textToValueFunction));
  706. layout.add (std::make_unique<AudioParameterBool> (ID::phaserEnabled, "Phaser", false, ""));
  707. layout.add (std::make_unique<Parameter> (ID::phaserRate,
  708. "Rate",
  709. "Hz",
  710. NormalisableRange<float> (0.05f, 20.0f, 0.0f, 0.25f),
  711. 1.0f,
  712. valueToTextFunction,
  713. textToValueFunction));
  714. layout.add (std::make_unique<Parameter> (ID::phaserDepth,
  715. "Depth",
  716. "%",
  717. NormalisableRange<float> (0.0f, 100.0f),
  718. 50.0f,
  719. valueToTextFunction,
  720. textToValueFunction));
  721. layout.add (std::make_unique<Parameter> (ID::phaserCentreFrequency,
  722. "Center",
  723. "Hz",
  724. NormalisableRange<float> (20.0f, 20000.0f, 0.0f, 0.25f),
  725. 600.0f,
  726. valueToTextFunction,
  727. textToValueFunction));
  728. layout.add (std::make_unique<Parameter> (ID::phaserFeedback,
  729. "Feedback",
  730. "%",
  731. NormalisableRange<float> (0.0f, 100.0f),
  732. 50.0f,
  733. valueToTextFunction,
  734. textToValueFunction));
  735. layout.add (std::make_unique<Parameter> (ID::phaserMix,
  736. "Mix",
  737. "%",
  738. NormalisableRange<float> (0.0f, 100.0f),
  739. 50.0f,
  740. valueToTextFunction,
  741. textToValueFunction));
  742. layout.add (std::make_unique<AudioParameterBool> (ID::chorusEnabled, "Chorus", false, ""));
  743. layout.add (std::make_unique<Parameter> (ID::chorusRate,
  744. "Rate",
  745. "Hz",
  746. NormalisableRange<float> (0.05f, 20.0f, 0.0f, 0.25f),
  747. 1.0f,
  748. valueToTextFunction,
  749. textToValueFunction));
  750. layout.add (std::make_unique<Parameter> (ID::chorusDepth,
  751. "Depth",
  752. "%",
  753. NormalisableRange<float> (0.0f, 100.0f),
  754. 50.0f,
  755. valueToTextFunction,
  756. textToValueFunction));
  757. layout.add (std::make_unique<Parameter> (ID::chorusCentreDelay,
  758. "Center",
  759. "ms",
  760. NormalisableRange<float> (1.0f, 100.0f, 0.0f, 0.25f),
  761. 7.0f,
  762. valueToTextFunction,
  763. textToValueFunction));
  764. layout.add (std::make_unique<Parameter> (ID::chorusFeedback,
  765. "Feedback",
  766. "%",
  767. NormalisableRange<float> (0.0f, 100.0f),
  768. 50.0f,
  769. valueToTextFunction,
  770. textToValueFunction));
  771. layout.add (std::make_unique<Parameter> (ID::chorusMix,
  772. "Mix",
  773. "%",
  774. NormalisableRange<float> (0.0f, 100.0f),
  775. 50.0f,
  776. valueToTextFunction,
  777. textToValueFunction));
  778. layout.add (std::make_unique<AudioParameterBool> (ID::ladderEnabled, "Ladder", false, ""));
  779. layout.add (std::make_unique<AudioParameterChoice> (ID::ladderMode,
  780. "Mode",
  781. StringArray { "LP12",
  782. "LP24",
  783. "HP12",
  784. "HP24",
  785. "BP12",
  786. "BP24" },
  787. 1));
  788. layout.add (std::make_unique<Parameter> (ID::ladderCutoff,
  789. "Frequency",
  790. "Hz",
  791. NormalisableRange<float> (10.0f, 22000.0f, 0.0f, 0.25f),
  792. 1000.0f,
  793. valueToTextFunction,
  794. textToValueFunction));
  795. layout.add (std::make_unique<Parameter> (ID::ladderResonance,
  796. "Resonance",
  797. "%",
  798. NormalisableRange<float> (0.0f, 100.0f),
  799. 0.0f,
  800. valueToTextFunction,
  801. textToValueFunction));
  802. layout.add (std::make_unique<Parameter> (ID::ladderDrive,
  803. "Drive",
  804. "dB",
  805. NormalisableRange<float> (0.0f, 40.0f),
  806. 0.0f,
  807. valueToTextFunction,
  808. textToValueFunction));
  809. return layout;
  810. }
  811. //==============================================================================
  812. struct DistortionProcessor
  813. {
  814. DistortionProcessor()
  815. {
  816. forEach ([] (dsp::Gain<float>& gain) { gain.setRampDurationSeconds (0.05); },
  817. distGain,
  818. compGain);
  819. lowpass.setType (dsp::FirstOrderTPTFilterType::lowpass);
  820. highpass.setType (dsp::FirstOrderTPTFilterType::highpass);
  821. mixer.setMixingRule (dsp::DryWetMixingRule::linear);
  822. }
  823. void prepare (const dsp::ProcessSpec& spec)
  824. {
  825. for (auto& oversampler : oversamplers)
  826. oversampler.initProcessing (spec.maximumBlockSize);
  827. prepareAll (spec, lowpass, highpass, distGain, compGain, mixer);
  828. }
  829. void reset()
  830. {
  831. for (auto& oversampler : oversamplers)
  832. oversampler.reset();
  833. resetAll (lowpass, highpass, distGain, compGain, mixer);
  834. }
  835. float getLatency() const
  836. {
  837. return oversamplers[size_t (currentIndexOversampling)].getLatencyInSamples();
  838. }
  839. template <typename Context>
  840. void process (Context& context)
  841. {
  842. if (context.isBypassed)
  843. return;
  844. const auto& inputBlock = context.getInputBlock();
  845. mixer.setWetLatency (getLatency());
  846. mixer.pushDrySamples (inputBlock);
  847. distGain.process (context);
  848. highpass.process (context);
  849. auto ovBlock = oversamplers[size_t (currentIndexOversampling)].processSamplesUp (inputBlock);
  850. dsp::ProcessContextReplacing<float> waveshaperContext (ovBlock);
  851. if (isPositiveAndBelow (currentIndexWaveshaper, waveShapers.size()))
  852. {
  853. waveShapers[size_t (currentIndexWaveshaper)].process (waveshaperContext);
  854. if (currentIndexWaveshaper == 1)
  855. clipping.process (waveshaperContext);
  856. waveshaperContext.getOutputBlock() *= 0.7f;
  857. }
  858. auto& outputBlock = context.getOutputBlock();
  859. oversamplers[size_t (currentIndexOversampling)].processSamplesDown (outputBlock);
  860. lowpass.process (context);
  861. compGain.process (context);
  862. mixer.mixWetSamples (outputBlock);
  863. }
  864. std::array<dsp::Oversampling<float>, 6> oversamplers
  865. { {
  866. { 2, 1, dsp::Oversampling<float>::filterHalfBandPolyphaseIIR, true, false },
  867. { 2, 2, dsp::Oversampling<float>::filterHalfBandPolyphaseIIR, true, false },
  868. { 2, 3, dsp::Oversampling<float>::filterHalfBandPolyphaseIIR, true, false },
  869. { 2, 1, dsp::Oversampling<float>::filterHalfBandPolyphaseIIR, true, true },
  870. { 2, 2, dsp::Oversampling<float>::filterHalfBandPolyphaseIIR, true, true },
  871. { 2, 3, dsp::Oversampling<float>::filterHalfBandPolyphaseIIR, true, true },
  872. } };
  873. dsp::FirstOrderTPTFilter<float> lowpass, highpass;
  874. dsp::Gain<float> distGain, compGain;
  875. dsp::DryWetMixer<float> mixer { 10 };
  876. std::array<dsp::WaveShaper<float>, 2> waveShapers { { { std::tanh },
  877. { dsp::FastMathApproximations::tanh } } };
  878. dsp::WaveShaper<float> clipping;
  879. int currentIndexOversampling = 0;
  880. int currentIndexWaveshaper = 0;
  881. };
  882. struct MultiBandProcessor
  883. {
  884. MultiBandProcessor()
  885. {
  886. forEach ([] (dsp::Gain<float>& gain) { gain.setRampDurationSeconds (0.05); },
  887. lowVolume,
  888. highVolume);
  889. lowpass .setType (dsp::LinkwitzRileyFilterType::lowpass);
  890. highpass.setType (dsp::LinkwitzRileyFilterType::highpass);
  891. }
  892. void prepare (const dsp::ProcessSpec& spec)
  893. {
  894. prepareAll (spec, lowpass, highpass, lowVolume, highVolume);
  895. bufferSeparation.setSize (4, int (spec.maximumBlockSize), false, false, true);
  896. }
  897. void reset()
  898. {
  899. resetAll (lowpass, highpass, lowVolume, highVolume);
  900. }
  901. template <typename Context>
  902. void process (Context& context)
  903. {
  904. const auto& inputBlock = context.getInputBlock();
  905. const auto numSamples = inputBlock.getNumSamples();
  906. const auto numChannels = inputBlock.getNumChannels();
  907. auto sepBlock = dsp::AudioBlock<float> (bufferSeparation).getSubBlock (0, (size_t) numSamples);
  908. auto sepLowBlock = sepBlock.getSubsetChannelBlock (0, (size_t) numChannels);
  909. auto sepHighBlock = sepBlock.getSubsetChannelBlock (2, (size_t) numChannels);
  910. sepLowBlock .copyFrom (inputBlock);
  911. sepHighBlock.copyFrom (inputBlock);
  912. auto contextLow = dsp::ProcessContextReplacing<float> (sepLowBlock);
  913. contextLow.isBypassed = context.isBypassed;
  914. lowpass .process (contextLow);
  915. lowVolume.process (contextLow);
  916. auto contextHigh = dsp::ProcessContextReplacing<float> (sepHighBlock);
  917. contextHigh.isBypassed = context.isBypassed;
  918. highpass .process (contextHigh);
  919. highVolume.process (contextHigh);
  920. if (! context.isBypassed)
  921. {
  922. sepLowBlock.add (sepHighBlock);
  923. context.getOutputBlock().copyFrom (sepLowBlock);
  924. }
  925. }
  926. dsp::LinkwitzRileyFilter<float> lowpass, highpass;
  927. dsp::Gain<float> lowVolume, highVolume;
  928. AudioBuffer<float> bufferSeparation;
  929. };
  930. struct DirectDelayProcessor
  931. {
  932. DirectDelayProcessor()
  933. {
  934. smoothFilter.setType (dsp::FirstOrderTPTFilterType::lowpass);
  935. mixer.setMixingRule (dsp::DryWetMixingRule::linear);
  936. }
  937. void prepare (const dsp::ProcessSpec& spec)
  938. {
  939. prepareAll (spec, noInterpolation, linear, lagrange, thiran, smoothFilter, mixer);
  940. }
  941. void reset()
  942. {
  943. resetAll (noInterpolation, linear, lagrange, thiran, smoothFilter, mixer);
  944. }
  945. template <typename Context>
  946. void process (Context& context)
  947. {
  948. if (context.isBypassed)
  949. return;
  950. const auto& inputBlock = context.getInputBlock();
  951. const auto& outputBlock = context.getOutputBlock();
  952. mixer.pushDrySamples (inputBlock);
  953. const auto numChannels = inputBlock.getNumChannels();
  954. const auto numSamples = inputBlock.getNumSamples();
  955. for (size_t channel = 0; channel < numChannels; ++channel)
  956. {
  957. auto* samplesIn = inputBlock .getChannelPointer (channel);
  958. auto* samplesOut = outputBlock.getChannelPointer (channel);
  959. for (size_t i = 0; i < numSamples; ++i)
  960. {
  961. const auto delay = smoothFilter.processSample (int (channel), delayDirectValue[channel]);
  962. samplesOut[i] = [&]
  963. {
  964. switch (delayLineDirectType)
  965. {
  966. case 0:
  967. noInterpolation.pushSample (int (channel), samplesIn[i]);
  968. noInterpolation.setDelay ((float) delay);
  969. return noInterpolation.popSample (int (channel));
  970. case 1:
  971. linear.pushSample (int (channel), samplesIn[i]);
  972. linear.setDelay ((float) delay);
  973. return linear.popSample (int (channel));
  974. case 2:
  975. lagrange.pushSample (int (channel), samplesIn[i]);
  976. lagrange.setDelay ((float) delay);
  977. return lagrange.popSample (int (channel));
  978. case 3:
  979. thiran.pushSample (int (channel), samplesIn[i]);
  980. thiran.setDelay ((float) delay);
  981. return thiran.popSample (int (channel));
  982. }
  983. jassertfalse;
  984. return 0.0f;
  985. }();
  986. }
  987. }
  988. mixer.mixWetSamples (outputBlock);
  989. }
  990. static constexpr auto directDelayBufferSize = 44100;
  991. dsp::DelayLine<float, dsp::DelayLineInterpolationTypes::None> noInterpolation { directDelayBufferSize };
  992. dsp::DelayLine<float, dsp::DelayLineInterpolationTypes::Linear> linear { directDelayBufferSize };
  993. dsp::DelayLine<float, dsp::DelayLineInterpolationTypes::Lagrange3rd> lagrange { directDelayBufferSize };
  994. dsp::DelayLine<float, dsp::DelayLineInterpolationTypes::Thiran> thiran { directDelayBufferSize };
  995. // Double precision to avoid some approximation issues
  996. dsp::FirstOrderTPTFilter<double> smoothFilter;
  997. dsp::DryWetMixer<float> mixer;
  998. std::array<double, 2> delayDirectValue { {} };
  999. int delayLineDirectType = 1;
  1000. };
  1001. struct DelayEffectProcessor
  1002. {
  1003. DelayEffectProcessor()
  1004. {
  1005. smoothFilter.setType (dsp::FirstOrderTPTFilterType::lowpass);
  1006. lowpass.setType (dsp::FirstOrderTPTFilterType::lowpass);
  1007. mixer.setMixingRule (dsp::DryWetMixingRule::linear);
  1008. }
  1009. void prepare (const dsp::ProcessSpec& spec)
  1010. {
  1011. prepareAll (spec, noInterpolation, linear, lagrange, thiran, smoothFilter, lowpass, mixer);
  1012. for (auto& volume : delayFeedbackVolume)
  1013. volume.reset (spec.sampleRate, 0.05);
  1014. }
  1015. void reset()
  1016. {
  1017. resetAll (noInterpolation, linear, lagrange, thiran, smoothFilter, lowpass, mixer);
  1018. std::fill (lastDelayEffectOutput.begin(), lastDelayEffectOutput.end(), 0.0f);
  1019. }
  1020. template <typename Context>
  1021. void process (Context& context)
  1022. {
  1023. if (context.isBypassed)
  1024. return;
  1025. const auto& inputBlock = context.getInputBlock();
  1026. const auto& outputBlock = context.getOutputBlock();
  1027. const auto numSamples = inputBlock.getNumSamples();
  1028. const auto numChannels = inputBlock.getNumChannels();
  1029. mixer.pushDrySamples (inputBlock);
  1030. for (size_t channel = 0; channel < numChannels; ++channel)
  1031. {
  1032. auto* samplesIn = inputBlock .getChannelPointer (channel);
  1033. auto* samplesOut = outputBlock.getChannelPointer (channel);
  1034. for (size_t i = 0; i < numSamples; ++i)
  1035. {
  1036. auto input = samplesIn[i] - lastDelayEffectOutput[channel];
  1037. auto delay = smoothFilter.processSample (int (channel), delayEffectValue[channel]);
  1038. const auto output = [&]
  1039. {
  1040. switch (delayEffectType)
  1041. {
  1042. case 0:
  1043. noInterpolation.pushSample (int (channel), input);
  1044. noInterpolation.setDelay ((float) delay);
  1045. return noInterpolation.popSample (int (channel));
  1046. case 1:
  1047. linear.pushSample (int (channel), input);
  1048. linear.setDelay ((float) delay);
  1049. return linear.popSample (int (channel));
  1050. case 2:
  1051. lagrange.pushSample (int (channel), input);
  1052. lagrange.setDelay ((float) delay);
  1053. return lagrange.popSample (int (channel));
  1054. case 3:
  1055. thiran.pushSample (int (channel), input);
  1056. thiran.setDelay ((float) delay);
  1057. return thiran.popSample (int (channel));
  1058. }
  1059. jassertfalse;
  1060. return 0.0f;
  1061. }();
  1062. const auto processed = lowpass.processSample (int (channel), output);
  1063. samplesOut[i] = processed;
  1064. lastDelayEffectOutput[channel] = processed * delayFeedbackVolume[channel].getNextValue();
  1065. }
  1066. }
  1067. mixer.mixWetSamples (outputBlock);
  1068. }
  1069. static constexpr auto effectDelaySamples = 192000;
  1070. dsp::DelayLine<float, dsp::DelayLineInterpolationTypes::None> noInterpolation { effectDelaySamples };
  1071. dsp::DelayLine<float, dsp::DelayLineInterpolationTypes::Linear> linear { effectDelaySamples };
  1072. dsp::DelayLine<float, dsp::DelayLineInterpolationTypes::Lagrange3rd> lagrange { effectDelaySamples };
  1073. dsp::DelayLine<float, dsp::DelayLineInterpolationTypes::Thiran> thiran { effectDelaySamples };
  1074. // Double precision to avoid some approximation issues
  1075. dsp::FirstOrderTPTFilter<double> smoothFilter;
  1076. std::array<double, 2> delayEffectValue;
  1077. std::array<LinearSmoothedValue<float>, 2> delayFeedbackVolume;
  1078. dsp::FirstOrderTPTFilter<float> lowpass;
  1079. dsp::DryWetMixer<float> mixer;
  1080. std::array<float, 2> lastDelayEffectOutput;
  1081. int delayEffectType = 1;
  1082. };
  1083. using Chain = dsp::ProcessorChain<dsp::NoiseGate<float>,
  1084. dsp::Gain<float>,
  1085. DirectDelayProcessor,
  1086. MultiBandProcessor,
  1087. dsp::Compressor<float>,
  1088. dsp::Phaser<float>,
  1089. dsp::Chorus<float>,
  1090. DistortionProcessor,
  1091. dsp::LadderFilter<float>,
  1092. DelayEffectProcessor,
  1093. dsp::Limiter<float>,
  1094. dsp::Gain<float>,
  1095. dsp::Panner<float>>;
  1096. Chain chain;
  1097. // We use this enum to index into the chain above
  1098. enum ProcessorIndices
  1099. {
  1100. noiseGateIndex,
  1101. inputGainIndex,
  1102. directDelayIndex,
  1103. multiBandIndex,
  1104. compressorIndex,
  1105. phaserIndex,
  1106. chorusIndex,
  1107. distortionIndex,
  1108. ladderIndex,
  1109. delayEffectIndex,
  1110. limiterIndex,
  1111. outputGainIndex,
  1112. pannerIndex
  1113. };
  1114. //==============================================================================
  1115. std::atomic<bool> requiresUpdate { true };
  1116. //==============================================================================
  1117. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DspModulePluginDemo)
  1118. };
  1119. //==============================================================================
  1120. class DspModulePluginDemoEditor : public AudioProcessorEditor
  1121. {
  1122. public:
  1123. explicit DspModulePluginDemoEditor (DspModulePluginDemo& p)
  1124. : AudioProcessorEditor (&p),
  1125. proc (p)
  1126. {
  1127. comboEffect.addSectionHeading ("Main");
  1128. comboEffect.addItem ("Distortion", TabDistortion);
  1129. comboEffect.addItem ("Multi-band", TabMultiBand);
  1130. comboEffect.addSectionHeading ("Dynamics");
  1131. comboEffect.addItem ("Compressor", TabCompressor);
  1132. comboEffect.addItem ("Noise gate", TabNoiseGate);
  1133. comboEffect.addItem ("Limiter", TabLimiter);
  1134. comboEffect.addSectionHeading ("Delay");
  1135. comboEffect.addItem ("Delay line direct", TabDelayLineDirect);
  1136. comboEffect.addItem ("Delay line effect", TabDelayLineEffect);
  1137. comboEffect.addSectionHeading ("Others");
  1138. comboEffect.addItem ("Phaser", TabPhaser);
  1139. comboEffect.addItem ("Chorus", TabChorus);
  1140. comboEffect.addItem ("Ladder filter", TabLadder);
  1141. comboEffect.setSelectedId (proc.indexTab + 1, dontSendNotification);
  1142. comboEffect.onChange = [this]
  1143. {
  1144. proc.indexTab = comboEffect.getSelectedId() - 1;
  1145. updateVisibility();
  1146. };
  1147. addAllAndMakeVisible (*this,
  1148. comboEffect,
  1149. labelEffect,
  1150. basicControls,
  1151. distortionControls,
  1152. multibandControls,
  1153. compressorControls,
  1154. noiseGateControls,
  1155. limiterControls,
  1156. directDelayControls,
  1157. delayEffectControls,
  1158. phaserControls,
  1159. chorusControls,
  1160. ladderControls);
  1161. labelEffect.setJustificationType (Justification::centredRight);
  1162. labelEffect.attachToComponent (&comboEffect, true);
  1163. updateVisibility();
  1164. setSize (800, 430);
  1165. }
  1166. //==============================================================================
  1167. void paint (Graphics& g) override
  1168. {
  1169. auto rect = getLocalBounds();
  1170. auto rectTop = rect.removeFromTop (topSize);
  1171. auto rectBottom = rect.removeFromBottom (bottomSize);
  1172. auto rectEffects = rect.removeFromBottom (tabSize);
  1173. auto rectChoice = rect.removeFromBottom (midSize);
  1174. g.setColour (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
  1175. g.fillRect (rect);
  1176. g.setColour (getLookAndFeel().findColour (ResizableWindow::backgroundColourId).brighter (0.2f));
  1177. g.fillRect (rectEffects);
  1178. g.setColour (getLookAndFeel().findColour (ResizableWindow::backgroundColourId).darker (0.2f));
  1179. g.fillRect (rectTop);
  1180. g.fillRect (rectBottom);
  1181. g.fillRect (rectChoice);
  1182. g.setColour (Colours::white);
  1183. g.setFont (Font (20.0f).italicised().withExtraKerningFactor (0.1f));
  1184. g.drawFittedText ("DSP MODULE DEMO", rectTop.reduced (10, 0), Justification::centredLeft, 1);
  1185. }
  1186. void resized() override
  1187. {
  1188. auto rect = getLocalBounds();
  1189. rect.removeFromTop (topSize);
  1190. rect.removeFromBottom (bottomSize);
  1191. auto rectEffects = rect.removeFromBottom (tabSize);
  1192. auto rectChoice = rect.removeFromBottom (midSize);
  1193. comboEffect.setBounds (rectChoice.withSizeKeepingCentre (200, 24));
  1194. rect.reduce (80, 0);
  1195. rectEffects.reduce (20, 0);
  1196. basicControls.setBounds (rect);
  1197. forEach ([&] (Component& comp) { comp.setBounds (rectEffects); },
  1198. distortionControls,
  1199. multibandControls,
  1200. compressorControls,
  1201. noiseGateControls,
  1202. limiterControls,
  1203. directDelayControls,
  1204. delayEffectControls,
  1205. phaserControls,
  1206. chorusControls,
  1207. ladderControls);
  1208. }
  1209. private:
  1210. class AttachedSlider : public Component
  1211. {
  1212. public:
  1213. AttachedSlider (AudioProcessorValueTreeState& state, StringRef strID)
  1214. : label ("", state.getParameter (strID)->name),
  1215. attachment (state, strID, slider)
  1216. {
  1217. addAllAndMakeVisible (*this, slider, label);
  1218. slider.setTextValueSuffix (" " + state.getParameter (strID)->label);
  1219. label.attachToComponent (&slider, false);
  1220. label.setJustificationType (Justification::centred);
  1221. }
  1222. void resized() override { slider.setBounds (getLocalBounds().reduced (0, 40)); }
  1223. private:
  1224. Slider slider { Slider::RotaryVerticalDrag, Slider::TextBoxBelow };
  1225. Label label;
  1226. AudioProcessorValueTreeState::SliderAttachment attachment;
  1227. };
  1228. class AttachedToggle : public Component
  1229. {
  1230. public:
  1231. AttachedToggle (AudioProcessorValueTreeState& state, StringRef strID)
  1232. : toggle (state.getParameter (strID)->name),
  1233. attachment (state, strID, toggle)
  1234. {
  1235. addAndMakeVisible (toggle);
  1236. }
  1237. void resized() override { toggle.setBounds (getLocalBounds()); }
  1238. private:
  1239. ToggleButton toggle;
  1240. AudioProcessorValueTreeState::ButtonAttachment attachment;
  1241. };
  1242. class AttachedCombo : public Component
  1243. {
  1244. public:
  1245. AttachedCombo (AudioProcessorValueTreeState& state, StringRef strID)
  1246. : combo (state, strID),
  1247. label ("", state.getParameter (strID)->name),
  1248. attachment (state, strID, combo)
  1249. {
  1250. addAllAndMakeVisible (*this, combo, label);
  1251. label.attachToComponent (&combo, false);
  1252. label.setJustificationType (Justification::centred);
  1253. }
  1254. void resized() override
  1255. {
  1256. combo.setBounds (getLocalBounds().withSizeKeepingCentre (jmin (getWidth(), 150), 24));
  1257. }
  1258. private:
  1259. struct ComboWithItems : public ComboBox
  1260. {
  1261. ComboWithItems (AudioProcessorValueTreeState& state, StringRef strID)
  1262. {
  1263. // Adding the list here in the constructor means that the combo
  1264. // is already populated when we construct the attachment below
  1265. addItemList (dynamic_cast<AudioParameterChoice*> (state.getParameter (strID))->choices, 1);
  1266. }
  1267. };
  1268. ComboWithItems combo;
  1269. Label label;
  1270. AudioProcessorValueTreeState::ComboBoxAttachment attachment;
  1271. };
  1272. //==============================================================================
  1273. void updateVisibility()
  1274. {
  1275. const auto indexEffect = comboEffect.getSelectedId();
  1276. const auto op = [&] (const std::tuple<Component&, int>& tup)
  1277. {
  1278. Component& comp = std::get<0> (tup);
  1279. const int tabIndex = std::get<1> (tup);
  1280. comp.setVisible (tabIndex == indexEffect);
  1281. };
  1282. forEach (op,
  1283. std::forward_as_tuple (distortionControls, TabDistortion),
  1284. std::forward_as_tuple (multibandControls, TabMultiBand),
  1285. std::forward_as_tuple (compressorControls, TabCompressor),
  1286. std::forward_as_tuple (noiseGateControls, TabNoiseGate),
  1287. std::forward_as_tuple (limiterControls, TabLimiter),
  1288. std::forward_as_tuple (directDelayControls, TabDelayLineDirect),
  1289. std::forward_as_tuple (delayEffectControls, TabDelayLineEffect),
  1290. std::forward_as_tuple (phaserControls, TabPhaser),
  1291. std::forward_as_tuple (chorusControls, TabChorus),
  1292. std::forward_as_tuple (ladderControls, TabLadder));
  1293. }
  1294. enum EffectsTabs
  1295. {
  1296. TabDistortion = 1,
  1297. TabMultiBand,
  1298. TabCompressor,
  1299. TabNoiseGate,
  1300. TabLimiter,
  1301. TabDelayLineDirect,
  1302. TabDelayLineEffect,
  1303. TabPhaser,
  1304. TabChorus,
  1305. TabLadder
  1306. };
  1307. //==============================================================================
  1308. ComboBox comboEffect;
  1309. Label labelEffect { "Audio effect: " };
  1310. struct GetTrackInfo
  1311. {
  1312. // Combo boxes need a lot of room
  1313. Grid::TrackInfo operator() (AttachedCombo&) const { return 120_px; }
  1314. // Toggles are a bit smaller
  1315. Grid::TrackInfo operator() (AttachedToggle&) const { return 80_px; }
  1316. // Sliders take up as much room as they can
  1317. Grid::TrackInfo operator() (AttachedSlider&) const { return 1_fr; }
  1318. };
  1319. template <typename... Components>
  1320. static void performLayout (const Rectangle<int>& bounds, Components&... components)
  1321. {
  1322. Grid grid;
  1323. using Track = Grid::TrackInfo;
  1324. grid.autoColumns = Track (1_fr);
  1325. grid.autoRows = Track (1_fr);
  1326. grid.columnGap = Grid::Px (10);
  1327. grid.rowGap = Grid::Px (0);
  1328. grid.autoFlow = Grid::AutoFlow::column;
  1329. grid.templateColumns = { GetTrackInfo{} (components)... };
  1330. grid.items = { GridItem (components)... };
  1331. grid.performLayout (bounds);
  1332. }
  1333. struct BasicControls : public Component
  1334. {
  1335. explicit BasicControls (AudioProcessorValueTreeState& state)
  1336. : pan (state, ID::pan),
  1337. input (state, ID::inputGain),
  1338. output (state, ID::outputGain)
  1339. {
  1340. addAllAndMakeVisible (*this, pan, input, output);
  1341. }
  1342. void resized() override
  1343. {
  1344. performLayout (getLocalBounds(), input, output, pan);
  1345. }
  1346. AttachedSlider pan, input, output;
  1347. };
  1348. struct DistortionControls : public Component
  1349. {
  1350. explicit DistortionControls (AudioProcessorValueTreeState& state)
  1351. : toggle (state, ID::distortionEnabled),
  1352. lowpass (state, ID::distortionLowpass),
  1353. highpass (state, ID::distortionHighpass),
  1354. mix (state, ID::distortionMix),
  1355. gain (state, ID::distortionInGain),
  1356. compv (state, ID::distortionCompGain),
  1357. type (state, ID::distortionType),
  1358. oversampling (state, ID::distortionOversampler)
  1359. {
  1360. addAllAndMakeVisible (*this, toggle, type, lowpass, highpass, mix, gain, compv, oversampling);
  1361. }
  1362. void resized() override
  1363. {
  1364. performLayout (getLocalBounds(), toggle, type, gain, highpass, lowpass, compv, mix, oversampling);
  1365. }
  1366. AttachedToggle toggle;
  1367. AttachedSlider lowpass, highpass, mix, gain, compv;
  1368. AttachedCombo type, oversampling;
  1369. };
  1370. struct MultiBandControls : public Component
  1371. {
  1372. explicit MultiBandControls (AudioProcessorValueTreeState& state)
  1373. : toggle (state, ID::multiBandEnabled),
  1374. low (state, ID::multiBandLowVolume),
  1375. high (state, ID::multiBandHighVolume),
  1376. lRFreq (state, ID::multiBandFreq)
  1377. {
  1378. addAllAndMakeVisible (*this, toggle, low, high, lRFreq);
  1379. }
  1380. void resized() override
  1381. {
  1382. performLayout (getLocalBounds(), toggle, lRFreq, low, high);
  1383. }
  1384. AttachedToggle toggle;
  1385. AttachedSlider low, high, lRFreq;
  1386. };
  1387. struct CompressorControls : public Component
  1388. {
  1389. explicit CompressorControls (AudioProcessorValueTreeState& state)
  1390. : toggle (state, ID::compressorEnabled),
  1391. threshold (state, ID::compressorThreshold),
  1392. ratio (state, ID::compressorRatio),
  1393. attack (state, ID::compressorAttack),
  1394. release (state, ID::compressorRelease)
  1395. {
  1396. addAllAndMakeVisible (*this, toggle, threshold, ratio, attack, release);
  1397. }
  1398. void resized() override
  1399. {
  1400. performLayout (getLocalBounds(), toggle, threshold, ratio, attack, release);
  1401. }
  1402. AttachedToggle toggle;
  1403. AttachedSlider threshold, ratio, attack, release;
  1404. };
  1405. struct NoiseGateControls : public Component
  1406. {
  1407. explicit NoiseGateControls (AudioProcessorValueTreeState& state)
  1408. : toggle (state, ID::noiseGateEnabled),
  1409. threshold (state, ID::noiseGateThreshold),
  1410. ratio (state, ID::noiseGateRatio),
  1411. attack (state, ID::noiseGateAttack),
  1412. release (state, ID::noiseGateRelease)
  1413. {
  1414. addAllAndMakeVisible (*this, toggle, threshold, ratio, attack, release);
  1415. }
  1416. void resized() override
  1417. {
  1418. performLayout (getLocalBounds(), toggle, threshold, ratio, attack, release);
  1419. }
  1420. AttachedToggle toggle;
  1421. AttachedSlider threshold, ratio, attack, release;
  1422. };
  1423. struct LimiterControls : public Component
  1424. {
  1425. explicit LimiterControls (AudioProcessorValueTreeState& state)
  1426. : toggle (state, ID::limiterEnabled),
  1427. threshold (state, ID::limiterThreshold),
  1428. release (state, ID::limiterRelease)
  1429. {
  1430. addAllAndMakeVisible (*this, toggle, threshold, release);
  1431. }
  1432. void resized() override
  1433. {
  1434. performLayout (getLocalBounds(), toggle, threshold, release);
  1435. }
  1436. AttachedToggle toggle;
  1437. AttachedSlider threshold, release;
  1438. };
  1439. struct DirectDelayControls : public Component
  1440. {
  1441. explicit DirectDelayControls (AudioProcessorValueTreeState& state)
  1442. : toggle (state, ID::directDelayEnabled),
  1443. type (state, ID::directDelayType),
  1444. delay (state, ID::directDelayValue),
  1445. smooth (state, ID::directDelaySmoothing),
  1446. mix (state, ID::directDelayMix)
  1447. {
  1448. addAllAndMakeVisible (*this, toggle, type, delay, smooth, mix);
  1449. }
  1450. void resized() override
  1451. {
  1452. performLayout (getLocalBounds(), toggle, type, delay, smooth, mix);
  1453. }
  1454. AttachedToggle toggle;
  1455. AttachedCombo type;
  1456. AttachedSlider delay, smooth, mix;
  1457. };
  1458. struct DelayEffectControls : public Component
  1459. {
  1460. explicit DelayEffectControls (AudioProcessorValueTreeState& state)
  1461. : toggle (state, ID::delayEffectEnabled),
  1462. type (state, ID::delayEffectType),
  1463. value (state, ID::delayEffectValue),
  1464. smooth (state, ID::delayEffectSmoothing),
  1465. lowpass (state, ID::delayEffectLowpass),
  1466. feedback (state, ID::delayEffectFeedback),
  1467. mix (state, ID::delayEffectMix)
  1468. {
  1469. addAllAndMakeVisible (*this, toggle, type, value, smooth, lowpass, feedback, mix);
  1470. }
  1471. void resized() override
  1472. {
  1473. performLayout (getLocalBounds(), toggle, type, value, smooth, lowpass, feedback, mix);
  1474. }
  1475. AttachedToggle toggle;
  1476. AttachedCombo type;
  1477. AttachedSlider value, smooth, lowpass, feedback, mix;
  1478. };
  1479. struct PhaserControls : public Component
  1480. {
  1481. explicit PhaserControls (AudioProcessorValueTreeState& state)
  1482. : toggle (state, ID::phaserEnabled),
  1483. rate (state, ID::phaserRate),
  1484. depth (state, ID::phaserDepth),
  1485. centre (state, ID::phaserCentreFrequency),
  1486. feedback (state, ID::phaserFeedback),
  1487. mix (state, ID::phaserMix)
  1488. {
  1489. addAllAndMakeVisible (*this, toggle, rate, depth, centre, feedback, mix);
  1490. }
  1491. void resized() override
  1492. {
  1493. performLayout (getLocalBounds(), toggle, rate, depth, centre, feedback, mix);
  1494. }
  1495. AttachedToggle toggle;
  1496. AttachedSlider rate, depth, centre, feedback, mix;
  1497. };
  1498. struct ChorusControls : public Component
  1499. {
  1500. explicit ChorusControls (AudioProcessorValueTreeState& state)
  1501. : toggle (state, ID::chorusEnabled),
  1502. rate (state, ID::chorusRate),
  1503. depth (state, ID::chorusDepth),
  1504. centre (state, ID::chorusCentreDelay),
  1505. feedback (state, ID::chorusFeedback),
  1506. mix (state, ID::chorusMix)
  1507. {
  1508. addAllAndMakeVisible (*this, toggle, rate, depth, centre, feedback, mix);
  1509. }
  1510. void resized() override
  1511. {
  1512. performLayout (getLocalBounds(), toggle, rate, depth, centre, feedback, mix);
  1513. }
  1514. AttachedToggle toggle;
  1515. AttachedSlider rate, depth, centre, feedback, mix;
  1516. };
  1517. struct LadderControls : public Component
  1518. {
  1519. explicit LadderControls (AudioProcessorValueTreeState& state)
  1520. : toggle (state, ID::ladderEnabled),
  1521. mode (state, ID::ladderMode),
  1522. freq (state, ID::ladderCutoff),
  1523. resonance (state, ID::ladderResonance),
  1524. drive (state, ID::ladderDrive)
  1525. {
  1526. addAllAndMakeVisible (*this, toggle, mode, freq, resonance, drive);
  1527. }
  1528. void resized() override
  1529. {
  1530. performLayout (getLocalBounds(), toggle, mode, freq, resonance, drive);
  1531. }
  1532. AttachedToggle toggle;
  1533. AttachedCombo mode;
  1534. AttachedSlider freq, resonance, drive;
  1535. };
  1536. //==============================================================================
  1537. static constexpr auto topSize = 40,
  1538. bottomSize = 40,
  1539. midSize = 40,
  1540. tabSize = 155;
  1541. //==============================================================================
  1542. DspModulePluginDemo& proc;
  1543. BasicControls basicControls { proc.apvts };
  1544. DistortionControls distortionControls { proc.apvts };
  1545. MultiBandControls multibandControls { proc.apvts };
  1546. CompressorControls compressorControls { proc.apvts };
  1547. NoiseGateControls noiseGateControls { proc.apvts };
  1548. LimiterControls limiterControls { proc.apvts };
  1549. DirectDelayControls directDelayControls { proc.apvts };
  1550. DelayEffectControls delayEffectControls { proc.apvts };
  1551. PhaserControls phaserControls { proc.apvts };
  1552. ChorusControls chorusControls { proc.apvts };
  1553. LadderControls ladderControls { proc.apvts };
  1554. //==============================================================================
  1555. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DspModulePluginDemoEditor)
  1556. };
  1557. struct DspModulePluginDemoAudioProcessor : public DspModulePluginDemo
  1558. {
  1559. AudioProcessorEditor* createEditor() override
  1560. {
  1561. return new DspModulePluginDemoEditor (*this);
  1562. }
  1563. bool hasEditor() const override { return true; }
  1564. };