Apply gradual phase-reset on unity in the R2 stretcher (R3 already does this)

This commit is contained in:
Chris Cannam
2022-08-18 16:41:43 +01:00
parent e58c6018c5
commit 53eca719fb
3 changed files with 22 additions and 2 deletions

View File

@@ -87,6 +87,8 @@ R2Stretcher::ChannelData::construct(const std::set<size_t> &sizes,
interpolator = allocate_and_zero<float>(maxSize);
interpolatorScale = 0;
unityResetLow = 16000.f;
for (std::set<size_t>::const_iterator i = sizes.begin();
i != sizes.end(); ++i) {
ffts[*i] = new FFT(*i);

View File

@@ -113,6 +113,7 @@ public:
float *ms; // only used when mid-side processing
float *interpolator; // only used when time-domain smoothing is on
int interpolatorScale;
float unityResetLow; // for gradual phase-reset on unity ratio
float *fltbuf;
process_t *dblbuf; // owned by FFT object, only used for time domain FFT i/o

View File

@@ -744,12 +744,29 @@ R2Stretcher::modifyChunk(size_t channel,
int bandlow = lrint((150 * m_fftSize) / rate);
int bandhigh = lrint((1000 * m_fftSize) / rate);
float r = getEffectiveRatio();
bool unity = (fabsf(r - 1.f) < 1.e-6f);
if (unity) {
if (!phaseReset) {
phaseReset = true;
bandlimited = true;
bandlow = lrint((cd.unityResetLow * m_fftSize) / rate);
bandhigh = count;
if (bandlow > 0) {
m_log.log(2, "unity: bandlow & high", bandlow, bandhigh);
}
}
cd.unityResetLow *= 0.9f;
} else {
cd.unityResetLow = 16000.f;
}
float freq0 = m_freq0;
float freq1 = m_freq1;
float freq2 = m_freq2;
if (laminar) {
float r = getEffectiveRatio();
if (r > 1) {
float rf0 = 600 + (600 * ((r-1)*(r-1)*(r-1)*2));
float f1ratio = freq1 / freq0;