From ce781960938b953506088c87c62648e1ea160ae9 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Tue, 2 Nov 2021 02:27:29 -0400 Subject: [PATCH] Add FrequencyQuantity to LFO. --- src/LFO.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/LFO.cpp b/src/LFO.cpp index 6fe490b..f05358b 100644 --- a/src/LFO.cpp +++ b/src/LFO.cpp @@ -56,7 +56,22 @@ struct LFO : Module { config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS); configButton(OFFSET_PARAM, "Offset 0-10V"); configButton(INVERT_PARAM, "Invert"); - configParam(FREQ_PARAM, -8.f, 10.f, 1.f, "Frequency", " Hz", 2, 1); + + struct FrequencyQuantity : ParamQuantity { + float getDisplayValue() override { + LFO* module = reinterpret_cast(this->module); + if (module->clockFreq == 2.f) { + unit = " Hz"; + displayMultiplier = 1.f; + } + else { + unit = "x"; + displayMultiplier = 1 / 2.f; + } + return ParamQuantity::getDisplayValue(); + } + }; + configParam(FREQ_PARAM, -8.f, 10.f, 1.f, "Frequency", " Hz", 2, 1); configParam(FM_PARAM, -1.f, 1.f, 0.f, "Frequency modulation", "%", 0.f, 100.f); getParamQuantity(FM_PARAM)->randomizeEnabled = false; configParam(PW_PARAM, 0.01f, 0.99f, 0.5f, "Pulse width", "%", 0.f, 100.f);