Skip to content

Commit

Permalink
consistency (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreya-Autumn authored Jul 7, 2024
1 parent 08d553d commit 687e53a
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 33 deletions.
10 changes: 7 additions & 3 deletions include/sst/voice-effects/delay/ShortDelay.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ template <typename VFXConfig> struct ShortDelay : core::VoiceEffectTemplateBase<
basic_blocks::params::ParamMetaData paramAt(int idx) const
{
using pmd = basic_blocks::params::ParamMetaData;
bool stereo = this->getIntParam(ipStereo) > 0;

switch (idx)
{
case fpTimeL:
Expand All @@ -98,20 +100,21 @@ template <typename VFXConfig> struct ShortDelay : core::VoiceEffectTemplateBase<
.withRange(0, maxMiliseconds)
.withDefault(50)
.withLinearScaleFormatting("ms")
.withName("Time L");
.withName(std::string("Time") + (stereo ? " L" : ""));

case fpTimeR:
return pmd()
.asFloat()
.withRange(0, maxMiliseconds)
.withDefault(50)
.withLinearScaleFormatting("ms")
.withName("Time R");
.withName(!stereo ? std::string() : "Time R");

case fpFeedback:
return pmd().asPercent().withDefault(0.f).withName("Feedback");
case fpCrossFeed:
return pmd().asPercent().withDefault(0.f).withName("CrossFeed");
return pmd().asPercent().withDefault(0.f).withName(!stereo ? std::string()
: "CrossFeed");

case fpLowCut:
return pmd().asAudibleFrequency().withDefault(-60).withName("LowCut");
Expand Down Expand Up @@ -319,6 +322,7 @@ template <typename VFXConfig> struct ShortDelay : core::VoiceEffectTemplateBase<
}

bool getMonoToStereoSetting() const { return this->getIntParam(ipStereo) > 0; }
bool checkParameterConsistency() const { return true; }

protected:
std::array<details::DelayLineSupport, 2> lineSupport;
Expand Down
28 changes: 18 additions & 10 deletions include/sst/voice-effects/delay/StringResonator.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ template <typename VFXConfig> struct StringResonator : core::VoiceEffectTemplate
basic_blocks::params::ParamMetaData paramAt(int idx) const
{
using pmd = basic_blocks::params::ParamMetaData;
bool dual = this->getIntParam(ipDualString) > 0;
bool stereo = this->getIntParam(ipStereo) > 0;

switch (idx)
{
case fpLevelOne:
Expand All @@ -102,15 +105,15 @@ template <typename VFXConfig> struct StringResonator : core::VoiceEffectTemplate
.withDefault(1.f)
.withLinearScaleFormatting("%", 100.f)
.withDecimalPlaces(2)
.withName("Level One");
.withName(std::string("Level") + (dual ? " One" : ""));
case fpLevelTwo:
return pmd()
.asFloat()
.withRange(0.f, 1.f)
.withDefault(1.f)
.withLinearScaleFormatting("%", 100.f)
.withDecimalPlaces(2)
.withName("Level Two");
.withName(!dual ? std::string() : "Level Two");
case fpOffsetOne:
if (keytrackOn)
{
Expand All @@ -119,9 +122,10 @@ template <typename VFXConfig> struct StringResonator : core::VoiceEffectTemplate
.withRange(-48, 48)
.withDefault(0)
.withLinearScaleFormatting("semitones")
.withName("Offset One");
.withName(std::string("Offset") + (dual ? " One" : ""));
}
return pmd().asAudibleFrequency().withName("Frequency One");
return pmd().asAudibleFrequency().withName(std::string("Frequency") +
(dual ? " One" : ""));
case fpOffsetTwo:
if (keytrackOn)
{
Expand All @@ -130,25 +134,28 @@ template <typename VFXConfig> struct StringResonator : core::VoiceEffectTemplate
.withRange(-48, 48)
.withDefault(0)
.withLinearScaleFormatting("semitones")
.withName("Offset Two");
.withName(!dual ? std::string() : "Offset Two");
}
return pmd().asAudibleFrequency().withName("Frequency Two");
return pmd()
.asAudibleFrequency()
.withName(!dual ? std::string() : "Frequency Two")
.withDefault(0);
case fpPanOne:
return pmd()
.asPercentBipolar()
.withCustomMinDisplay("L")
.withCustomMaxDisplay("R")
.withCustomDefaultDisplay("C")
.withDefault(-1.f)
.withName("Pan One");
.withName(!stereo ? std::string() : (std::string("Pan") + (dual ? " One" : "")));
case fpPanTwo:
return pmd()
.asPercentBipolar()
.withCustomMinDisplay("L")
.withCustomMaxDisplay("R")
.withCustomDefaultDisplay("C")
.withDefault(1.f)
.withName("Pan Two");
.withName((dual && stereo) ? "Pan Two" : std::string());
case fpDecay:
return pmd()
.asFloat()
Expand Down Expand Up @@ -251,8 +258,8 @@ template <typename VFXConfig> struct StringResonator : core::VoiceEffectTemplate

if (this->getIntParam(ipStereo) == false)
{
panParamOne = 0.f;
panParamTwo = 1.f;
panParamOne = 0.5f;
panParamTwo = 0.5f;
}

auto ptOne = this->getFloatParam(fpOffsetOne);
Expand Down Expand Up @@ -685,6 +692,7 @@ template <typename VFXConfig> struct StringResonator : core::VoiceEffectTemplate
}

bool getMonoToStereoSetting() const { return this->getIntParam(ipStereo) > 0; }
bool checkParameterConsistency() const { return true; }

bool enableKeytrack(bool b)
{
Expand Down
14 changes: 13 additions & 1 deletion include/sst/voice-effects/filter/CytomicSVF.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ template <typename VFXConfig> struct CytomicSVF : core::VoiceEffectTemplateBase<
using pmd = basic_blocks::params::ParamMetaData;
bool stereo = this->getIntParam(ipStereo) > 0;

bool gain{false};
using md = sst::filters::CytomicSVF::Mode;
auto mode = (md)this->getIntParam(ipMode);
if (mode == md::BELL || mode == md::HIGH_SHELF || mode == md::LOW_SHELF)
{
gain = true;
}

switch (idx)
{
case 0:
Expand Down Expand Up @@ -106,7 +114,11 @@ template <typename VFXConfig> struct CytomicSVF : core::VoiceEffectTemplateBase<
.withLinearScaleFormatting("")
.withDefault(0.707);
case 3:
return pmd().asDecibelNarrow().withRange(-12, 12).withName("Gain").withDefault(0);
return pmd()
.asDecibelNarrow()
.withRange(-12, 12)
.withName(!gain ? std::string() : "Gain")
.withDefault(0);
}

return pmd().withName("Unknown " + std::to_string(idx)).asPercent();
Expand Down
26 changes: 18 additions & 8 deletions include/sst/voice-effects/filter/StaticPhaser.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ template <typename VFXConfig> struct StaticPhaser : core::VoiceEffectTemplateBas

enum FloatParams
{
fpCenterFrequency,
fpCenterFrequencyL,
fpCenterFrequencyR,
fpSpacing, // = fpCenterFrequency + (stereo ? 2 : 1) <-re-implement this?
fpSpacing,
fpResonance,
fpFeedback
};
Expand All @@ -68,6 +68,8 @@ template <typename VFXConfig> struct StaticPhaser : core::VoiceEffectTemplateBas
basic_blocks::params::ParamMetaData intParamAt(int idx) const
{
using pmd = basic_blocks::params::ParamMetaData;
bool stereo = this->getIntParam(ipStereo) > 0;

switch (idx)
{
case ipStages:
Expand All @@ -90,32 +92,39 @@ template <typename VFXConfig> struct StaticPhaser : core::VoiceEffectTemplateBas
basic_blocks::params::ParamMetaData paramAt(int idx) const
{
using pmd = basic_blocks::params::ParamMetaData;
bool stereo = this->getIntParam(ipStereo) > 0;

switch (idx)
{
case fpCenterFrequency:
case fpCenterFrequencyL:
if (keytrackOn)
{
return pmd()
.asFloat()
.withRange(-48, 48)
.withName("Offset L")
.withName(std::string("Offset L") + (stereo ? " L" : ""))
.withDefault(0)
.withLinearScaleFormatting("semitones");
}
return pmd().asAudibleFrequency().withName("Frequency L").withDefault(0);
return pmd()
.asAudibleFrequency()
.withName(std::string("Frequency") + (stereo ? " L" : ""))
.withDefault(0);

case fpCenterFrequencyR:
if (keytrackOn)
{
return pmd()
.asFloat()
.withRange(-48, 48)
.withName("Offset R")
.withName(!stereo ? std::string() : "Offset R")
.withDefault(0)
.withLinearScaleFormatting("semitones");
}
return pmd().asAudibleFrequency().withName("Frequency R").withDefault(0);
return pmd()
.asAudibleFrequency()
.withName(!stereo ? std::string() : "Frequency R")
.withDefault(0);

break;
case fpSpacing:
Expand Down Expand Up @@ -240,7 +249,7 @@ template <typename VFXConfig> struct StaticPhaser : core::VoiceEffectTemplateBas
}
auto mode = sst::filters::CytomicSVF::Mode::ALL;
auto spread{0.f};
auto baseL{param[fpCenterFrequency]}, baseR{baseL};
auto baseL{param[fpCenterFrequencyL]}, baseR{baseL};
if (iparam[ipStereo])
{
baseR = param[fpCenterFrequencyR];
Expand Down Expand Up @@ -288,6 +297,7 @@ template <typename VFXConfig> struct StaticPhaser : core::VoiceEffectTemplateBas
return res;
}
bool getKeytrack() const { return keytrackOn; }
bool checkParameterConsistency() const { return true; }

protected:
bool keytrackOn{false}, wasKeytrackOn{false};
Expand Down
5 changes: 4 additions & 1 deletion include/sst/voice-effects/generator/GenCorrelatedNoise.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ template <typename VFXConfig> struct GenCorrelatedNoise : core::VoiceEffectTempl
basic_blocks::params::ParamMetaData paramAt(int idx) const
{
using pmd = basic_blocks::params::ParamMetaData;
bool stereo = this->getIntParam(ipStereo) > 0;

switch (idx)
{
Expand All @@ -80,7 +81,8 @@ template <typename VFXConfig> struct GenCorrelatedNoise : core::VoiceEffectTempl
case FloatParams::fpLevel:
return pmd().asCubicDecibelAttenuation().withDefault(0.5f).withName("Level");
case FloatParams::fpStereoWidth:
return pmd().asFloat().withRange(0.f, 2.f).withDefault(1.f).withName("Stereo Width");
return pmd().asFloat().withRange(0.f, 2.f).withDefault(1.f).withName(
!stereo ? std::string() : "Stereo Width");
default:
break;
}
Expand Down Expand Up @@ -179,6 +181,7 @@ template <typename VFXConfig> struct GenCorrelatedNoise : core::VoiceEffectTempl
}

bool getMonoToStereoSetting() const { return this->getIntParam(ipStereo) > 0; }
bool checkParameterConsistency() const { return true; }

protected:
float mPrior[2][2]{{0.f, 0.f}, {0.f, 0.f}};
Expand Down
13 changes: 9 additions & 4 deletions include/sst/voice-effects/modulation/FMFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ template <typename VFXConfig> struct FMFilter : core::VoiceEffectTemplateBase<VF
basic_blocks::params::ParamMetaData paramAt(int idx) const
{
using pmd = basic_blocks::params::ParamMetaData;
bool stereo = this->getIntParam(ipStereo) > 0;

switch (idx)
{
Expand All @@ -68,22 +69,25 @@ template <typename VFXConfig> struct FMFilter : core::VoiceEffectTemplateBase<VF
return pmd()
.asFloat()
.withRange(-48, 48)
.withName("Offset L")
.withName(std::string("Offset") + (stereo ? " L" : ""))
.withDefault(0)
.withLinearScaleFormatting("semitones");
}
return pmd().asAudibleFrequency().withName("Frequency L");
return pmd()
.asAudibleFrequency()
.withName(std::string("Frequency L") + (stereo ? " L" : ""))
.withDefault(0);
case fpFreqR:
if (keytrackOn)
{
return pmd()
.asFloat()
.withRange(-48, 48)
.withName("Offset R")
.withName(!stereo ? std::string() : "Offset R")
.withDefault(0)
.withLinearScaleFormatting("semitones");
}
return pmd().asAudibleFrequency().withName("Frequency R");
return pmd().asAudibleFrequency().withName(!stereo ? std::string() : "Frequency R");
case fpDepth:
return pmd().asFloat().withRange(0.f, 1.f).withDefault(0.f).withName("FM Depth");
case fpRes:
Expand Down Expand Up @@ -290,6 +294,7 @@ template <typename VFXConfig> struct FMFilter : core::VoiceEffectTemplateBase<VF
return res;
}
bool getKeytrack() const { return keytrackOn; }
bool checkParameterConsistency() const { return true; }

protected:
bool keytrackOn{false};
Expand Down
7 changes: 5 additions & 2 deletions include/sst/voice-effects/modulation/Tremolo.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ template <typename VFXConfig> struct Tremolo : core::VoiceEffectTemplateBase<VFX
basic_blocks::params::ParamMetaData paramAt(int idx) const
{
using pmd = basic_blocks::params::ParamMetaData;
bool harmonic = this->getIntParam(ipHarmonic) > 0;

switch (idx)
{
Expand All @@ -81,11 +82,11 @@ template <typename VFXConfig> struct Tremolo : core::VoiceEffectTemplateBase<VFX
return pmd()
.asFloat()
.withRange(-24, 48)
.withName("Crossover Offset")
.withName(!harmonic ? "Harmonic" : "Crossover Offset")
.withDefault(0)
.withLinearScaleFormatting("semitones");
}
return pmd().asAudibleFrequency().withName("Crossover");
return pmd().asAudibleFrequency().withName(!harmonic ? "Harmonic" : "Crossover");
}
return pmd().asFloat().withName("Error");
}
Expand Down Expand Up @@ -446,6 +447,8 @@ template <typename VFXConfig> struct Tremolo : core::VoiceEffectTemplateBase<VFX
}
bool getKeytrack() const { return keytrackOn; }

bool checkParameterConsistency() const { return true; }

protected:
bool keytrackOn{false};
std::array<float, numFloatParams> mLastParam{};
Expand Down
14 changes: 10 additions & 4 deletions include/sst/voice-effects/waveshaper/WaveShaper.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ 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 @@ -80,22 +82,24 @@ template <typename VFXConfig> struct WaveShaper : core::VoiceEffectTemplateBase<
return pmd()
.asFloat()
.withRange(-48, 48)
.withName("Hp Offset")
.withName(!hp ? "Highpass" : "HP Offset")
.withDefault(-48)
.withLinearScaleFormatting("semitones");
}
return pmd().asAudibleFrequency().withDefault(-60).withName("Hp Frequency");
return pmd().asAudibleFrequency().withDefault(-60).withName(!hp ? "Highpass"
: "HP Frequency");
case WaveShaperFloatParams::lowpass:
if (keytrackOn)
{
return pmd()
.asFloat()
.withRange(-48, 48)
.withName("Lp Offset")
.withName(!lp ? "Lowpass" : "LP Offset")
.withDefault(48)
.withLinearScaleFormatting("semitones");
}
return pmd().asAudibleFrequency().withDefault(70).withName("Lp Frequency");
return pmd().asAudibleFrequency().withDefault(70).withName(!lp ? "Lowpass"
: "LP Frequency");
default:
break;
}
Expand Down Expand Up @@ -312,6 +316,8 @@ template <typename VFXConfig> struct WaveShaper : core::VoiceEffectTemplateBase<
}
bool getKeytrack() const { return keytrackOn; }

bool checkParameterConsistency() const { return true; }

protected:
bool keytrackOn{false};
float hpFreqPrior = -9999.f;
Expand Down

0 comments on commit 687e53a

Please sign in to comment.