Browse Source

Mixer: When polyphonic and monophonic inputs are combined, copy all mono signals to all mix output poly channels.

tags/v2.0.1
Andrew Belt 5 years ago
parent
commit
02558776ed
2 changed files with 25 additions and 8 deletions
  1. +4
    -0
      CHANGELOG.md
  2. +21
    -8
      src/VCMixer.cpp

+ 4
- 0
CHANGELOG.md View File

@@ -1,3 +1,7 @@
### 2.0.0 (in development)
- Mixer
- When polyphonic and monophonic inputs are combined, copy all mono signals to all mix output poly channels.

### 1.4.0 (2019-11-08) ### 1.4.0 (2019-11-08)
- Add Pulses. - Add Pulses.




+ 21
- 8
src/VCMixer.cpp View File

@@ -48,10 +48,15 @@ struct VCMixer : Module {
} }


void process(const ProcessArgs& args) override { void process(const ProcessArgs& args) override {
// Get number of poly channels for mix output
int mixChannels = 1;
for (int i = 0; i < 4; i++) {
int channels = inputs[CH_INPUTS + i].getChannels();
mixChannels = std::max(mixChannels, channels);
}
float mix[16] = {}; float mix[16] = {};
int maxChannels = 1;


// Channels
// Channel strips
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
int channels = 1; int channels = 1;
float in[16] = {}; float in[16] = {};
@@ -59,7 +64,6 @@ struct VCMixer : Module {


if (inputs[CH_INPUTS + i].isConnected()) { if (inputs[CH_INPUTS + i].isConnected()) {
channels = inputs[CH_INPUTS + i].getChannels(); channels = inputs[CH_INPUTS + i].getChannels();
maxChannels = std::max(maxChannels, channels);


// Get input // Get input
inputs[CH_INPUTS + i].readVoltages(in); inputs[CH_INPUTS + i].readVoltages(in);
@@ -79,8 +83,17 @@ struct VCMixer : Module {
} }


// Add to mix // Add to mix
for (int c = 0; c < channels; c++) {
mix[c] += in[c];
if (channels == 1) {
// Copy the mono signal to all mix channels
for (int c = 0; c < mixChannels; c++) {
mix[c] += in[0];
}
}
else {
// Copy each poly channel to the corresponding mix channel
for (int c = 0; c < channels; c++) {
mix[c] += in[c];
}
} }


// Sum channel for VU meter // Sum channel for VU meter
@@ -102,20 +115,20 @@ struct VCMixer : Module {
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();
for (int c = 0; c < maxChannels; c++) {
for (int c = 0; c < mixChannels; c++) {
mix[c] *= gain; mix[c] *= gain;
} }


// Apply mix CV gain // Apply mix CV gain
if (inputs[MIX_CV_INPUT].isConnected()) { if (inputs[MIX_CV_INPUT].isConnected()) {
for (int c = 0; c < maxChannels; c++) {
for (int c = 0; c < mixChannels; c++) {
float cv = clamp(inputs[MIX_CV_INPUT].getPolyVoltage(c) / 10.f, 0.f, 1.f); float cv = clamp(inputs[MIX_CV_INPUT].getPolyVoltage(c) / 10.f, 0.f, 1.f);
mix[c] *= cv; mix[c] *= cv;
} }
} }


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




Loading…
Cancel
Save