Browse Source

Set plug lights to 0 when disconnected

tags/v1.0.0
Andrew Belt 6 years ago
parent
commit
c8fbc1a076
2 changed files with 4 additions and 4 deletions
  1. +1
    -1
      src/engine/Engine.cpp
  2. +3
    -3
      src/engine/Port.cpp

+ 1
- 1
src/engine/Engine.cpp View File

@@ -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 // Iterate modules
int modulesLen = engine->modules.size(); int modulesLen = engine->modules.size();


+ 3
- 3
src/engine/Port.cpp View File

@@ -6,12 +6,12 @@ namespace rack {


void Port::step() { void Port::step() {
// Set plug lights // Set plug lights
if (channels == 0) {
if (!isConnected() || getChannels() == 0) {
plugLights[0].setBrightness(0.f); plugLights[0].setBrightness(0.f);
plugLights[1].setBrightness(0.f); plugLights[1].setBrightness(0.f);
plugLights[2].setBrightness(0.f); plugLights[2].setBrightness(0.f);
} }
else if (channels == 1) {
else if (getChannels() == 1) {
float v = getVoltage() / 10.f; float v = getVoltage() / 10.f;
plugLights[0].setBrightnessSmooth(v); plugLights[0].setBrightnessSmooth(v);
plugLights[1].setBrightnessSmooth(-v); plugLights[1].setBrightnessSmooth(-v);
@@ -19,7 +19,7 @@ void Port::step() {
} }
else { else {
float v2 = 0.f; float v2 = 0.f;
for (int c = 0; c < channels; c++) {
for (int c = 0; c < getChannels(); c++) {
v2 += std::pow(getVoltage(c), 2); v2 += std::pow(getVoltage(c), 2);
} }
float v = std::sqrt(v2) / 10.f; float v = std::sqrt(v2) / 10.f;


Loading…
Cancel
Save