Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A const-only diff in voice effects #138

Merged
merged 1 commit into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions include/sst/effects-shared/TreemonsterCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ struct TreemonsterCore : public BaseClass
mix.set_blocksize(FXConfig::blockSize);
}

void processWithoutMixOrWith(float *dataL, float *dataR, float *wetL, float *wetR);
void processWithoutMixOrWith(const float *const dataL, const float *const dataR, float *wetL,
float *wetR);

void processWithMixAndWidth(float *dataL, float *dataR)
{
Expand Down Expand Up @@ -168,9 +169,8 @@ inline void TreemonsterCore<BaseClass, BiquadType, addHPLP>::setvars(bool init)
}
}
template <typename BaseClass, typename BiquadType, bool addHPLP>
void TreemonsterCore<BaseClass, BiquadType, addHPLP>::processWithoutMixOrWith(float *dataL,
float *dataR,
float *L, float *R)
void TreemonsterCore<BaseClass, BiquadType, addHPLP>::processWithoutMixOrWith(
const float *const dataL, const float *const dataR, float *L, float *R)
{
static constexpr double MIDI_0_FREQ = 8.17579891564371; // or 440.0 * pow( 2.0, - (69.0/12.0 ) )

Expand Down
15 changes: 8 additions & 7 deletions include/sst/voice-effects/delay/Chorus.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ template <typename VFXConfig> struct Chorus : core::VoiceEffectTemplateBase<VFXC
bool phaseSet = false;

template <typename T>
void stereoImpl(const std::array<T *, 2> &lines, float *datainL, float *datainR,
float *dataoutL, float *dataoutR)
void stereoImpl(const std::array<T *, 2> &lines, const float *const datainL,
const float *const datainR, float *dataoutL, float *dataoutR)
{
namespace mech = sst::basic_blocks::mechanics;
namespace sdsp = sst::basic_blocks::dsp;
Expand Down Expand Up @@ -286,7 +286,7 @@ template <typename VFXConfig> struct Chorus : core::VoiceEffectTemplateBase<VFXC
}
}

template <typename T> void monoImpl(T *line, float *datainL, float *dataoutL)
template <typename T> void monoImpl(T *line, const float *const datainL, float *dataoutL)
{
namespace mech = sst::basic_blocks::mechanics;
namespace sdsp = sst::basic_blocks::dsp;
Expand Down Expand Up @@ -351,8 +351,8 @@ template <typename VFXConfig> struct Chorus : core::VoiceEffectTemplateBase<VFXC
}
}

void processStereo(float *datainL, float *datainR, float *dataoutL, float *dataoutR,
float pitch)
void processStereo(const float *const datainL, const float *const datainR, float *dataoutL,
float *dataoutR, float pitch)
{
if (isShort)
{
Expand All @@ -368,12 +368,13 @@ template <typename VFXConfig> struct Chorus : core::VoiceEffectTemplateBase<VFXC
}
}

void processMonoToStereo(float *datainL, float *dataoutL, float *dataoutR, float pitch)
void processMonoToStereo(const float *const datainL, float *dataoutL, float *dataoutR,
float pitch)
{
processStereo(datainL, datainL, dataoutL, dataoutR, pitch);
}

