|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- /*
- * DISTRHO MVerb, a DPF'ied MVerb.
- * Copyright (c) 2010 Martin Eastwood
- * Copyright (C) 2014 Filipe Coelho <falktx@falktx.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 3 of
- * the License, or any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * For a full copy of the GNU General Public License see the LICENSE file.
- */
-
- #include "DistrhoPluginMVerb.hpp"
-
- START_NAMESPACE_DISTRHO
-
- // -----------------------------------------------------------------------
-
- DistrhoPluginMVerb::DistrhoPluginMVerb()
- : Plugin(MVerb<float>::NUM_PARAMS, 5, 0) // 5 program, 0 states
- {
- fVerb.setSampleRate(d_getSampleRate());
-
- // set initial values
- d_setProgram(0);
- }
-
- // -----------------------------------------------------------------------
- // Init
-
- void DistrhoPluginMVerb::d_initParameter(uint32_t index, Parameter& parameter)
- {
- parameter.unit = "%";
- parameter.ranges.min = 0.0f;
- parameter.ranges.max = 100.0f;
-
- // default values taken from 1st preset
- switch (index)
- {
- case MVerb<float>::DAMPINGFREQ:
- parameter.hints = kParameterIsAutomable;
- parameter.name = "Damping";
- parameter.symbol = "damping";
- parameter.ranges.def = 0.5f * 100.0f;
- break;
- case MVerb<float>::DENSITY:
- parameter.hints = kParameterIsAutomable;
- parameter.name = "Density";
- parameter.symbol = "density";
- parameter.ranges.def = 0.5f * 100.0f;
- break;
- case MVerb<float>::BANDWIDTHFREQ:
- parameter.hints = kParameterIsAutomable;
- parameter.name = "Bandwidth";
- parameter.symbol = "bandwidth";
- parameter.ranges.def = 0.5f * 100.0f;
- break;
- case MVerb<float>::DECAY:
- parameter.hints = kParameterIsAutomable;
- parameter.name = "Decay";
- parameter.symbol = "decay";
- parameter.ranges.def = 0.5f * 100.0f;
- break;
- case MVerb<float>::PREDELAY:
- parameter.hints = kParameterIsAutomable;
- parameter.name = "Predelay";
- parameter.symbol = "predelay";
- parameter.ranges.def = 0.5f * 100.0f;
- break;
- case MVerb<float>::SIZE:
- parameter.hints = kParameterIsAutomable;
- parameter.name = "Size";
- parameter.symbol = "size";
- parameter.ranges.def = 0.75f * 100.0f;
- parameter.ranges.min = 0.05f * 100.0f;
- break;
- case MVerb<float>::GAIN:
- parameter.hints = kParameterIsAutomable;
- parameter.name = "Gain";
- parameter.symbol = "gain";
- parameter.ranges.def = 1.0f * 100.0f;
- break;
- case MVerb<float>::MIX:
- parameter.hints = kParameterIsAutomable;
- parameter.name = "Mix";
- parameter.symbol = "mix";
- parameter.ranges.def = 0.5f * 100.0f;
- break;
- case MVerb<float>::EARLYMIX:
- parameter.hints = kParameterIsAutomable;
- parameter.name = "Early/Late Mix";
- parameter.symbol = "earlymix";
- parameter.ranges.def = 0.5f * 100.0f;
- break;
- }
- }
-
- void DistrhoPluginMVerb::d_initProgramName(uint32_t index, d_string& programName)
- {
- switch(index)
- {
- case 0:
- programName = "Halves";
- break;
- case 1:
- programName = "Dark";
- break;
- case 2:
- programName = "Cupboard";
- break;
- case 3:
- programName = "Stadium";
- break;
- case 4:
- programName = "Subtle";
- break;
- }
- }
-
- // -----------------------------------------------------------------------
- // Internal data
-
- float DistrhoPluginMVerb::d_getParameterValue(uint32_t index) const
- {
- return fVerb.getParameter(static_cast<int>(index)) * 100.0f;
- }
-
- void DistrhoPluginMVerb::d_setParameterValue(uint32_t index, float value)
- {
- fVerb.setParameter(static_cast<int>(index), value / 100.0f);
- }
-
- void DistrhoPluginMVerb::d_setProgram(uint32_t index)
- {
- // NOTE: DAMPINGFREQ is reversed
-
- switch(index)
- {
- case 0:
- fVerb.setParameter(MVerb<float>::DAMPINGFREQ, 0.5f);
- fVerb.setParameter(MVerb<float>::DENSITY, 0.5f);
- fVerb.setParameter(MVerb<float>::BANDWIDTHFREQ, 0.5f);
- fVerb.setParameter(MVerb<float>::DECAY, 0.5f);
- fVerb.setParameter(MVerb<float>::PREDELAY, 0.5f);
- fVerb.setParameter(MVerb<float>::SIZE, 0.75f);
- fVerb.setParameter(MVerb<float>::GAIN, 1.0f);
- fVerb.setParameter(MVerb<float>::MIX, 0.5f);
- fVerb.setParameter(MVerb<float>::EARLYMIX, 0.5f);
- break;
- case 1:
- fVerb.setParameter(MVerb<float>::DAMPINGFREQ, 0.1f);
- fVerb.setParameter(MVerb<float>::DENSITY, 0.5f);
- fVerb.setParameter(MVerb<float>::BANDWIDTHFREQ, 0.1f);
- fVerb.setParameter(MVerb<float>::DECAY, 0.5f);
- fVerb.setParameter(MVerb<float>::PREDELAY, 0.0f);
- fVerb.setParameter(MVerb<float>::SIZE, 0.5f);
- fVerb.setParameter(MVerb<float>::GAIN, 1.0f);
- fVerb.setParameter(MVerb<float>::MIX, 0.5f);
- fVerb.setParameter(MVerb<float>::EARLYMIX, 0.75f);
- break;
- case 2:
- fVerb.setParameter(MVerb<float>::DAMPINGFREQ, 1.0f);
- fVerb.setParameter(MVerb<float>::DENSITY, 0.5f);
- fVerb.setParameter(MVerb<float>::BANDWIDTHFREQ, 1.0f);
- fVerb.setParameter(MVerb<float>::DECAY, 0.5f);
- fVerb.setParameter(MVerb<float>::PREDELAY, 0.0f);
- fVerb.setParameter(MVerb<float>::SIZE, 0.25f);
- fVerb.setParameter(MVerb<float>::GAIN, 1.0f);
- fVerb.setParameter(MVerb<float>::MIX, 0.35f);
- fVerb.setParameter(MVerb<float>::EARLYMIX, 0.75f);
- break;
- case 3:
- fVerb.setParameter(MVerb<float>::DAMPINGFREQ, 1.0f);
- fVerb.setParameter(MVerb<float>::DENSITY, 0.5f);
- fVerb.setParameter(MVerb<float>::BANDWIDTHFREQ, 1.0f);
- fVerb.setParameter(MVerb<float>::DECAY, 0.5f);
- fVerb.setParameter(MVerb<float>::PREDELAY, 0.0f);
- fVerb.setParameter(MVerb<float>::SIZE, 1.0f);
- fVerb.setParameter(MVerb<float>::GAIN, 1.0f);
- fVerb.setParameter(MVerb<float>::MIX, 0.35f);
- fVerb.setParameter(MVerb<float>::EARLYMIX, 0.75f);
- break;
- case 4:
- fVerb.setParameter(MVerb<float>::DAMPINGFREQ, 1.0f);
- fVerb.setParameter(MVerb<float>::DENSITY, 0.5f);
- fVerb.setParameter(MVerb<float>::BANDWIDTHFREQ, 1.0f);
- fVerb.setParameter(MVerb<float>::DECAY, 0.5f);
- fVerb.setParameter(MVerb<float>::PREDELAY, 0.0f);
- fVerb.setParameter(MVerb<float>::SIZE, 0.5f);
- fVerb.setParameter(MVerb<float>::GAIN, 1.0f);
- fVerb.setParameter(MVerb<float>::MIX, 0.15f);
- fVerb.setParameter(MVerb<float>::EARLYMIX, 0.75f);
- break;
- }
-
- fVerb.reset();
- }
-
- // -----------------------------------------------------------------------
- // Process
-
- void DistrhoPluginMVerb::d_activate()
- {
- fVerb.reset();
- }
-
- void DistrhoPluginMVerb::d_run(const float** inputs, float** outputs, uint32_t frames)
- {
- fVerb.process(inputs, outputs, static_cast<int>(frames));
- }
-
- // -----------------------------------------------------------------------
- // Callbacks
-
- void DistrhoPluginMVerb::d_sampleRateChanged(double newSampleRate)
- {
- fVerb.setSampleRate(newSampleRate);
- }
-
- // -----------------------------------------------------------------------
-
- Plugin* createPlugin()
- {
- return new DistrhoPluginMVerb();
- }
-
- // -----------------------------------------------------------------------
-
- END_NAMESPACE_DISTRHO
|