Browse Source

Fix Port::read/writeVoltages.

tags/v1.0.1
Andrew Belt 6 years ago
parent
commit
5e6782cbfb
5 changed files with 37 additions and 39 deletions
  1. +4
    -3
      src/8vert.cpp
  2. +2
    -2
      src/Mutes.cpp
  3. +1
    -6
      src/Sum.cpp
  4. +4
    -4
      src/VCA.cpp
  5. +26
    -24
      src/VCMixer.cpp

+ 4
- 3
src/8vert.cpp View File

@@ -33,19 +33,20 @@ struct _8vert : Module {
// Get input // Get input
if (inputs[IN_INPUTS + i].isConnected()) { if (inputs[IN_INPUTS + i].isConnected()) {
channels = inputs[IN_INPUTS + i].getChannels(); channels = inputs[IN_INPUTS + i].getChannels();
inputs[IN_INPUTS + i].getVoltages(in);
inputs[IN_INPUTS + i].readVoltages(in);
} }


if (outputs[OUT_OUTPUTS + i].isConnected()) { if (outputs[OUT_OUTPUTS + i].isConnected()) {
// Apply gain // Apply gain
float out[16]; float out[16];
float gain = params[GAIN_PARAMS + i].getValue(); 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]; out[c] = gain * in[c];
}


// Set output // Set output
outputs[OUT_OUTPUTS + i].setChannels(channels); outputs[OUT_OUTPUTS + i].setChannels(channels);
outputs[OUT_OUTPUTS + i].setVoltages(out);
outputs[OUT_OUTPUTS + i].writeVoltages(out);
} }
} }
} }


+ 2
- 2
src/Mutes.cpp View File

@@ -45,14 +45,14 @@ struct Mutes : Module {
// Get input // Get input
// Inputs are normalized to the input above it, so only set if connected // Inputs are normalized to the input above it, so only set if connected
if (inputs[IN_INPUT + i].isConnected()) { if (inputs[IN_INPUT + i].isConnected()) {
inputs[IN_INPUT + i].getVoltages(out);
channels = inputs[IN_INPUT + i].getChannels(); channels = inputs[IN_INPUT + i].getChannels();
inputs[IN_INPUT + i].readVoltages(out);
} }


// Set output // Set output
if (outputs[OUT_OUTPUT + i].isConnected()) { if (outputs[OUT_OUTPUT + i].isConnected()) {
outputs[OUT_OUTPUT + i].setChannels(channels); 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 // Set light


+ 1
- 6
src/Sum.cpp View File

@@ -34,12 +34,7 @@ struct Sum : Module {
} }


void process(const ProcessArgs &args) override { 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(); sum *= params[LEVEL_PARAM].getValue();
outputs[MONO_OUTPUT].setVoltage(sum); outputs[MONO_OUTPUT].setVoltage(sum);




+ 4
- 4
src/VCA.cpp View File

@@ -36,7 +36,7 @@ struct VCA : Module {
int channels = in.getChannels(); int channels = in.getChannels();
simd::float_4 v[4]; simd::float_4 v[4];
for (int c = 0; c < channels; c += 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 // Apply knob gain
@@ -56,7 +56,7 @@ struct VCA : Module {
} }
else { else {
for (int c = 0; c < channels; c += 4) { 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); cv = clamp(cv, 0.f, 1.f);
v[c / 4] *= cv; v[c / 4] *= cv;
} }
@@ -76,7 +76,7 @@ struct VCA : Module {
} }
else { else {
for (int c = 0; c < channels; c += 4) { 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 = clamp(cv, 0.f, 1.f);
cv = rescale(pow(expBase, cv), 1.f, expBase, 0.f, 1.f); cv = rescale(pow(expBase, cv), 1.f, expBase, 0.f, 1.f);
v[c / 4] *= cv; v[c / 4] *= cv;
@@ -87,7 +87,7 @@ struct VCA : Module {
// Set output // Set output
out.setChannels(channels); out.setChannels(channels);
for (int c = 0; c < channels; c += 4) { for (int c = 0; c < channels; c += 4) {
v[c / 4].store(&out.voltages[c]);
v[c / 4].store(out.getVoltages(c));
} }
} }




+ 26
- 24
src/VCMixer.cpp View File

@@ -34,44 +34,46 @@ struct VCMixer : Module {
float mix[16] = {}; float mix[16] = {};
int maxChannels = 1; int maxChannels = 1;


// Channels
for (int i = 0; i < 4; i++) { 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] = {}; 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++) { 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 // Set channel output
if (outputs[CH_OUTPUT + i].isConnected()) { if (outputs[CH_OUTPUT + i].isConnected()) {
outputs[CH_OUTPUT + i].setChannels(channels); 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()) { if (outputs[MIX_OUTPUT].isConnected()) {
// Apply mix knob gain // Apply mix knob gain
float gain = params[MIX_LVL_PARAM].getValue(); float gain = params[MIX_LVL_PARAM].getValue();
@@ -89,7 +91,7 @@ struct VCMixer : Module {


// Set mix output // Set mix output
outputs[MIX_OUTPUT].setChannels(maxChannels); outputs[MIX_OUTPUT].setChannels(maxChannels);
outputs[MIX_OUTPUT].setVoltages(mix);
outputs[MIX_OUTPUT].writeVoltages(mix);
} }
} }
}; };


Loading…
Cancel
Save