Skip to content

Commit

Permalink
clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreya-Autumn committed May 30, 2024
1 parent a0978f4 commit 9b585c6
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 67 deletions.
65 changes: 30 additions & 35 deletions include/sst/voice-effects/delay/ShortDelay.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ template <typename VFXConfig> struct ShortDelay : core::VoiceEffectTemplateBase<
fpLowCut,
fpHighCut
};

enum IntParams
{
ipStereo
};

ShortDelay(const SincTable &st)
: sSincTable(st), core::VoiceEffectTemplateBase<VFXConfig>(), lp(this), hp(this)
{
Expand Down Expand Up @@ -120,7 +120,7 @@ template <typename VFXConfig> struct ShortDelay : core::VoiceEffectTemplateBase<
}
return pmd().withName("Error");
}

basic_blocks::params::ParamMetaData intParamAt(int idx) const
{
using pmd = basic_blocks::params::ParamMetaData;
Expand Down Expand Up @@ -165,36 +165,32 @@ template <typename VFXConfig> struct ShortDelay : core::VoiceEffectTemplateBase<

template <typename T>
void stereoImpl(const std::array<T *, 2> &lines, float *datainL, float *datainR,
float *dataoutL, float *dataoutR)
float *dataoutL, float *dataoutR)
{
namespace mech = sst::basic_blocks::mechanics;
namespace sdsp = sst::basic_blocks::dsp;
auto stereoSwitch = this->getIntParam(ipStereo);

mech::copy_from_to<VFXConfig::blockSize>(datainL, dataoutL);
mech::copy_from_to<VFXConfig::blockSize>(datainR, dataoutR);
float FIRipol = static_cast<float>(SincTable::FIRipol_N);

auto timeL = this->getFloatParam(fpTimeL);
auto timeR = (stereoSwitch) ? this->getFloatParam(fpTimeR) : timeL;

lipolDelay[0].set_target(
std::max((std::clamp(timeL, 0.f, maxMiliseconds) *
this->getSampleRate() / 1000.f),
FIRipol));
lipolDelay[1].set_target(
std::max((std::clamp(timeR, 0.f, maxMiliseconds) *
this->getSampleRate() / 1000.f),
FIRipol));

lipolDelay[0].set_target(std::max(
(std::clamp(timeL, 0.f, maxMiliseconds) * this->getSampleRate() / 1000.f), FIRipol));
lipolDelay[1].set_target(std::max(
(std::clamp(timeR, 0.f, maxMiliseconds) * this->getSampleRate() / 1000.f), FIRipol));

float ld alignas(16)[2][VFXConfig::blockSize];
lipolDelay[0].store_block(ld[0]);
lipolDelay[1].store_block(ld[1]);

lipolFb.set_target(std::clamp(this->getFloatParam(fpFeedback), 0.f, 1.f));
float feedback alignas(16)[VFXConfig::blockSize];
lipolFb.store_block(feedback);

lipolCross.set_target(std::clamp(this->getFloatParam(fpCrossFeed), 0.f, 1.f));
float crossfeed alignas(16)[VFXConfig::blockSize];
lipolCross.store_block(crossfeed);
Expand All @@ -215,11 +211,11 @@ template <typename VFXConfig> struct ShortDelay : core::VoiceEffectTemplateBase<

auto fbc0 = feedback[i] * dataoutL[i];
auto fbc1 = feedback[i] * dataoutR[i];

if (stereoSwitch)
{
fbc0 += crossfeed[i] * dataoutR[i];
fbc1 += crossfeed[i] * dataoutL[i];
fbc0 += crossfeed[i] * dataoutR[i];
fbc1 += crossfeed[i] * dataoutL[i];
}

// soft clip for now
Expand All @@ -233,9 +229,8 @@ template <typename VFXConfig> struct ShortDelay : core::VoiceEffectTemplateBase<
lines[1]->write(datainR[i] + fbc1);
}
}

template <typename T>
void monoImpl(T *line, float *datainL, float *dataoutL)

template <typename T> void monoImpl(T *line, float *datainL, float *dataoutL)
{
namespace mech = sst::basic_blocks::mechanics;
namespace sdsp = sst::basic_blocks::dsp;
Expand Down Expand Up @@ -284,33 +279,33 @@ template <typename VFXConfig> struct ShortDelay : core::VoiceEffectTemplateBase<
if (isShort)
{
stereoImpl(std::array{lineSupport[0].template getLinePointer<shortLineSize>(),
lineSupport[1].template getLinePointer<shortLineSize>()},
datainL, datainR, dataoutL, dataoutR);
lineSupport[1].template getLinePointer<shortLineSize>()},
datainL, datainR, dataoutL, dataoutR);
}
else
{
stereoImpl(std::array{lineSupport[0].template getLinePointer<longLineSize>(),
lineSupport[1].template getLinePointer<longLineSize>()},
datainL, datainR, dataoutL, dataoutR);
lineSupport[1].template getLinePointer<longLineSize>()},
datainL, datainR, dataoutL, dataoutR);
}
}

