Fix bad Granular Pitch Shifter init values (#7354)

This commit is contained in:
Lost Robot
2024-06-27 00:18:24 -05:00
committed by GitHub
parent 9a0db6a17c
commit f2fbcecc50
2 changed files with 12 additions and 5 deletions

View File

@@ -96,8 +96,8 @@ bool GranularPitchShifterEffect::processAudioBuffer(sampleFrame* buf, const fpp_
for (fpp_t f = 0; f < frames; ++f)
{
const double pitch = pitchBuf ? pitchBuf->value(f) : m_granularpitchshifterControls.m_pitchModel.value();
const double pitchSpread = (pitchSpreadBuf ? pitchSpreadBuf->value(f) : m_granularpitchshifterControls.m_pitchSpreadModel.value()) * 0.5f;
const double pitch = (pitchBuf ? pitchBuf->value(f) : m_granularpitchshifterControls.m_pitchModel.value()) * (1. / 12.);
const double pitchSpread = (pitchSpreadBuf ? pitchSpreadBuf->value(f) : m_granularpitchshifterControls.m_pitchSpreadModel.value()) * (1. / 24.);
// interpolate pitch depending on glide
for (int i = 0; i < 2; ++i)
@@ -118,8 +118,8 @@ bool GranularPitchShifterEffect::processAudioBuffer(sampleFrame* buf, const fpp_
m_updatePitches = false;
std::array<double, 2> speed = {
std::exp2(m_truePitch[0] * (1. / 12.)),
std::exp2(m_truePitch[1] * (1. / 12.))
std::exp2(m_truePitch[0]),
std::exp2(m_truePitch[1])
};
std::array<double, 2> ratio = {
speed[0] / m_speed[0],
@@ -274,6 +274,13 @@ void GranularPitchShifterEffect::changeSampleRate()
m_grains.reserve(8);// arbitrary
m_dcCoeff = std::exp(-2.0 * F_PI * DcRemovalHz / m_sampleRate);
const double pitch = m_granularpitchshifterControls.m_pitchModel.value() * (1. / 12.);
const double pitchSpread = m_granularpitchshifterControls.m_pitchSpreadModel.value() * (1. / 24.);
m_truePitch[0] = pitch - pitchSpread;
m_truePitch[1] = pitch + pitchSpread;
m_speed[0] = std::exp2(m_truePitch[0]);
m_speed[1] = std::exp2(m_truePitch[1]);
}

View File

@@ -168,7 +168,7 @@ private:
int m_ringBufLength = 0;
int m_writePoint = 0;
int m_grainCount = 0;
int m_timeSinceLastGrain = 0;
int m_timeSinceLastGrain = 999999999;
double m_oldGlide = -1;
double m_glideCoef = 0;