diff --git a/plugins/Cardinal/src/HostAudio.cpp b/plugins/Cardinal/src/HostAudio.cpp index 7272b51..6fd21ce 100644 --- a/plugins/Cardinal/src/HostAudio.cpp +++ b/plugins/Cardinal/src/HostAudio.cpp @@ -23,36 +23,6 @@ USE_NAMESPACE_DISTRHO; -/* - * Find the highest absolute and normalized value within a float array. - */ -static inline -float d_findMaxNormalizedFloat(const float floats[], const std::size_t count) -{ - DISTRHO_SAFE_ASSERT_RETURN(floats != nullptr, 0.0f); - DISTRHO_SAFE_ASSERT_RETURN(count > 0, 0.0f); - - static const float kEmptyFloats[8192] = {}; - - if (count <= 8192 && std::memcmp(floats, kEmptyFloats, count) == 0) - return 0.0f; - - float tmp, maxf2 = std::abs(floats[0]); - - for (std::size_t i=1; i maxf2) - maxf2 = tmp; - } - - if (maxf2 > 1.0f) - maxf2 = 1.0f; - - return maxf2; -} - template struct HostAudio : Module { CardinalPluginContext* const pcontext; @@ -65,6 +35,8 @@ struct HostAudio : Module { // for rack core audio module compatibility dsp::RCFilter dcFilters[numIO]; bool dcFilterEnabled = (numIO == 2); + + // for stereo meter volatile bool resetMeters = true; float gainMeterL = 0.0f; float gainMeterR = 0.0f; @@ -190,7 +162,10 @@ struct HostAudioNanoMeter : NanoMeter { HostAudio* const module; HostAudioNanoMeter(HostAudio* const m) - : module(m) {} + : module(m) + { + hasGainKnob = true; + } void updateMeters() override { diff --git a/plugins/Cardinal/src/ModuleWidgets.hpp b/plugins/Cardinal/src/ModuleWidgets.hpp index 748f286..7191d3a 100644 --- a/plugins/Cardinal/src/ModuleWidgets.hpp +++ b/plugins/Cardinal/src/ModuleWidgets.hpp @@ -29,7 +29,7 @@ template struct ModuleWidgetWithSideScrews : ModuleWidget { static constexpr const float startX_In = 10.65f; static constexpr const float startX_Out = (hp - 3) * 15 + startX_In; - static constexpr const float startY = 73.0f; // note out bg box has 2px extra + static constexpr const float startY = 73.0f; // note: out bg box has 2px extra static constexpr const float padding = 29.0f; static constexpr const float middleX = startX_In + (startX_Out - startX_In) * 0.5f /*+ padding * 0.35f*/; diff --git a/plugins/Cardinal/src/Widgets.hpp b/plugins/Cardinal/src/Widgets.hpp index 6906749..61b662c 100644 --- a/plugins/Cardinal/src/Widgets.hpp +++ b/plugins/Cardinal/src/Widgets.hpp @@ -242,6 +242,7 @@ struct NanoKnob : Knob { }; struct NanoMeter : Widget { + bool hasGainKnob = false; float gainMeterL = 0.0f; float gainMeterR = 0.0f; @@ -252,7 +253,7 @@ struct NanoMeter : Widget { if (layer != 1) return; - const float usableHeight = box.size.y - 10.0f; + const float usableHeight = box.size.y - (hasGainKnob ? 10.0f : 0.0f); // draw background nvgBeginPath(args.vg); @@ -281,6 +282,9 @@ struct NanoMeter : Widget { nvgFill(args.vg); nvgStroke(args.vg); + if (! hasGainKnob) + return; + nvgLineCap(args.vg, NVG_ROUND); nvgBeginPath(args.vg); diff --git a/plugins/Cardinal/src/plugin.hpp b/plugins/Cardinal/src/plugin.hpp index 07c352e..cf50652 100644 --- a/plugins/Cardinal/src/plugin.hpp +++ b/plugins/Cardinal/src/plugin.hpp @@ -44,3 +44,33 @@ extern Model* modelHostTime; extern Model* modelIldaeil; extern Model* modelMPV; extern Model* modelTextEditor; + +/* + * Find the highest absolute and normalized value within a float array. + */ +static inline +float d_findMaxNormalizedFloat(const float floats[], const std::size_t count) +{ + DISTRHO_SAFE_ASSERT_RETURN(floats != nullptr, 0.0f); + DISTRHO_SAFE_ASSERT_RETURN(count > 0, 0.0f); + + static const float kEmptyFloats[8192] = {}; + + if (count <= 8192 && std::memcmp(floats, kEmptyFloats, count) == 0) + return 0.0f; + + float tmp, maxf2 = std::abs(floats[0]); + + for (std::size_t i=1; i maxf2) + maxf2 = tmp; + } + + if (maxf2 > 1.0f) + maxf2 = 1.0f; + + return maxf2; +}