From e23d915e6c0807c8786c6c4212265676d1934751 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 18 Jul 2024 12:38:20 -0400 Subject: [PATCH] Parameter deactivation available and used in waveshaper (#117) 1. Add a new api getIsDeactivate(index) to the common template API and sifnae it to false 2. Use that in waveshaper to replace the hpOn hpOff params --- include/sst/voice-effects/VoiceEffectCore.h | 1 + .../sst/voice-effects/waveshaper/WaveShaper.h | 30 +++++++------------ 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/include/sst/voice-effects/VoiceEffectCore.h b/include/sst/voice-effects/VoiceEffectCore.h index 5b9d7ae..63220c4 100644 --- a/include/sst/voice-effects/VoiceEffectCore.h +++ b/include/sst/voice-effects/VoiceEffectCore.h @@ -201,6 +201,7 @@ template struct VoiceEffectTemplateBase : public VFXConfig: HASMEM(oversamplingRatio, constexpr int16_t getOversamplingRatio(), 1, ); HASMEM(getTempoPointer, double *getBaseTempoPointer(), &defaultTempo, (asBase())); HASMEM(isTemposync, bool getIsTemposync(), false, (asBase())); + HASMEM(isDeactivated, bool getIsDeactivated(int index), false, (asBase(), index)); #undef HASMEM diff --git a/include/sst/voice-effects/waveshaper/WaveShaper.h b/include/sst/voice-effects/waveshaper/WaveShaper.h index 92e18d7..118ebf7 100644 --- a/include/sst/voice-effects/waveshaper/WaveShaper.h +++ b/include/sst/voice-effects/waveshaper/WaveShaper.h @@ -50,8 +50,6 @@ template struct WaveShaper : core::VoiceEffectTemplateBase< enum struct WaveShaperIntParams : uint32_t { type, - hpOn, - lpOn, num_params }; @@ -65,8 +63,6 @@ template struct WaveShaper : core::VoiceEffectTemplateBase< basic_blocks::params::ParamMetaData paramAt(int idx) const { using pmd = basic_blocks::params::ParamMetaData; - bool hp = this->getIntParam((int)WaveShaperIntParams::hpOn) > 0; - bool lp = this->getIntParam((int)WaveShaperIntParams::lpOn) > 0; switch ((WaveShaperFloatParams)idx) { @@ -82,24 +78,24 @@ template struct WaveShaper : core::VoiceEffectTemplateBase< return pmd() .asFloat() .withRange(-48, 48) - .withName(!hp ? "Highpass" : "HP Offset") + .withName("HP Off") .withDefault(-48) + .deactivatable() .withLinearScaleFormatting("semitones"); } - return pmd().asAudibleFrequency().withDefault(-60).withName(!hp ? "Highpass" - : "HP Frequency"); + return pmd().asAudibleFrequency().withDefault(-60).withName("LoCut").deactivatable(); case WaveShaperFloatParams::lowpass: if (keytrackOn) { return pmd() .asFloat() .withRange(-48, 48) - .withName(!lp ? "Lowpass" : "LP Offset") + .withName("LP Off") .withDefault(48) - .withLinearScaleFormatting("semitones"); + .withLinearScaleFormatting("semitones") + .deactivatable(); } - return pmd().asAudibleFrequency().withDefault(70).withName(!lp ? "Lowpass" - : "LP Frequency"); + return pmd().asAudibleFrequency().withDefault(70).withName("HiCut").deactivatable(); default: break; } @@ -128,10 +124,6 @@ template struct WaveShaper : core::VoiceEffectTemplateBase< .withUnorderedMapFormatting(names) .withDefault(1); } - case WaveShaperIntParams::hpOn: - return pmd().asBool().withDefault(false).withName("Highpass"); - case WaveShaperIntParams::lpOn: - return pmd().asBool().withDefault(false).withName("Lowpass"); default: break; } @@ -222,8 +214,8 @@ template struct WaveShaper : core::VoiceEffectTemplateBase< void processStereo(float *datainL, float *datainR, float *dataoutL, float *dataoutR, float pitch) { - bool hpActive = this->getIntParam((int)WaveShaperIntParams::hpOn); - bool lpActive = this->getIntParam((int)WaveShaperIntParams::lpOn); + bool hpActive = this->getIsDeactivated((int)WaveShaperFloatParams::highpass); + bool lpActive = this->getIsDeactivated((int)WaveShaperFloatParams::lowpass); namespace mech = sst::basic_blocks::mechanics; checkType(); @@ -259,8 +251,8 @@ template struct WaveShaper : core::VoiceEffectTemplateBase< void processMonoToMono(float *datainL, float *dataoutL, float pitch) { - bool hpActive = this->getIntParam((int)WaveShaperIntParams::hpOn); - bool lpActive = this->getIntParam((int)WaveShaperIntParams::lpOn); + bool hpActive = this->getIsDeactivated((int)WaveShaperFloatParams::highpass); + bool lpActive = this->getIsDeactivated((int)WaveShaperFloatParams::lowpass); namespace mech = sst::basic_blocks::mechanics; checkType();