diff --git a/src/8vert.cpp b/src/8vert.cpp index 6925aff..bbd10fb 100644 --- a/src/8vert.cpp +++ b/src/8vert.cpp @@ -33,19 +33,20 @@ struct _8vert : Module { // Get input if (inputs[IN_INPUTS + i].isConnected()) { channels = inputs[IN_INPUTS + i].getChannels(); - inputs[IN_INPUTS + i].getVoltages(in); + inputs[IN_INPUTS + i].readVoltages(in); } if (outputs[OUT_OUTPUTS + i].isConnected()) { // Apply gain float out[16]; float gain = params[GAIN_PARAMS + i].getValue(); - for (int c = 0; c < channels; c++) + for (int c = 0; c < channels; c++) { out[c] = gain * in[c]; + } // Set output outputs[OUT_OUTPUTS + i].setChannels(channels); - outputs[OUT_OUTPUTS + i].setVoltages(out); + outputs[OUT_OUTPUTS + i].writeVoltages(out); } } } diff --git a/src/Mutes.cpp b/src/Mutes.cpp index 25a482a..07c2590 100644 --- a/src/Mutes.cpp +++ b/src/Mutes.cpp @@ -45,14 +45,14 @@ struct Mutes : Module { // Get input // Inputs are normalized to the input above it, so only set if connected if (inputs[IN_INPUT + i].isConnected()) { - inputs[IN_INPUT + i].getVoltages(out); channels = inputs[IN_INPUT + i].getChannels(); + inputs[IN_INPUT + i].readVoltages(out); } // Set output if (outputs[OUT_OUTPUT + i].isConnected()) { outputs[OUT_OUTPUT + i].setChannels(channels); - outputs[OUT_OUTPUT + i].setVoltages(state[i] ? out : zero); + outputs[OUT_OUTPUT + i].writeVoltages(state[i] ? out : zero); } // Set light diff --git a/src/Sum.cpp b/src/Sum.cpp index 6470023..e3fce5e 100644 --- a/src/Sum.cpp +++ b/src/Sum.cpp @@ -34,12 +34,7 @@ struct Sum : Module { } void process(const ProcessArgs &args) override { - int channels = inputs[POLY_INPUT].getChannels(); - float sum = 0.f; - for (int c = 0; c < channels; c++) { - sum += inputs[POLY_INPUT].getVoltage(c); - } - + float sum = inputs[POLY_INPUT].getVoltageSum(); sum *= params[LEVEL_PARAM].getValue(); outputs[MONO_OUTPUT].setVoltage(sum); diff --git a/src/VCA.cpp b/src/VCA.cpp index 4ca44ca..8c37f10 100644 --- a/src/VCA.cpp +++ b/src/VCA.cpp @@ -36,7 +36,7 @@ struct VCA : Module { int channels = in.getChannels(); simd::float_4 v[4]; for (int c = 0; c < channels; c += 4) { - v[c / 4] = simd::float_4::load(&in.voltages[c]); + v[c / 4] = simd::float_4::load(in.getVoltages(c)); } // Apply knob gain @@ -56,7 +56,7 @@ struct VCA : Module { } else { for (int c = 0; c < channels; c += 4) { - simd::float_4 cv = simd::float_4::load(&lin.voltages[c]) / 10.f; + simd::float_4 cv = simd::float_4::load(lin.getVoltages(c)) / 10.f; cv = clamp(cv, 0.f, 1.f); v[c / 4] *= cv; } @@ -76,7 +76,7 @@ struct VCA : Module { } else { for (int c = 0; c < channels; c += 4) { - simd::float_4 cv = simd::float_4::load(&exp.voltages[c]) / 10.f; + simd::float_4 cv = simd::float_4::load(exp.getVoltages(c)) / 10.f; cv = clamp(cv, 0.f, 1.f); cv = rescale(pow(expBase, cv), 1.f, expBase, 0.f, 1.f); v[c / 4] *= cv; @@ -87,7 +87,7 @@ struct VCA : Module { // Set output out.setChannels(channels); for (int c = 0; c < channels; c += 4) { - v[c / 4].store(&out.voltages[c]); + v[c / 4].store(out.getVoltages(c)); } } diff --git a/src/VCMixer.cpp b/src/VCMixer.cpp index 56f506f..025b6ad 100644 --- a/src/VCMixer.cpp +++ b/src/VCMixer.cpp @@ -34,44 +34,46 @@ struct VCMixer : Module { float mix[16] = {}; int maxChannels = 1; + // Channels for (int i = 0; i < 4; i++) { - // Skip channel if not patched - if (!inputs[CH_INPUT + i].isConnected()) - continue; - + int channels = 1; float in[16] = {}; - int channels = inputs[CH_INPUT + i].getChannels(); - maxChannels = std::max(maxChannels, channels); - // Get input - inputs[CH_INPUT + i].getVoltages(in); + if (inputs[CH_INPUT + i].isConnected()) { + channels = inputs[CH_INPUT + i].getChannels(); + maxChannels = std::max(maxChannels, channels); - // Apply fader gain - float gain = std::pow(params[LVL_PARAM + i].getValue(), 2.f); - for (int c = 0; c < channels; c++) { - in[c] *= gain; - } + // Get input + inputs[CH_INPUT + i].readVoltages(in); - // Apply CV gain - if (inputs[CV_INPUT + i].isConnected()) { + // Apply fader gain + float gain = std::pow(params[LVL_PARAM + i].getValue(), 2.f); for (int c = 0; c < channels; c++) { - float cv = clamp(inputs[CV_INPUT + i].getPolyVoltage(c) / 10.f, 0.f, 1.f); - in[c] *= cv; + in[c] *= gain; + } + + // Apply CV gain + if (inputs[CV_INPUT + i].isConnected()) { + for (int c = 0; c < channels; c++) { + float cv = clamp(inputs[CV_INPUT + i].getPolyVoltage(c) / 10.f, 0.f, 1.f); + in[c] *= cv; + } + } + + // Add to mix + for (int c = 0; c < channels; c++) { + mix[c] += in[c]; } } // Set channel output if (outputs[CH_OUTPUT + i].isConnected()) { outputs[CH_OUTPUT + i].setChannels(channels); - outputs[CH_OUTPUT + i].setVoltages(in); - } - - // Add to mix - for (int c = 0; c < channels; c++) { - mix[c] += in[c]; + outputs[CH_OUTPUT + i].writeVoltages(in); } } + // Mix output if (outputs[MIX_OUTPUT].isConnected()) { // Apply mix knob gain float gain = params[MIX_LVL_PARAM].getValue(); @@ -89,7 +91,7 @@ struct VCMixer : Module { // Set mix output outputs[MIX_OUTPUT].setChannels(maxChannels); - outputs[MIX_OUTPUT].setVoltages(mix); + outputs[MIX_OUTPUT].writeVoltages(mix); } } };