| @@ -17,6 +17,8 @@ | |||||
| #include "plugincontext.hpp" | #include "plugincontext.hpp" | ||||
| #define CARDINAL_AUDIO_IO_OFFSET 8 | |||||
| // ----------------------------------------------------------------------------------------------------------- | // ----------------------------------------------------------------------------------------------------------- | ||||
| USE_NAMESPACE_DISTRHO; | USE_NAMESPACE_DISTRHO; | ||||
| @@ -84,8 +86,8 @@ struct HostCV : Module { | |||||
| for (int i=0; i<5; ++i) | for (int i=0; i<5; ++i) | ||||
| { | { | ||||
| outputs[i].setVoltage(dataIns[i+2][dataFrame] - outputOffset); | |||||
| dataOuts[i+2][dataFrame] = inputs[i].getVoltage() + inputOffset; | |||||
| outputs[i].setVoltage(dataIns[i+CARDINAL_AUDIO_IO_OFFSET][dataFrame] - outputOffset); | |||||
| dataOuts[i+CARDINAL_AUDIO_IO_OFFSET][dataFrame] = inputs[i].getVoltage() + inputOffset; | |||||
| } | } | ||||
| inputOffset = params[BIPOLAR_INPUTS_6_10].getValue() > 0.1f ? 5.0f : 0.0f; | inputOffset = params[BIPOLAR_INPUTS_6_10].getValue() > 0.1f ? 5.0f : 0.0f; | ||||
| @@ -93,8 +95,8 @@ struct HostCV : Module { | |||||
| for (int i=5; i<10; ++i) | for (int i=5; i<10; ++i) | ||||
| { | { | ||||
| outputs[i].setVoltage(dataIns[i+2][dataFrame] - outputOffset); | |||||
| dataOuts[i+2][dataFrame] = inputs[i].getVoltage() + inputOffset; | |||||
| outputs[i].setVoltage(dataIns[i+CARDINAL_AUDIO_IO_OFFSET][dataFrame] - outputOffset); | |||||
| dataOuts[i+CARDINAL_AUDIO_IO_OFFSET][dataFrame] = inputs[i].getVoltage() + inputOffset; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -40,4 +40,7 @@ | |||||
| // #define DISTRHO_PLUGIN_LV2_CATEGORY "lv2:AnalyserPlugin" | // #define DISTRHO_PLUGIN_LV2_CATEGORY "lv2:AnalyserPlugin" | ||||
| // #define DISTRHO_PLUGIN_VST3_CATEGORIES "Fx|Analyzer" | // #define DISTRHO_PLUGIN_VST3_CATEGORIES "Fx|Analyzer" | ||||
| #define CARDINAL_NUM_AUDIO_INPUTS 8 | |||||
| #define CARDINAL_NUM_AUDIO_OUTPUTS 8 | |||||
| #endif // DISTRHO_PLUGIN_INFO_H_INCLUDED | #endif // DISTRHO_PLUGIN_INFO_H_INCLUDED | ||||
| @@ -40,4 +40,7 @@ | |||||
| // #define DISTRHO_PLUGIN_LV2_CATEGORY "lv2:AnalyserPlugin" | // #define DISTRHO_PLUGIN_LV2_CATEGORY "lv2:AnalyserPlugin" | ||||
| // #define DISTRHO_PLUGIN_VST3_CATEGORIES "Fx|Analyzer" | // #define DISTRHO_PLUGIN_VST3_CATEGORIES "Fx|Analyzer" | ||||
| #define CARDINAL_NUM_AUDIO_INPUTS DISTRHO_PLUGIN_NUM_INPUTS | |||||
| #define CARDINAL_NUM_AUDIO_OUTPUTS DISTRHO_PLUGIN_NUM_OUTPUTS | |||||
| #endif // DISTRHO_PLUGIN_INFO_H_INCLUDED | #endif // DISTRHO_PLUGIN_INFO_H_INCLUDED | ||||
| @@ -942,20 +942,18 @@ protected: | |||||
| if (fCurrentAudioDevice != nullptr) | if (fCurrentAudioDevice != nullptr) | ||||
| { | { | ||||
| #if DISTRHO_PLUGIN_NUM_INPUTS != 0 | |||||
| #if CARDINAL_NUM_AUDIO_INPUTS != 0 | |||||
| for (uint32_t i=0, j=0; i<frames; ++i) | for (uint32_t i=0, j=0; i<frames; ++i) | ||||
| { | |||||
| fAudioBufferIn[j++] = inputs[0][i]; | |||||
| fAudioBufferIn[j++] = inputs[1][i]; | |||||
| } | |||||
| fCurrentAudioDevice->processInput(fAudioBufferIn, 2, frames); | |||||
| for (uint32_t k=0; k<CARDINAL_NUM_AUDIO_INPUTS; ++k) | |||||
| fAudioBufferIn[j++] = inputs[k][i]; | |||||
| fCurrentAudioDevice->processInput(fAudioBufferIn, CARDINAL_NUM_AUDIO_INPUTS, frames); | |||||
| #else | #else | ||||
| std::memset(fAudioBufferIn, 0, sizeof(float)*frames); | std::memset(fAudioBufferIn, 0, sizeof(float)*frames); | ||||
| fCurrentAudioDevice->processInput(fAudioBufferIn, 1, frames); | fCurrentAudioDevice->processInput(fAudioBufferIn, 1, frames); | ||||
| #endif | #endif | ||||
| } | } | ||||
| #if DISTRHO_PLUGIN_NUM_OUTPUTS != 2 | |||||
| #if CARDINAL_NUM_AUDIO_OUTPUTS != 2 | |||||
| context->dataFrame = 0; | context->dataFrame = 0; | ||||
| context->dataIns = inputs; | context->dataIns = inputs; | ||||
| context->dataOuts = outputs; | context->dataOuts = outputs; | ||||
| @@ -965,19 +963,17 @@ protected: | |||||
| if (fCurrentAudioDevice != nullptr) | if (fCurrentAudioDevice != nullptr) | ||||
| { | { | ||||
| std::memset(fAudioBufferOut, 0, sizeof(float)*frames*2); | |||||
| fCurrentAudioDevice->processOutput(fAudioBufferOut, 2, frames); | |||||
| std::memset(fAudioBufferOut, 0, sizeof(float)*frames*CARDINAL_NUM_AUDIO_OUTPUTS); | |||||
| fCurrentAudioDevice->processOutput(fAudioBufferOut, CARDINAL_NUM_AUDIO_OUTPUTS, frames); | |||||
| for (uint32_t i=0, j=0; i<frames; ++i) | for (uint32_t i=0, j=0; i<frames; ++i) | ||||
| { | |||||
| outputs[0][i] = fAudioBufferOut[j++]; | |||||
| outputs[1][i] = fAudioBufferOut[j++]; | |||||
| } | |||||
| for (uint32_t k=0; k<CARDINAL_NUM_AUDIO_OUTPUTS; ++k) | |||||
| outputs[k][i] = fAudioBufferOut[j++]; | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| std::memset(outputs[0], 0, sizeof(float)*frames); | |||||
| std::memset(outputs[1], 0, sizeof(float)*frames); | |||||
| for (uint32_t k=0; k<CARDINAL_NUM_AUDIO_OUTPUTS; ++k) | |||||
| std::memset(outputs[k], 0, sizeof(float)*frames); | |||||
| } | } | ||||
| } | } | ||||
| @@ -39,4 +39,7 @@ | |||||
| #define DISTRHO_PLUGIN_WANT_STATE 1 | #define DISTRHO_PLUGIN_WANT_STATE 1 | ||||
| #define DISTRHO_PLUGIN_WANT_TIMEPOS 1 | #define DISTRHO_PLUGIN_WANT_TIMEPOS 1 | ||||
| #define CARDINAL_NUM_AUDIO_INPUTS DISTRHO_PLUGIN_NUM_INPUTS | |||||
| #define CARDINAL_NUM_AUDIO_OUTPUTS DISTRHO_PLUGIN_NUM_OUTPUTS | |||||
| #endif // DISTRHO_PLUGIN_INFO_H_INCLUDED | #endif // DISTRHO_PLUGIN_INFO_H_INCLUDED | ||||
| @@ -37,20 +37,12 @@ struct CardinalAudioDevice : rack::audio::Device | |||||
| int getNumInputs() override | int getNumInputs() override | ||||
| { | { | ||||
| #if DISTRHO_PLUGIN_NUM_INPUTS > 10 | |||||
| return DISTRHO_PLUGIN_NUM_INPUTS - 10; | |||||
| #else | |||||
| return std::min(2, DISTRHO_PLUGIN_NUM_INPUTS); | |||||
| #endif | |||||
| return CARDINAL_NUM_AUDIO_INPUTS; | |||||
| } | } | ||||
| int getNumOutputs() override | int getNumOutputs() override | ||||
| { | { | ||||
| #if DISTRHO_PLUGIN_NUM_OUTPUTS > 10 | |||||
| return DISTRHO_PLUGIN_NUM_OUTPUTS - 10; | |||||
| #else | |||||
| return std::min(2, DISTRHO_PLUGIN_NUM_OUTPUTS); | |||||
| #endif | |||||
| return CARDINAL_NUM_AUDIO_OUTPUTS; | |||||
| } | } | ||||
| int getBlockSize() override | int getBlockSize() override | ||||
| @@ -117,20 +109,12 @@ struct CardinalAudioDriver : rack::audio::Driver | |||||
| int getDeviceNumInputs(int) override | int getDeviceNumInputs(int) override | ||||
| { | { | ||||
| #if DISTRHO_PLUGIN_NUM_INPUTS > 10 | |||||
| return DISTRHO_PLUGIN_NUM_INPUTS - 10; | |||||
| #else | |||||
| return std::min(2, DISTRHO_PLUGIN_NUM_INPUTS); | |||||
| #endif | |||||
| return CARDINAL_NUM_AUDIO_INPUTS; | |||||
| } | } | ||||
| int getDeviceNumOutputs(int) override | int getDeviceNumOutputs(int) override | ||||
| { | { | ||||
| #if DISTRHO_PLUGIN_NUM_OUTPUTS > 10 | |||||
| return DISTRHO_PLUGIN_NUM_OUTPUTS - 10; | |||||
| #else | |||||
| return std::min(2, DISTRHO_PLUGIN_NUM_OUTPUTS); | |||||
| #endif | |||||
| return CARDINAL_NUM_AUDIO_OUTPUTS; | |||||
| } | } | ||||
| rack::audio::Device* subscribe(int, rack::audio::Port* const port) override | rack::audio::Device* subscribe(int, rack::audio::Port* const port) override | ||||