void processMonoToStereo(float *datain, float *dataoutL, float *dataoutR, float pitch)
{
if (isShort)
{
stereoImpl(std::array{lineSupport[0].template getLinePointer<shortLineSize>(),
lineSupport[1].template getLinePointer<shortLineSize>()},
datain, datain, dataoutL, dataoutR);
lineSupport[1].template getLinePointer<shortLineSize>()},
datain, datain, dataoutL, dataoutR);
}
else
{
stereoImpl(std::array{lineSupport[0].template getLinePointer<longLineSize>(),
lineSupport[1].template getLinePointer<longLineSize>()},
datain, datain, dataoutL, dataoutR);
lineSupport[1].template getLinePointer<longLineSize>()},
datain, datain, dataoutL, dataoutR);
}
}

void processMonoToMono(float *datain, float *dataout, float pitch)
{
if (isShort)
Expand All @@ -322,9 +317,9 @@ template <typename VFXConfig> struct ShortDelay : core::VoiceEffectTemplateBase<
monoImpl(lineSupport[0].template getLinePointer<shortLineSize>(), datain, dataout);
}
}

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

protected:
std::array<details::DelayLineSupport, 2> lineSupport;
bool isShort{true};
Expand Down
62 changes: 30 additions & 32 deletions include/sst/voice-effects/filter/CytomicSVF.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,21 @@ template <typename VFXConfig> struct CytomicSVF : core::VoiceEffectTemplateBase<
}

~CytomicSVF() {}

enum floatParams
{
fpFreqL,
fpFreqR,
fpResonance,
fpShelf,
};

enum intParams
{
ipMode,
ipStereo
};

basic_blocks::params::ParamMetaData paramAt(int idx) const
{
using pmd = basic_blocks::params::ParamMetaData;
Expand All @@ -79,7 +79,7 @@ template <typename VFXConfig> struct CytomicSVF : core::VoiceEffectTemplateBase<
.withLinearScaleFormatting("semitones");
}
return pmd().asAudibleFrequency().withName("Cutoff (L)").withDefault(0);

case 1:
if (keytrackOn)
{
Expand Down Expand Up @@ -112,33 +112,32 @@ template <typename VFXConfig> struct CytomicSVF : core::VoiceEffectTemplateBase<
using md = sst::filters::CytomicSVF::Mode;
switch (idx)
{
case ipMode:
return pmd()
.asInt()
.withRange(0, 8)
.withName("Mode")
.withUnorderedMapFormatting({
{md::LP, "Low Pass"},
{md::HP, "High Pass"},
{md::BP, "Band Pass"},
{md::NOTCH, "Notch"},
{md::PEAK, "Peak"},
{md::ALL, "All Pass"},
{md::BELL, "Bell"},
{md::LOW_SHELF, "Low Shelf"},
{md::HIGH_SHELF, "High Shelf"},
})
.withDefault(md::LP);
case ipMode:
return pmd()
.asInt()
.withRange(0, 8)
.withName("Mode")
.withUnorderedMapFormatting({
{md::LP, "Low Pass"},
{md::HP, "High Pass"},
{md::BP, "Band Pass"},
{md::NOTCH, "Notch"},
{md::PEAK, "Peak"},
{md::ALL, "All Pass"},
{md::BELL, "Bell"},
{md::LOW_SHELF, "Low Shelf"},
{md::HIGH_SHELF, "High Shelf"},
})
.withDefault(md::LP);
case ipStereo:
return pmd().asBool().withDefault(false).withName("Stereo");
}
return pmd().withName("error");

}

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

void calc_coeffs(float pitch = 0.f)
{
std::array<float, numFloatParams> param;
Expand Down Expand Up @@ -169,21 +168,21 @@ template <typename VFXConfig> struct CytomicSVF : core::VoiceEffectTemplateBase<
}
auto mode = (sst::filters::CytomicSVF::Mode)(iparam[0]);


auto res = std::clamp(param[2], 0.f, 1.f);
auto shelf = this->dbToLinear(param[3]);

if (this->getIntParam(ipStereo))
{
auto freqL = 440.0 * this->note_to_pitch_ignoring_tuning(param[0]);
auto freqR = 440.0 * this->note_to_pitch_ignoring_tuning(param[1]);
cySvf.setCoeffForBlock<VFXConfig::blockSize>(mode, freqL, freqR, res, res, this->getSampleRateInv(), shelf, shelf);
cySvf.setCoeffForBlock<VFXConfig::blockSize>(
mode, freqL, freqR, res, res, this->getSampleRateInv(), shelf, shelf);
}
else
{
auto freq = 440.0 * this->note_to_pitch_ignoring_tuning(param[0]);
cySvf.setCoeffForBlock<VFXConfig::blockSize>(mode, freq, res, this->getSampleRateInv(),
shelf);
cySvf.setCoeffForBlock<VFXConfig::blockSize>(mode, freq, res,
this->getSampleRateInv(), shelf);
}

mLastParam = param;
Expand All @@ -207,14 +206,13 @@ template <typename VFXConfig> struct CytomicSVF : core::VoiceEffectTemplateBase<
calc_coeffs(pitch);
cySvf.processBlock<VFXConfig::blockSize>(datainL, dataoutL);
}

void processMonoToStereo(float *datainL, float *dataoutL, float *dataoutR,
float pitch)

void processMonoToStereo(float *datainL, float *dataoutL, float *dataoutR, float pitch)
{
calc_coeffs(pitch);
cySvf.processBlock<VFXConfig::blockSize>(datainL, datainL, dataoutL, dataoutR);
}

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

bool enableKeytrack(bool b)
Expand Down

0 comments on commit 9b585c6

Please sign in to comment.