Skip to content

Commit

Permalink
Change to transpose processing order
Browse files Browse the repository at this point in the history
Turned `std::array<X, N> cmp;`  into `ParallelX`. Sometimes this brings speed up, but it wasn't this time.
  • Loading branch information
ryukau committed Jul 23, 2023
1 parent f65e68a commit ce50fe9
Show file tree
Hide file tree
Showing 8 changed files with 332 additions and 214 deletions.
34 changes: 8 additions & 26 deletions GrowlSynth/source/dsp/dspcore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ void DSPCore::setup(double sampleRate)
SmootherCommon<double>::setTime(smoothingTimeSecond);

for (auto &x : blitFormant.lpComb) x.setup(upRate, double(1));
spreadDelay.setup(upRate, double(Scales::maxTimeSpreadSamples.getMax()));
for (auto &x : modComb) {
x.setup(upRate, double(0.5));
}
modComb.setup(upRate, double(0.5), double(Scales::maxTimeSpreadSeconds.getMax()));

reset();
startup();
Expand Down Expand Up @@ -107,21 +104,11 @@ void DSPCore::setup(double sampleRate)
const auto combFeedbackGain = pv[ID::combFeedbackGain]->getDouble(); \
const auto combDelayTimeMod = std::exp2(pv[ID::combDelayTimeMod]->getDouble()); \
const auto combDelayTimeSlewRate = pv[ID::combDelayTimeSlewRate]->getDouble(); \
const auto maxTimeSpreadSamples = upRate * pv[ID::maxTimeSpreadSamples]->getDouble(); \
for (size_t idx = 0; idx < modComb.size(); ++idx) { \
modComb[idx].METHOD( \
modCombScaler.lowpassCut[idx] * combLowpassHz, \
modCombScaler.highpassCut[idx] * combHighpassHz, \
modCombScaler.allpassCut[idx] * combAllpassCut, combAllpassMod, \
modCombScaler.allpassQ[idx] * combAllpassQ, combEnergyLossThreshold, \
modCombScaler.combSamples[idx] * combSamples, \
modCombScaler.combFeedbaackGain[idx] * combFeedbackGain, combDelayTimeMod, \
combDelayTimeSlewRate); \
} \
for (size_t idx = 0; idx < spreadDelay.size(); ++idx) { \
spreadDelay.timeInSamples.METHOD##At( \
idx, modCombScaler.timeSpread[idx] * maxTimeSpreadSamples); \
}
const auto maxTimeSpreadSamples = upRate * pv[ID::maxTimeSpreadSeconds]->getDouble(); \
modComb.METHOD( \
modCombScaler, combLowpassHz, combHighpassHz, combAllpassCut, combAllpassMod, \
combAllpassQ, combEnergyLossThreshold, combSamples, combFeedbackGain, \
combDelayTimeMod, combDelayTimeSlewRate, maxTimeSpreadSamples);

void DSPCore::reset()
{
Expand All @@ -138,7 +125,6 @@ void DSPCore::reset()
blitOsc.reset();
breathFormant.reset();
modCombScaler.reset();
spreadDelay.reset();
ASSIGN_MOD_COMB_PARAMETER(reset);
noteGate.reset();
halfbandIir.reset();
Expand Down Expand Up @@ -186,15 +172,11 @@ double DSPCore::processSample()
envAm * breathGain.getValue() * breathNoise.process(pulsePitchRatio * frequency),
std::exp2(pulseBendOctave.getValue() * envOut) * breathFormantOctave.getValue());

spreadDelay.process(s0 + noise);
auto fbMod = std::lerp(double(1), envOut, combFeedbackFollowEnvelope.getValue());
auto combInvPitchRatio
= double(1) / std::lerp(double(1), interpPitch.getValue(), combFollowNote.getValue());
for (size_t idx = 0; idx < nModDelay; ++idx) {
spreadDelay.output[idx]
= modComb[idx].process(spreadDelay.output[idx], combInvPitchRatio, -envAm, fbMod);
}
return outputGain.getValue() * noteGate.process() * spreadDelay.sum();
auto sig = modComb.process(s0 + noise, combInvPitchRatio, -envAm, fbMod);
return outputGain.getValue() * noteGate.process() * sig;
}

void DSPCore::process(const size_t length, float *out0, float *out1)
Expand Down
3 changes: 1 addition & 2 deletions GrowlSynth/source/dsp/dspcore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ class DSPCore {
EnvelopedNoise<double> breathNoise;
NoiseFormant<double, decltype(formantRng)> breathFormant;
ModCombScaler<double, decltype(rng), nModDelay> modCombScaler;
MultiTapDelay<double, nModDelay> spreadDelay;
std::array<ModComb<double>, nModDelay> modComb;
ParallelModComb<double, decltype(formantRng), nModDelay> modComb;
NoteGate<double> noteGate;
HalfBandIIR<double, HalfBandCoefficient<double>> halfbandIir;
SVFHighpass<double> safetyHighpass;
Expand Down
Loading

0 comments on commit ce50fe9

Please sign in to comment.