From c8fbc1a0760fb0ce041789e30e1763494f539861 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sun, 27 Jan 2019 04:28:34 -0500 Subject: [PATCH] Set plug lights to 0 when disconnected --- src/engine/Engine.cpp | 2 +- src/engine/Port.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp index 666bcb7d..6c2c16e3 100644 --- a/src/engine/Engine.cpp +++ b/src/engine/Engine.cpp @@ -117,7 +117,7 @@ static void Engine_step(Engine *engine) { } } - float cpuLambda = engine->internal->sampleTime / 2.f; + const float cpuLambda = engine->internal->sampleTime / 2.f; // Iterate modules int modulesLen = engine->modules.size(); diff --git a/src/engine/Port.cpp b/src/engine/Port.cpp index 606f622b..282d6389 100644 --- a/src/engine/Port.cpp +++ b/src/engine/Port.cpp @@ -6,12 +6,12 @@ namespace rack { void Port::step() { // Set plug lights - if (channels == 0) { + if (!isConnected() || getChannels() == 0) { plugLights[0].setBrightness(0.f); plugLights[1].setBrightness(0.f); plugLights[2].setBrightness(0.f); } - else if (channels == 1) { + else if (getChannels() == 1) { float v = getVoltage() / 10.f; plugLights[0].setBrightnessSmooth(v); plugLights[1].setBrightnessSmooth(-v); @@ -19,7 +19,7 @@ void Port::step() { } else { float v2 = 0.f; - for (int c = 0; c < channels; c++) { + for (int c = 0; c < getChannels(); c++) { v2 += std::pow(getVoltage(c), 2); } float v = std::sqrt(v2) / 10.f;