Avoid recalculating window scale factor every time
This commit is contained in:
@@ -532,8 +532,6 @@ R3StretcherImpl::analyseChannel(int c, int inhop, int prevInhop, int prevOuthop)
|
|||||||
// where the inhop has changed as above, in which case we need to
|
// where the inhop has changed as above, in which case we need to
|
||||||
// do both readahead and current)
|
// do both readahead and current)
|
||||||
|
|
||||||
v_fftshift(readahead.timeDomain.data(), classify);
|
|
||||||
|
|
||||||
if (haveValidReadahead) {
|
if (haveValidReadahead) {
|
||||||
v_copy(classifyScale->mag.data(),
|
v_copy(classifyScale->mag.data(),
|
||||||
readahead.mag.data(),
|
readahead.mag.data(),
|
||||||
@@ -543,6 +541,7 @@ R3StretcherImpl::analyseChannel(int c, int inhop, int prevInhop, int prevOuthop)
|
|||||||
classifyScale->bufSize);
|
classifyScale->bufSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
v_fftshift(readahead.timeDomain.data(), classify);
|
||||||
m_scaleData.at(classify)->fft.forward(readahead.timeDomain.data(),
|
m_scaleData.at(classify)->fft.forward(readahead.timeDomain.data(),
|
||||||
classifyScale->real.data(),
|
classifyScale->real.data(),
|
||||||
classifyScale->imag.data());
|
classifyScale->imag.data());
|
||||||
@@ -776,18 +775,7 @@ R3StretcherImpl::synthesiseChannel(int c, int outhop)
|
|||||||
auto &scale = cd->scales.at(fftSize);
|
auto &scale = cd->scales.at(fftSize);
|
||||||
auto &scaleData = m_scaleData.at(fftSize);
|
auto &scaleData = m_scaleData.at(fftSize);
|
||||||
|
|
||||||
//!!! messy and slow, but leave it until we've
|
double winscale = double(outhop) / scaleData->windowScaleFactor;
|
||||||
//!!! discovered whether we need a window accumulator
|
|
||||||
//!!! (we probably do)
|
|
||||||
int analysisWindowSize = scaleData->analysisWindow.getSize();
|
|
||||||
int synthesisWindowSize = scaleData->synthesisWindow.getSize();
|
|
||||||
int offset = (analysisWindowSize - synthesisWindowSize) / 2;
|
|
||||||
double winscale = 0.0;
|
|
||||||
for (int i = 0; i < synthesisWindowSize; ++i) {
|
|
||||||
winscale += scaleData->analysisWindow.getValue(i + offset) *
|
|
||||||
scaleData->synthesisWindow.getValue(i);
|
|
||||||
}
|
|
||||||
winscale = double(outhop) / winscale;
|
|
||||||
|
|
||||||
// The frequency filter is applied naively in the frequency
|
// The frequency filter is applied naively in the frequency
|
||||||
// domain. Aliasing is reduced by the shorter resynthesis
|
// domain. Aliasing is reduced by the shorter resynthesis
|
||||||
|
|||||||
@@ -233,6 +233,7 @@ protected:
|
|||||||
FFT fft;
|
FFT fft;
|
||||||
Window<double> analysisWindow;
|
Window<double> analysisWindow;
|
||||||
Window<double> synthesisWindow;
|
Window<double> synthesisWindow;
|
||||||
|
double windowScaleFactor;
|
||||||
GuidedPhaseAdvance guided;
|
GuidedPhaseAdvance guided;
|
||||||
ScaleData(GuidedPhaseAdvance::Parameters guidedParameters) :
|
ScaleData(GuidedPhaseAdvance::Parameters guidedParameters) :
|
||||||
fftSize(guidedParameters.fftSize),
|
fftSize(guidedParameters.fftSize),
|
||||||
@@ -241,7 +242,16 @@ protected:
|
|||||||
analysisWindowLength(fftSize)),
|
analysisWindowLength(fftSize)),
|
||||||
synthesisWindow(synthesisWindowShape(fftSize),
|
synthesisWindow(synthesisWindowShape(fftSize),
|
||||||
synthesisWindowLength(fftSize)),
|
synthesisWindowLength(fftSize)),
|
||||||
guided(guidedParameters) { }
|
guided(guidedParameters),
|
||||||
|
windowScaleFactor(0.0)
|
||||||
|
{
|
||||||
|
int asz = analysisWindow.getSize(), ssz = synthesisWindow.getSize();
|
||||||
|
int off = (asz - ssz) / 2;
|
||||||
|
for (int i = 0; i < ssz; ++i) {
|
||||||
|
windowScaleFactor += analysisWindow.getValue(i + off) *
|
||||||
|
synthesisWindow.getValue(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
WindowType analysisWindowShape(int fftSize);
|
WindowType analysisWindowShape(int fftSize);
|
||||||
int analysisWindowLength(int fftSize);
|
int analysisWindowLength(int fftSize);
|
||||||
|
|||||||
Reference in New Issue
Block a user