From b6a321a8ad47e158717bd475a87d15126299c6b3 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sun, 19 Nov 2017 05:08:15 -0500 Subject: [PATCH] Use VUMeter in Unity --- src/8vert.cpp | 6 +----- src/Unity.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/8vert.cpp b/src/8vert.cpp index 355520f..c593023 100644 --- a/src/8vert.cpp +++ b/src/8vert.cpp @@ -35,11 +35,7 @@ _8vertWidget::_8vertWidget() { _8vert *module = new _8vert(); setModule(module); box.size = Vec(8 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT); - - SVGPanel *panel = new SVGPanel(); - panel->box.size = box.size; - panel->setBackground(SVG::load(assetPlugin(plugin, "res/8vert.svg"))); - addChild(panel); + setPanel(SVG::load(assetPlugin(plugin, "res/8vert.svg"))); addChild(createScrew(Vec(15, 0))); addChild(createScrew(Vec(box.size.x - 30, 0))); diff --git a/src/Unity.cpp b/src/Unity.cpp index 938e28e..6709ba3 100644 --- a/src/Unity.cpp +++ b/src/Unity.cpp @@ -1,4 +1,5 @@ #include "Fundamental.hpp" +#include "dsp/vumeter.hpp" struct Unity : Module { @@ -79,10 +80,11 @@ void Unity::step() { outputs[MIX1_OUTPUT + 2*i].value = mix[i]; outputs[INV1_OUTPUT + 2*i].value = -mix[i]; // Lights - float dB = logf(fabsf(mix[i] / 10.0)) / logf(20.0) * 10.0; + VUMeter vuMeter; + vuMeter.dBInterval = 6.0; + vuMeter.setValue(mix[i] / 10.0); for (int j = 0; j < 5; j++) { - float b = clampf(dB / 3.0 + 1 + j, 0.0, 1.0); - lights[VU1_LIGHT + 5*i + j].setBrightnessSmooth(b); + lights[VU1_LIGHT + 5*i + j].setBrightnessSmooth(vuMeter.getBrightness(j)); } } }