From 0fbc990f0de6264904bbf0fa88a65dc1151c842b Mon Sep 17 00:00:00 2001 From: falkTX Date: Tue, 13 Aug 2013 01:46:44 +0100 Subject: [PATCH] Update vex based plugin code, add remaning fx --- source/backend/native/vex.cpp | 478 ++++++++++++++++++++-- source/backend/native/vex/PeggySettings.h | 1 - source/backend/native/vex/cArpSettings.h | 1 + source/backend/native/vex/cChorus.h | 1 + source/backend/native/vex/cDelay.h | 1 + source/backend/native/vex/cReverb.h | 1 + 6 files changed, 446 insertions(+), 37 deletions(-) delete mode 120000 source/backend/native/vex/PeggySettings.h create mode 120000 source/backend/native/vex/cArpSettings.h create mode 120000 source/backend/native/vex/cChorus.h create mode 120000 source/backend/native/vex/cDelay.h create mode 120000 source/backend/native/vex/cReverb.h diff --git a/source/backend/native/vex.cpp b/source/backend/native/vex.cpp index cac1b8714..c8a2562b0 100644 --- a/source/backend/native/vex.cpp +++ b/source/backend/native/vex.cpp @@ -20,12 +20,18 @@ using namespace juce; #include "vex/cArp.h" +#include "vex/cChorus.h" +#include "vex/cDelay.h" +#include "vex/cReverb.h" + +// ----------------------------------------------------------------------- class VexArpPlugin : public PluginDescriptorClass { public: enum Params { - kParamLength = 0, + kParamOnOff = 0, + kParamLength, kParamTimeMode, kParamSyncMode, kParamFailMode, @@ -35,29 +41,24 @@ public: VexArpPlugin(const HostDescriptor* const host) : PluginDescriptorClass(host), - settings(), - arp(&settings), - fWetOnly(false) + fSettings(), + fArp(&fSettings) { - arp.setSampleRate(getSampleRate()); - inMidiBuffer.ensureSize(512*4); - for (int i=0; i < 8; ++i) - settings.grid[i*10] = true; + fSettings.grid[i*10] = true; - settings.grid[1] = true; - settings.grid[2] = true; - settings.grid[3] = true; + fSettings.grid[1] = true; + fSettings.grid[2] = true; + fSettings.grid[3] = true; - settings.grid[41] = true; - settings.grid[42] = true; - settings.grid[43] = true; - settings.grid[44] = true; - settings.grid[45] = true; - } + fSettings.grid[41] = true; + fSettings.grid[42] = true; + fSettings.grid[43] = true; + fSettings.grid[44] = true; + fSettings.grid[45] = true; - ~VexArpPlugin() override - { + fArp.setSampleRate(getSampleRate()); + fMidiInBuffer.ensureSize(512*4); } protected: @@ -89,6 +90,13 @@ protected: switch (index) { + case kParamOnOff: + hints |= PARAMETER_IS_BOOLEAN; + paramInfo.name = "On/Off"; + paramInfo.ranges.def = 0.0f; + paramInfo.ranges.min = 0.0f; + paramInfo.ranges.max = 1.0f; + break; case kParamLength: paramInfo.name = "Length"; paramInfo.ranges.def = 8.0f; @@ -164,16 +172,18 @@ protected: { switch (index) { + case kParamOnOff: + return fSettings.on ? 1.0f : 0.0f; case kParamLength: - return settings.length; + return fSettings.length; case kParamTimeMode: - return settings.timeMode; + return fSettings.timeMode; case kParamSyncMode: - return settings.syncMode; + return fSettings.syncMode; case kParamFailMode: - return settings.failMode; + return fSettings.failMode; case kParamVelMode: - return settings.velMode; + return fSettings.velMode; default: return 0.0f; } @@ -186,20 +196,23 @@ protected: { switch (index) { + case kParamOnOff: + fSettings.on = (value > 0.5f); + break; case kParamLength: - settings.length = value; + fSettings.length = value; break; case kParamTimeMode: - settings.timeMode = value; + fSettings.timeMode = value; break; case kParamSyncMode: - settings.syncMode = value; + fSettings.syncMode = value; break; case kParamFailMode: - settings.failMode = value; + fSettings.failMode = value; break; case kParamVelMode: - settings.velMode = value; + fSettings.velMode = value; break; } } @@ -209,6 +222,14 @@ protected: void process(float**, float**, const uint32_t frames, const uint32_t midiEventCount, const MidiEvent* const midiEvents) override { + if (! fSettings.on) + { + for (uint32_t i=0; i < midiEventCount; ++i) + writeMidiEvent(&midiEvents[i]); + + return; + } + const TimeInfo* const timeInfo(getTimeInfo()); double ppqPos, barStartPos, bpm; @@ -229,15 +250,15 @@ protected: bpm = 120.0; } - inMidiBuffer.clear(); + fMidiInBuffer.clear(); for (uint32_t i=0; i < midiEventCount; ++i) { const MidiEvent* const midiEvent(&midiEvents[i]); - inMidiBuffer.addEvent(MidiMessage(midiEvent->data, midiEvent->size, midiEvent->time), 0/*timeInfo->frame*/); + fMidiInBuffer.addEvent(MidiMessage(midiEvent->data, midiEvent->size, midiEvent->time), timeInfo->frame); } - const MidiBuffer& outMidiBuffer(arp.processMidi(inMidiBuffer, timeInfo->playing, ppqPos, barStartPos, bpm, frames)); + const MidiBuffer& outMidiBuffer(fArp.processMidi(fMidiInBuffer, timeInfo->playing, ppqPos, barStartPos, bpm, frames)); MidiBuffer::Iterator outBufferIterator(outMidiBuffer); MidiMessage midiMessage(0xf4); @@ -260,10 +281,9 @@ protected: } private: - PeggySettings settings; - cArp arp; - MidiBuffer inMidiBuffer; - bool fWetOnly; + VexArpSettings fSettings; + VexArp fArp; + MidiBuffer fMidiInBuffer; PluginDescriptorClassEND(VexArpPlugin) CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(VexArpPlugin) @@ -271,6 +291,332 @@ private: // ----------------------------------------------------------------------- +class VexChorusPlugin : public PluginDescriptorClass +{ +public: + enum Params { + kParamDepth = 0, + kParamRate, + kParamCount + }; + + VexChorusPlugin(const HostDescriptor* const host) + : PluginDescriptorClass(host), + chorus(parameters) + { + parameters[0] = 0.6f; + parameters[1] = 0.3f; + + chorus.setSampleRate(getSampleRate()); + } + +protected: + // ------------------------------------------------------------------- + // Plugin parameter calls + + uint32_t getParameterCount() override + { + return kParamCount; + } + + const Parameter* getParameterInfo(const uint32_t index) override + { + static Parameter paramInfo; + + int hints = PARAMETER_IS_ENABLED|PARAMETER_IS_AUTOMABLE; + + paramInfo.name = nullptr; + paramInfo.unit = nullptr; + paramInfo.ranges.def = 0.0f; + paramInfo.ranges.min = 0.0f; + paramInfo.ranges.max = 1.0f; + paramInfo.ranges.step = 1.0f; + paramInfo.ranges.stepSmall = 1.0f; + paramInfo.ranges.stepLarge = 1.0f; + paramInfo.scalePointCount = 0; + paramInfo.scalePoints = nullptr; + + switch (index) + { + case kParamDepth: + paramInfo.name = "Depth"; + paramInfo.ranges.def = 0.6f; + paramInfo.ranges.min = 0.0f; + paramInfo.ranges.max = 1.0f; + break; + case kParamRate: + paramInfo.name = "Rate"; + paramInfo.ranges.def = 0.3f; + paramInfo.ranges.min = 0.0f; + paramInfo.ranges.max = 1.0f; + break; + } + + paramInfo.hints = static_cast(hints); + + return ¶mInfo; + } + + float getParameterValue(const uint32_t index) override + { + if (index < kParamCount) + return parameters[index]; + return 0.0f; + } + + // ------------------------------------------------------------------- + // Plugin state calls + + void setParameterValue(const uint32_t index, const float value) + { + if (index < kParamCount) + parameters[index] = value; + } + + // ------------------------------------------------------------------- + // Plugin process calls + + void process(float** const inBuffer, float** const outBuffer, const uint32_t frames, const uint32_t, const MidiEvent* const) override + { + if (inBuffer[0] != outBuffer[0]) + carla_copyFloat(outBuffer[0], inBuffer[0], frames); + if (inBuffer[1] != outBuffer[1]) + carla_copyFloat(outBuffer[1], inBuffer[1], frames); + + chorus.processBlock(outBuffer[0], outBuffer[1], frames); + } + +private: + VexChorus chorus; + float parameters[2]; + + PluginDescriptorClassEND(VexChorusPlugin) + CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(VexChorusPlugin) +}; + +// ----------------------------------------------------------------------- + +class VexDelayPlugin : public PluginDescriptorClass +{ +public: + enum Params { + kParamTime = 0, + kParamFeedback, + kParamCount + }; + + VexDelayPlugin(const HostDescriptor* const host) + : PluginDescriptorClass(host), + delay(parameters) + { + parameters[0] = 4.0f; + parameters[1] = 40.0f; + + delay.setSampleRate(getSampleRate()); + } + +protected: + // ------------------------------------------------------------------- + // Plugin parameter calls + + uint32_t getParameterCount() override + { + return kParamCount; + } + + const Parameter* getParameterInfo(const uint32_t index) override + { + static Parameter paramInfo; + + int hints = PARAMETER_IS_ENABLED|PARAMETER_IS_AUTOMABLE; + + paramInfo.name = nullptr; + paramInfo.unit = nullptr; + paramInfo.ranges.def = 0.0f; + paramInfo.ranges.min = 0.0f; + paramInfo.ranges.max = 1.0f; + paramInfo.ranges.step = 1.0f; + paramInfo.ranges.stepSmall = 1.0f; + paramInfo.ranges.stepLarge = 1.0f; + paramInfo.scalePointCount = 0; + paramInfo.scalePoints = nullptr; + + switch (index) + { + case kParamTime: + hints |= PARAMETER_IS_INTEGER; + paramInfo.name = "Time"; + paramInfo.ranges.def = 4.0f; + paramInfo.ranges.min = 0.0f; + paramInfo.ranges.max = 8.0f; + break; + case kParamFeedback: + paramInfo.name = "Feedback"; + paramInfo.unit = "%"; + paramInfo.ranges.def = 40.0f; + paramInfo.ranges.min = 0.0f; + paramInfo.ranges.max = 100.0f; + break; + } + + paramInfo.hints = static_cast(hints); + + return ¶mInfo; + } + + float getParameterValue(const uint32_t index) override + { + if (index < kParamCount) + return parameters[index]; + return 0.0f; + } + + // ------------------------------------------------------------------- + // Plugin state calls + + void setParameterValue(const uint32_t index, const float value) + { + if (index < kParamCount) + parameters[index] = value; + } + + // ------------------------------------------------------------------- + // Plugin process calls + + void process(float** const inBuffer, float** const outBuffer, const uint32_t frames, const uint32_t, const MidiEvent* const) override + { + if (inBuffer[0] != outBuffer[0]) + carla_copyFloat(outBuffer[0], inBuffer[0], frames); + if (inBuffer[1] != outBuffer[1]) + carla_copyFloat(outBuffer[1], inBuffer[1], frames); + + const TimeInfo* const timeInfo(getTimeInfo()); + const double bpm(timeInfo->bbt.valid ? timeInfo->bbt.beatsPerMinute : 120.0); + + delay.processBlock(outBuffer[0], outBuffer[1], frames, bpm); + } + +private: + VexDelay delay; + float parameters[2]; + + PluginDescriptorClassEND(VexDelayPlugin) + CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(VexDelayPlugin) +}; + +// ----------------------------------------------------------------------- + +class VexReverbPlugin : public PluginDescriptorClass +{ +public: + enum Params { + kParamSize = 0, + kParamWidth, + kParamDamp, + kParamCount + }; + + VexReverbPlugin(const HostDescriptor* const host) + : PluginDescriptorClass(host), + reverb(parameters) + { + parameters[0] = 0.6f; + parameters[1] = 0.7f; + parameters[2] = 0.6f; + } + +protected: + // ------------------------------------------------------------------- + // Plugin parameter calls + + uint32_t getParameterCount() override + { + return kParamCount; + } + + const Parameter* getParameterInfo(const uint32_t index) override + { + static Parameter paramInfo; + + int hints = PARAMETER_IS_ENABLED|PARAMETER_IS_AUTOMABLE; + + paramInfo.name = nullptr; + paramInfo.unit = nullptr; + paramInfo.ranges.def = 0.0f; + paramInfo.ranges.min = 0.0f; + paramInfo.ranges.max = 1.0f; + paramInfo.ranges.step = 1.0f; + paramInfo.ranges.stepSmall = 1.0f; + paramInfo.ranges.stepLarge = 1.0f; + paramInfo.scalePointCount = 0; + paramInfo.scalePoints = nullptr; + + switch (index) + { + case kParamSize: + paramInfo.name = "Size"; + paramInfo.ranges.def = 0.6f; + paramInfo.ranges.min = 0.0f; + paramInfo.ranges.max = 1.0f; + break; + case kParamWidth: + paramInfo.name = "Width"; + paramInfo.ranges.def = 0.7f; + paramInfo.ranges.min = 0.0f; + paramInfo.ranges.max = 1.0f; + break; + case kParamDamp: + paramInfo.name = "Damp"; + paramInfo.ranges.def = 0.6f; + paramInfo.ranges.min = 0.0f; + paramInfo.ranges.max = 1.0f; + break; + } + + paramInfo.hints = static_cast(hints); + + return ¶mInfo; + } + + float getParameterValue(const uint32_t index) override + { + if (index < kParamCount) + return parameters[index]; + return 0.0f; + } + + // ------------------------------------------------------------------- + // Plugin state calls + + void setParameterValue(const uint32_t index, const float value) + { + if (index < kParamCount) + parameters[index] = value; + } + + // ------------------------------------------------------------------- + // Plugin process calls + + void process(float** const inBuffer, float** const outBuffer, const uint32_t frames, const uint32_t, const MidiEvent* const) override + { + for (uint32_t i=0; i< frames; ++i) + outBuffer[0][i] = inBuffer[0][i]/2.0f; + for (uint32_t i=0; i< frames; ++i) + outBuffer[1][i] = inBuffer[1][i]/2.0f; + + reverb.processBlock(outBuffer[0], outBuffer[1], frames); + } + +private: + VexReverb reverb; + float parameters[3]; + + PluginDescriptorClassEND(VexReverbPlugin) + CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(VexReverbPlugin) +}; + +// ----------------------------------------------------------------------- + static const PluginDescriptor vexArpDesc = { /* category */ PLUGIN_CATEGORY_UTILITY, /* hints */ static_cast(0x0), @@ -288,12 +634,72 @@ static const PluginDescriptor vexArpDesc = { PluginDescriptorFILL(VexArpPlugin) }; +static const PluginDescriptor vexChorusDesc = { + /* category */ PLUGIN_CATEGORY_MODULATOR, + /* hints */ static_cast(PLUGIN_IS_RTSAFE), + /* supports */ static_cast(0x0), + /* audioIns */ 2, + /* audioOuts */ 2, + /* midiIns */ 0, + /* midiOuts */ 0, + /* paramIns */ VexChorusPlugin::kParamCount, + /* paramOuts */ 0, + /* name */ "Vex Chorus", + /* label */ "vexChorus", + /* maker */ "falkTX", + /* copyright */ "GNU GPL v2+", + PluginDescriptorFILL(VexChorusPlugin) +}; + +static const PluginDescriptor vexDelayDesc = { + /* category */ PLUGIN_CATEGORY_DELAY, + /* hints */ static_cast(PLUGIN_IS_RTSAFE), + /* supports */ static_cast(0x0), + /* audioIns */ 2, + /* audioOuts */ 2, + /* midiIns */ 0, + /* midiOuts */ 0, + /* paramIns */ VexDelayPlugin::kParamCount, + /* paramOuts */ 0, + /* name */ "Vex Delay", + /* label */ "vexDelay", + /* maker */ "falkTX", + /* copyright */ "GNU GPL v2+", + PluginDescriptorFILL(VexDelayPlugin) +}; + +static const PluginDescriptor vexReverbDesc = { + /* category */ PLUGIN_CATEGORY_DELAY, + /* hints */ static_cast(PLUGIN_IS_RTSAFE), + /* supports */ static_cast(0x0), + /* audioIns */ 2, + /* audioOuts */ 2, + /* midiIns */ 0, + /* midiOuts */ 0, + /* paramIns */ VexReverbPlugin::kParamCount, + /* paramOuts */ 0, + /* name */ "Vex Reverb", + /* label */ "vexReverb", + /* maker */ "falkTX", + /* copyright */ "GNU GPL v2+", + PluginDescriptorFILL(VexReverbPlugin) +}; + // ----------------------------------------------------------------------- CARLA_EXPORT void carla_register_native_plugin_vex() { carla_register_native_plugin(&vexArpDesc); + carla_register_native_plugin(&vexChorusDesc); + carla_register_native_plugin(&vexDelayDesc); + carla_register_native_plugin(&vexReverbDesc); } // ----------------------------------------------------------------------- + +#include "vex/freeverb/allpass.cpp" +#include "vex/freeverb/comb.cpp" +#include "vex/freeverb/revmodel.cpp" + +// ----------------------------------------------------------------------- diff --git a/source/backend/native/vex/PeggySettings.h b/source/backend/native/vex/PeggySettings.h deleted file mode 120000 index 467b020a5..000000000 --- a/source/backend/native/vex/PeggySettings.h +++ /dev/null @@ -1 +0,0 @@ -/home/falktx/Personal/FOSS/GIT/distrho/ports/vex/source/PeggySettings.h \ No newline at end of file diff --git a/source/backend/native/vex/cArpSettings.h b/source/backend/native/vex/cArpSettings.h new file mode 120000 index 000000000..a864004ce --- /dev/null +++ b/source/backend/native/vex/cArpSettings.h @@ -0,0 +1 @@ +/home/falktx/Personal/FOSS/GIT/distrho/ports/vex/source/synth/cArpSettings.h \ No newline at end of file diff --git a/source/backend/native/vex/cChorus.h b/source/backend/native/vex/cChorus.h new file mode 120000 index 000000000..8b4b4ff55 --- /dev/null +++ b/source/backend/native/vex/cChorus.h @@ -0,0 +1 @@ +/home/falktx/Personal/FOSS/GIT/distrho/ports/vex/source/synth/cChorus.h \ No newline at end of file diff --git a/source/backend/native/vex/cDelay.h b/source/backend/native/vex/cDelay.h new file mode 120000 index 000000000..efa7872e2 --- /dev/null +++ b/source/backend/native/vex/cDelay.h @@ -0,0 +1 @@ +/home/falktx/Personal/FOSS/GIT/distrho/ports/vex/source/synth/cDelay.h \ No newline at end of file diff --git a/source/backend/native/vex/cReverb.h b/source/backend/native/vex/cReverb.h new file mode 120000 index 000000000..e3de745e8 --- /dev/null +++ b/source/backend/native/vex/cReverb.h @@ -0,0 +1 @@ +/home/falktx/Personal/FOSS/GIT/distrho/ports/vex/source/synth/cReverb.h \ No newline at end of file