From 2307845b94f98f826035ded0585533a8b82867c6 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sat, 1 Jun 2019 21:52:11 -0400 Subject: [PATCH] Clear voltages of higher channels when a Cable copies from Output to Input. --- src/engine/Engine.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp index f174df8a..11982c5b 100644 --- a/src/engine/Engine.cpp +++ b/src/engine/Engine.cpp @@ -272,11 +272,16 @@ static void Cable_step(Cable *that) { Output *output = &that->outputModule->outputs[that->outputId]; Input *input = &that->inputModule->inputs[that->inputId]; // Match number of polyphonic channels to output port - input->channels = output->channels; + int channels = output->channels; + input->channels = channels; // Copy all voltages from output to input - for (int i = 0; i < PORT_MAX_CHANNELS; i++) { + for (int i = 0; i < channels; i++) { input->voltages[i] = output->voltages[i]; } + // Clear all voltages of higher channels + for (int i = channels; i < PORT_MAX_CHANNELS; i++) { + input->voltages[i] = 0.f; + } } static void Engine_step(Engine *that) {