From c74e96ccde6429332f601ff999fe7ebde1f3f114 Mon Sep 17 00:00:00 2001 From: Don Cross Date: Mon, 24 Jun 2024 21:08:36 -0400 Subject: [PATCH] Fixed #56 - Tube Unit now supports low-sensitivity attenuverters. --- CHANGELOG.md | 3 ++- TubeUnit.md | 6 ++++++ src/tubeunit_vcv.cpp | 15 ++++++++++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b58ae12..5167e86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ @@ -34,7 +35,7 @@ 2.4.5 diff --git a/TubeUnit.md b/TubeUnit.md index 3170e6f..427bdd5 100644 --- a/TubeUnit.md +++ b/TubeUnit.md @@ -199,7 +199,9 @@ when the limiter is active. The warning light option defaults to being enabled. + ### Toggling between VENT mode and SEAL mode + As [mentioned above](#vent_port), there is a VENT port in the upper left corner of the panel. @@ -228,3 +230,7 @@ high, Tube Unit starts making sound. The VENT/SEAL input is polyphonic just like all the other input ports in Tube Unit. + +### Low-sensitivity attenuverters + +Tube Unit supports [low-sensitivity attenuverters](LowSensitivityAttenuverterKnobs.md). diff --git a/src/tubeunit_vcv.cpp b/src/tubeunit_vcv.cpp index 6302f8c..de24dee 100644 --- a/src/tubeunit_vcv.cpp +++ b/src/tubeunit_vcv.cpp @@ -1,5 +1,6 @@ #include #include "sapphire_vcvrack.hpp" +#include "sapphire_widget.hpp" #include "tubeunit_engine.hpp" // Sapphire Tube Unit for VCV Rack 2, by Don Cross @@ -192,6 +193,8 @@ namespace Sapphire // Thus we allow the complete range of control for any CV whose // range is [-5, +5] volts. float attenu = params[cg.attenId].getValue(); + if (isLowSensitive(cg.attenId)) + attenu /= AttenuverterLowSensitivityDenom; slider += attenu*(cv / 5)*(cg.maxValue - cg.minValue); } return std::clamp(slider, cg.minValue, cg.maxValue); @@ -380,7 +383,14 @@ namespace Sapphire addParam(createParamCentered(knobCenter, tubeUnitModule, cg.paramId)); Vec attenCenter = knobCenter.plus(mm2px(Vec(-10.0*xdir, -4.0))); - addParam(createParamCentered(attenCenter, tubeUnitModule, cg.attenId)); + SapphireAttenuverterKnob* knob = createParamCentered(attenCenter, tubeUnitModule, cg.attenId); + if (module != nullptr) + { + // Allow Tube Unit's attenuverter knobs to participate in the "low-sensitivity" feature. + knob->lowSensitivityMode = module->lowSensitiveFlag(cg.attenId); + module->defineAttenuverterId(cg.attenId); + } + addParam(knob); Vec portCenter = knobCenter.plus(mm2px(Vec(-10.0*xdir, +4.0))); addInput(createInputCentered(portCenter, tubeUnitModule, cg.inputId)); @@ -420,6 +430,9 @@ namespace Sapphire // Add toggle for whether the VENT port should be inverted to a SEAL port. menu->addChild(createBoolPtrMenuItem("Toggle VENT/SEAL", "", &tubeUnitModule->isInvertedVentPort)); + + // Add an option to toggle the low-sensitivity state of all attenuverter knobs. + menu->addChild(tubeUnitModule->createToggleAllSensitivityMenuItem()); } } }