Skip to content

Commit

Permalink
Parameter deactivation available and used in waveshaper (#117)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
baconpaul authored Jul 18, 2024
1 parent 3cc971c commit e23d915
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
1 change: 1 addition & 0 deletions include/sst/voice-effects/VoiceEffectCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ template <typename VFXConfig> 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

Expand Down
30 changes: 11 additions & 19 deletions include/sst/voice-effects/waveshaper/WaveShaper.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ template <typename VFXConfig> struct WaveShaper : core::VoiceEffectTemplateBase<
enum struct WaveShaperIntParams : uint32_t
{
type,
hpOn,
lpOn,
num_params
};

Expand All @@ -65,8 +63,6 @@ template <typename VFXConfig> 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)
{
Expand All @@ -82,24 +78,24 @@ template <typename VFXConfig> 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;
}
Expand Down Expand Up @@ -128,10 +124,6 @@ template <typename VFXConfig> 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;
}
Expand Down Expand Up @@ -222,8 +214,8 @@ template <typename VFXConfig> 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();
Expand Down Expand Up @@ -259,8 +251,8 @@ template <typename VFXConfig> 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();
Expand Down

0 comments on commit e23d915

Please sign in to comment.