From c127afdf1b12d87565808ce4b6939dd5cffd86c4 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sat, 2 Feb 2019 21:03:30 -0500 Subject: [PATCH] Add ExponentialSlewLimiter. Add "Poly" tag. Tweak appearance of port and cable widgets. --- include/dsp/filter.hpp | 19 +++++++++++++++++++ include/engine/Light.hpp | 2 +- src/app/CableWidget.cpp | 4 ++-- src/app/LightWidget.cpp | 24 +++++++++++++++--------- src/plugin.cpp | 1 + 5 files changed, 38 insertions(+), 12 deletions(-) diff --git a/include/dsp/filter.hpp b/include/dsp/filter.hpp index 47727c49..c0c21699 100644 --- a/include/dsp/filter.hpp +++ b/include/dsp/filter.hpp @@ -64,6 +64,25 @@ struct SlewLimiter { }; +struct ExponentialSlewLimiter { + float riseLambda = 1.f; + float fallLambda = 1.f; + float out = 0.f; + + float process(float in) { + if (in > out) { + float y = out + (in - out) * riseLambda; + out = (out == y) ? in : y; + } + else if (in < out) { + float y = out + (in - out) * fallLambda; + out = (out == y) ? in : y; + } + return out; + } +}; + + /** Applies exponential smoothing to a signal with the ODE dy/dt = x * lambda */ diff --git a/include/engine/Light.hpp b/include/engine/Light.hpp index 829922aa..c160dc7b 100644 --- a/include/engine/Light.hpp +++ b/include/engine/Light.hpp @@ -31,7 +31,7 @@ struct Light { // Fade out light with lambda = framerate // Use 44.1k here to avoid the call to Engine::getSampleRate(). // This is close enough to look okay up to 96k - value += (v - value) * frames * 120.f / 44100.f; + value += (v - value) * frames * 30.f / 44100.f; } else { // Immediately illuminate light diff --git a/src/app/CableWidget.cpp b/src/app/CableWidget.cpp index 5f4fd39c..0ff1d7ef 100644 --- a/src/app/CableWidget.cpp +++ b/src/app/CableWidget.cpp @@ -216,7 +216,7 @@ void CableWidget::draw(const widget::DrawContext &ctx) { // Draw opaque if mouse is hovering over a connected port if (output->channels > 1) { // Increase thickness if output port is polyphonic - thickness = 8; + thickness = 7; } if (outputPort->hovered || inputPort->hovered) { @@ -224,7 +224,7 @@ void CableWidget::draw(const widget::DrawContext &ctx) { } else if (output->channels == 0) { // Draw translucent cable if not active (i.e. 0 channels) - opacity *= 0.25; + opacity *= 0.5; } } else { diff --git a/src/app/LightWidget.cpp b/src/app/LightWidget.cpp index 9cfbc763..7acefd6f 100644 --- a/src/app/LightWidget.cpp +++ b/src/app/LightWidget.cpp @@ -18,28 +18,34 @@ void LightWidget::drawLight(const widget::DrawContext &ctx) { nvgCircle(ctx.vg, radius, radius, radius); // Background - nvgFillColor(ctx.vg, bgColor); - nvgFill(ctx.vg); + if (bgColor.a > 0.0) { + nvgFillColor(ctx.vg, bgColor); + nvgFill(ctx.vg); + } // Foreground - nvgFillColor(ctx.vg, color); - nvgFill(ctx.vg); + if (color.a > 0.0) { + nvgFillColor(ctx.vg, color); + nvgFill(ctx.vg); + } // Border - nvgStrokeWidth(ctx.vg, 0.5); - nvgStrokeColor(ctx.vg, borderColor); - nvgStroke(ctx.vg); + if (borderColor.a > 0.0) { + nvgStrokeWidth(ctx.vg, 0.5); + nvgStrokeColor(ctx.vg, borderColor); + nvgStroke(ctx.vg); + } } void LightWidget::drawHalo(const widget::DrawContext &ctx) { float radius = box.size.x / 2.0; - float oradius = radius + 15.0; + float oradius = 4.0 * radius; nvgBeginPath(ctx.vg); nvgRect(ctx.vg, radius - oradius, radius - oradius, 2*oradius, 2*oradius); NVGpaint paint; - NVGcolor icol = color::mult(color, 0.08); + NVGcolor icol = color::mult(color, 0.07); NVGcolor ocol = nvgRGB(0, 0, 0); paint = nvgRadialGradient(ctx.vg, radius, radius, radius, oradius, icol, ocol); nvgFillPaint(ctx.vg, paint); diff --git a/src/plugin.cpp b/src/plugin.cpp index e11f6e9a..e073f390 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -577,6 +577,7 @@ const std::vector allowedTags = { "VCO", "Panning", "Phaser", + "Poly", "Physical Modeling", "Quad", // The core functionality times four. If multiple channels are a requirement for the module to exist (ring modulator, mixer, etc), it is not a Quad module. "Quantizer",