void processMonoToMono(float *datainL, float *dataoutL, float pitch)
void processMonoToMono(const float *const datainL, float *dataoutL, float pitch)
{
if (isShort)
{
Expand Down
4 changes: 2 additions & 2 deletions include/sst/voice-effects/delay/Microgate.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ template <typename VFXConfig> struct MicroGate : core::VoiceEffectTemplateBase<V

void initVoiceEffectParams() { this->initToParamMetadataDefault(this); }

void processStereo(float *datainL, float *datainR, float *dataoutL, float *dataoutR,
float pitch)
void processStereo(const float *const datainL, const float *const datainR, float *dataoutL,
float *dataoutR, float pitch)
{
namespace mech = sst::basic_blocks::mechanics;

Expand Down
15 changes: 8 additions & 7 deletions include/sst/voice-effects/delay/ShortDelay.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ template <typename VFXConfig> struct ShortDelay : core::VoiceEffectTemplateBase<
void initVoiceEffectParams() { this->initToParamMetadataDefault(this); }

template <typename T>
void stereoImpl(const std::array<T *, 2> &lines, float *datainL, float *datainR,
float *dataoutL, float *dataoutR)
void stereoImpl(const std::array<T *, 2> &lines, const float *const datainL,
const float *const datainR, float *dataoutL, float *dataoutR)
{
namespace mech = sst::basic_blocks::mechanics;
namespace sdsp = sst::basic_blocks::dsp;
Expand Down Expand Up @@ -264,7 +264,7 @@ template <typename VFXConfig> struct ShortDelay : core::VoiceEffectTemplateBase<
}
}

template <typename T> void monoImpl(T *line, float *datainL, float *dataoutL)
template <typename T> void monoImpl(T *line, const float *const datainL, float *dataoutL)
{
namespace mech = sst::basic_blocks::mechanics;
namespace sdsp = sst::basic_blocks::dsp;
Expand Down Expand Up @@ -313,8 +313,8 @@ template <typename VFXConfig> struct ShortDelay : core::VoiceEffectTemplateBase<
}
}

void processStereo(float *datainL, float *datainR, float *dataoutL, float *dataoutR,
float pitch)
void processStereo(const float *const datainL, const float *const datainR, float *dataoutL,
float *dataoutR, float pitch)
{
if (isShort)
{
Expand All @@ -330,7 +330,8 @@ template <typename VFXConfig> struct ShortDelay : core::VoiceEffectTemplateBase<
}
}

void processMonoToStereo(float *datain, float *dataoutL, float *dataoutR, float pitch)
void processMonoToStereo(const float *const datain, float *dataoutL, float *dataoutR,
float pitch)
{
if (isShort)
{
Expand All @@ -346,7 +347,7 @@ template <typename VFXConfig> struct ShortDelay : core::VoiceEffectTemplateBase<
}
}

void processMonoToMono(float *datain, float *dataout, float pitch)
void processMonoToMono(const float *const datain, float *dataout, float pitch)
{
if (isShort)
{
Expand Down
23 changes: 12 additions & 11 deletions include/sst/voice-effects/delay/StringResonator.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ template <typename VFXConfig> struct StringResonator : core::VoiceEffectTemplate
}

template <typename T>
void stereoDualString(const std::array<T *, 2> &lines, float *datainL, float *datainR,
float *dataoutL, float *dataoutR, float pitch)
void stereoDualString(const std::array<T *, 2> &lines, const float *const datainL,
const float *const datainR, float *dataoutL, float *dataoutR, float pitch)
{
namespace mech = sst::basic_blocks::mechanics;
namespace sdsp = sst::basic_blocks::dsp;
Expand Down Expand Up @@ -360,8 +360,8 @@ template <typename VFXConfig> struct StringResonator : core::VoiceEffectTemplate
}

template <typename T>
void stereoSingleString(T *line, float *datainL, float *datainR, float *dataoutL,
float *dataoutR, float pitch)
void stereoSingleString(T *line, const float *const datainL, const float *const datainR,
float *dataoutL, float *dataoutR, float pitch)
{
namespace mech = sst::basic_blocks::mechanics;
namespace sdsp = sst::basic_blocks::dsp;
Expand Down Expand Up @@ -446,8 +446,8 @@ template <typename VFXConfig> struct StringResonator : core::VoiceEffectTemplate
}

template <typename T>
void monoDualString(const std::array<T *, 2> &lines, float *datainL, float *dataoutL,
float pitch)
void monoDualString(const std::array<T *, 2> &lines, const float *const datainL,
float *dataoutL, float pitch)
{
namespace mech = sst::basic_blocks::mechanics;
namespace sdsp = sst::basic_blocks::dsp;
Expand Down Expand Up @@ -529,7 +529,7 @@ template <typename VFXConfig> struct StringResonator : core::VoiceEffectTemplate
}

template <typename T>
void monoSingleString(T *line, float *datainL, float *dataoutL, float pitch)
void monoSingleString(T *line, const float *const datainL, float *dataoutL, float pitch)
{
namespace mech = sst::basic_blocks::mechanics;
namespace sdsp = sst::basic_blocks::dsp;
Expand Down Expand Up @@ -660,8 +660,8 @@ template <typename VFXConfig> struct StringResonator : core::VoiceEffectTemplate
return 0;
}

void processStereo(float *datainL, float *datainR, float *dataoutL, float *dataoutR,
float pitch)
void processStereo(const float *const datainL, const float *const datainR, float *dataoutL,
float *dataoutR, float pitch)
{
if (this->getIntParam(ipDualString == true))
{
Expand Down Expand Up @@ -694,12 +694,13 @@ template <typename VFXConfig> struct StringResonator : core::VoiceEffectTemplate
}
}

void processMonoToStereo(float *datainL, float *dataoutL, float *dataoutR, float pitch)
void processMonoToStereo(const float *const datainL, float *dataoutL, float *dataoutR,
float pitch)
{
processStereo(datainL, datainL, dataoutL, dataoutR, pitch);
}

void processMonoToMono(float *datainL, float *dataoutL, float pitch)
void processMonoToMono(const float *const datainL, float *dataoutL, float pitch)
{
if (this->getIntParam(ipDualString == true))
{
Expand Down
8 changes: 4 additions & 4 deletions include/sst/voice-effects/delay/Widener.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ template <typename VFXConfig> struct Widener : core::VoiceEffectTemplateBase<VFX
void initVoiceEffectParams() { this->initToParamMetadataDefault(this); }

template <typename Line>
void processOntoLine(Line *line, float *datainL, float *datainR, float *dataoutL,
float *dataoutR, float pitch)
void processOntoLine(Line *line, const float *const datainL, const float *const datainR,
float *dataoutL, float *dataoutR, float pitch)
{
namespace mech = sst::basic_blocks::mechanics;
namespace sdsp = sst::basic_blocks::dsp;
Expand Down Expand Up @@ -154,8 +154,8 @@ template <typename VFXConfig> struct Widener : core::VoiceEffectTemplateBase<VFX
sdsp::decodeMS<VFXConfig::blockSize>(mid, side, dataoutL, dataoutR);
}

void processStereo(float *datainL, float *datainR, float *dataoutL, float *dataoutR,
float pitch)
void processStereo(const float *const datainL, const float *const datainR, float *dataoutL,
float *dataoutR, float pitch)
{
if (isShort)
{
Expand Down
4 changes: 2 additions & 2 deletions include/sst/voice-effects/distortion/BitCrusher.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ template <typename VFXConfig> struct BitCrusher : core::VoiceEffectTemplateBase<

void initVoiceEffectParams() { this->initToParamMetadataDefault(this); }

void processStereo(float *datainL, float *datainR, float *dataoutL, float *dataoutR,
float pitch)
void processStereo(const float *const datainL, const float *const datainR, float *dataoutL,
float *dataoutR, float pitch)
{
bool filterSwitch = this->getIntParam(ipFilterSwitch);
int filtMode = this->getIntParam(ipFilterMode);
Expand Down
6 changes: 3 additions & 3 deletions include/sst/voice-effects/distortion/Slewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ template <typename VFXConfig> struct Slewer : core::VoiceEffectTemplateBase<VFXC
}
}

void processStereo(float *datainL, float *datainR, float *dataoutL, float *dataoutR,
float pitch)
void processStereo(const float *const datainL, const float *const datainR, float *dataoutL,
float *dataoutR, float pitch)
{
calc_coeffs();
float rate alignas(16)[VFXConfig::blockSize];
Expand All @@ -144,7 +144,7 @@ template <typename VFXConfig> struct Slewer : core::VoiceEffectTemplateBase<VFXC
bq[1].process_block_to(dataoutL, dataoutR, dataoutL, dataoutR);
}

void processMonoToMono(float *datainL, float *dataoutL, float pitch)
void processMonoToMono(const float *const datainL, float *dataoutL, float pitch)
{
calc_coeffs();
float rate alignas(16)[VFXConfig::blockSize];
Expand Down
4 changes: 2 additions & 2 deletions include/sst/voice-effects/distortion/TreeMonster.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ template <typename VFXConfig> struct TreeMonster : core::VoiceEffectTemplateBase
void initVoiceEffect() { coreProc.initialize(); }
void initVoiceEffectParams() { this->initToParamMetadataDefault(this); }

void processStereo(float *datainL, float *datainR, float *dataoutL, float *dataoutR,
float pitch)
void processStereo(const float *const datainL, const float *const datainR, float *dataoutL,
float *dataoutR, float pitch)
{
coreProc.processWithoutMixOrWith(datainL, datainR, dataoutL, dataoutR);
}
Expand Down
4 changes: 2 additions & 2 deletions include/sst/voice-effects/dynamics/AutoWah.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ template <typename VFXConfig> struct AutoWah : core::VoiceEffectTemplateBase<VFX
R = R - 4.0 / 27.0 * R * R * R;
}

void processStereo(float *datainL, float *datainR, float *dataoutL, float *dataoutR,
float pitch)
void processStereo(const float *const datainL, const float *const datainR, float *dataoutL,
float *dataoutR, float pitch)
{
auto sens = 1 + -1 * this->getFloatParam(fpSens);
sens *= sens;
Expand Down
6 changes: 3 additions & 3 deletions include/sst/voice-effects/dynamics/Compressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ template <typename VFXConfig> struct Compressor : core::VoiceEffectTemplateBase<
return z;
}

void processStereo(float *datainL, float *datainR, float *dataoutL, float *dataoutR,
float pitch)
void processStereo(const float *const datainL, const float *const datainR, float *dataoutL,
float *dataoutR, float pitch)
{
auto makeup = decibelsToAmplitude(this->getFloatParam(fpMakeUp));
gainLerp.set_target(makeup);
Expand Down Expand Up @@ -271,7 +271,7 @@ template <typename VFXConfig> struct Compressor : core::VoiceEffectTemplateBase<
gainLerp.multiply_2_blocks(dataoutL, dataoutR);
}

void processMonoToMono(float *datain, float *dataout, float pitch)
void processMonoToMono(const float *const datain, float *dataout, float pitch)
{
auto makeup = decibelsToAmplitude(this->getFloatParam(fpMakeUp));
gainLerp.set_target(makeup);
Expand Down
12 changes: 6 additions & 6 deletions include/sst/voice-effects/eq/EqGraphic6Band.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ template <typename VFXConfig> struct EqGraphic6Band : core::VoiceEffectTemplateB
void initVoiceEffect() {}
void initVoiceEffectParams() { this->initToParamMetadataDefault(this); }

void processStereo(float *datainL, float *datainR, float *dataoutL, float *dataoutR,
float pitch)
void processStereo(const float *const datainL, const float *const datainR, float *dataoutL,
float *dataoutR, float pitch)
{
calc_coeffs();
float *inL = datainL;
float *inR = datainR;
auto *inL = datainL;
auto *inR = datainR;
for (int i = 0; i < nBands; ++i)
{
mParametric[i].process_block_to(inL, inR, dataoutL, dataoutR);
Expand All @@ -80,10 +80,10 @@ template <typename VFXConfig> struct EqGraphic6Band : core::VoiceEffectTemplateB
}
}

void processMonoToMono(float *datainL, float *dataoutL, float pitch)
void processMonoToMono(const float *const datainL, float *dataoutL, float pitch)
{
calc_coeffs();
float *inL = datainL;
auto *inL = datainL;
for (int i = 0; i < nBands; ++i)
{
mParametric[i].process_block_to(inL, dataoutL);
Expand Down
12 changes: 6 additions & 6 deletions include/sst/voice-effects/eq/EqNBandParametric.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ struct EqNBandParametric : core::VoiceEffectTemplateBase<VFXConfig>
void initVoiceEffect() {}
void initVoiceEffectParams() { this->initToParamMetadataDefault(this); }

void processStereo(float *datainL, float *datainR, float *dataoutL, float *dataoutR,
float pitch)
void processStereo(const float *const datainL, const float *const datainR, float *dataoutL,
float *dataoutR, float pitch)
{
calc_coeffs();
float *inL = datainL;
float *inR = datainR;
auto *inL = datainL;
auto *inR = datainR;
for (int i = 0; i < NBands; ++i)
{
mParametric[i].process_block_to(inL, inR, dataoutL, dataoutR);
Expand All @@ -113,10 +113,10 @@ struct EqNBandParametric : core::VoiceEffectTemplateBase<VFXConfig>
}
}

void processMonoToMono(float *datainL, float *dataoutL, float pitch)
void processMonoToMono(const float *const datainL, float *dataoutL, float pitch)
{
calc_coeffs();
float *inL = datainL;
auto *inL = datainL;
for (int i = 0; i < NBands; ++i)
{
mParametric[i].process_block_to(inL, dataoutL);
Expand Down
6 changes: 3 additions & 3 deletions include/sst/voice-effects/eq/MorphEQ.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ template <typename VFXConfig> struct MorphEQ : core::VoiceEffectTemplateBase<VFX
}
void initVoiceEffectParams() { this->initToParamMetadataDefault(this); }

void processStereo(float *datainL, float *datainR, float *dataoutL, float *dataoutR,
float pitch)
void processStereo(const float *const datainL, const float *const datainR, float *dataoutL,
float *dataoutR, float pitch)
{
calc_coeffs();
gain.multiply_2_blocks_to(datainL, datainR, dataoutL, dataoutR);
Expand All @@ -311,7 +311,7 @@ template <typename VFXConfig> struct MorphEQ : core::VoiceEffectTemplateBase<VFX
}
}

void processMonoToMono(float *datainL, float *dataoutL, float pitch)
void processMonoToMono(const float *const datainL, float *dataoutL, float pitch)
{
calc_coeffs();

Expand Down
6 changes: 3 additions & 3 deletions include/sst/voice-effects/eq/TiltEQ.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ template <typename VFXConfig> struct TiltEQ : core::VoiceEffectTemplateBase<VFXC
}
}

void processStereo(float *datainL, float *datainR, float *dataoutL, float *dataoutR,
float pitch)
void processStereo(const float *const datainL, const float *const datainR, float *dataoutL,
float *dataoutR, float pitch)
{
setCoeffs();
filters[0].template processBlock<VFXConfig::blockSize>(datainL, datainR, dataoutL,
Expand All @@ -107,7 +107,7 @@ template <typename VFXConfig> struct TiltEQ : core::VoiceEffectTemplateBase<VFXC
dataoutR);
}

void processMonoToMono(float *datainL, float *dataoutL, float pitch)
void processMonoToMono(const float *const datainL, float *dataoutL, float pitch)
{
setCoeffs();
filters[0].template processBlock<VFXConfig::blockSize>(datainL, dataoutL);
Expand Down
Loading
Loading