Tidy, and format comments

This commit is contained in:
Chris Cannam
2022-05-25 16:25:03 +01:00
parent 4c878340df
commit fa004562f7
2 changed files with 40 additions and 38 deletions

View File

@@ -48,18 +48,23 @@ public:
GuidedPhaseAdvance(Parameters parameters) : GuidedPhaseAdvance(Parameters parameters) :
m_parameters(parameters), m_parameters(parameters),
m_blockSize(parameters.fftSize / 2 + 1), m_binCount(parameters.fftSize / 2 + 1),
m_peakPicker(m_blockSize), m_peakPicker(m_binCount),
m_reported(false) { m_reported(false) {
size_t ch = m_parameters.channels; size_t ch = m_parameters.channels;
m_currentPeaks = allocate_and_zero_channels<int>(ch, m_blockSize); m_currentPeaks = allocate_and_zero_channels<int>(ch, m_binCount);
m_prevPeaks = allocate_and_zero_channels<int>(ch, m_blockSize); m_prevPeaks = allocate_and_zero_channels<int>(ch, m_binCount);
m_greatestChannel = allocate_and_zero<int>(m_blockSize); m_greatestChannel = allocate_and_zero<int>(m_binCount);
//!!! there is also a prevMag in R3StretcherImpl which could be passed in to here instead m_prevInMag = allocate_and_zero_channels<double>(ch, m_binCount);
m_prevInMag = allocate_and_zero_channels<double>(ch, m_blockSize); m_prevInPhase = allocate_and_zero_channels<double>(ch, m_binCount);
m_prevInPhase = allocate_and_zero_channels<double>(ch, m_blockSize); m_prevOutPhase = allocate_and_zero_channels<double>(ch, m_binCount);
m_prevOutPhase = allocate_and_zero_channels<double>(ch, m_blockSize); m_unlocked = allocate_and_zero_channels<double>(ch, m_binCount);
m_unlocked = allocate_and_zero_channels<double>(ch, m_blockSize);
for (int c = 0; c < ch; ++c) {
for (int i = 0; i < m_binCount; ++i) {
m_prevPeaks[c][i] = i;
}
}
} }
~GuidedPhaseAdvance() { ~GuidedPhaseAdvance() {
@@ -221,7 +226,7 @@ public:
protected: protected:
Parameters m_parameters; Parameters m_parameters;
int m_blockSize; int m_binCount;
Peak<double> m_peakPicker; Peak<double> m_peakPicker;
int **m_currentPeaks; int **m_currentPeaks;
int **m_prevPeaks; int **m_prevPeaks;

View File

@@ -371,12 +371,12 @@ R3StretcherImpl::analyseChannel(int c, int inhop, int prevOuthop)
cd->inbuf->peek(buf, longest); cd->inbuf->peek(buf, longest);
} }
// We have a single unwindowed frame at the longest FFT // We have a single unwindowed frame at the longest FFT size
// size ("scale"). Populate the shorter FFT sizes from the // ("scale"). Populate the shorter FFT sizes from the centre of
// centre of it, windowing as we copy. The classification // it, windowing as we copy. The classification scale is handled
// scale is handled separately because it has readahead, // separately because it has readahead, so skip it here as well as
// so skip it here as well as the longest. (In practice // the longest. (In practice this means we are probably only
// this means we are probably only populating one scale) // populating one scale)
for (auto &it: cd->scales) { for (auto &it: cd->scales) {
int fftSize = it.first; int fftSize = it.first;
@@ -406,10 +406,9 @@ R3StretcherImpl::analyseChannel(int c, int inhop, int prevOuthop)
// FFT shift, forward FFT, and carry out cartesian-polar // FFT shift, forward FFT, and carry out cartesian-polar
// conversion for each FFT size. // conversion for each FFT size.
// For the classification scale we need magnitudes for the // For the classification scale we need magnitudes for the full
// full range (polar only in a subset) and we operate in // range (polar only in a subset) and we operate in the readahead,
// the readahead, pulling current values from the existing // pulling current values from the existing readahead
// readahead
v_fftshift(readahead.timeDomain.data(), classify); v_fftshift(readahead.timeDomain.data(), classify);
@@ -455,8 +454,8 @@ R3StretcherImpl::analyseChannel(int c, int inhop, int prevOuthop)
} }
} }
// For the others we operate directly in the scale data // For the others we operate directly in the scale data and
// and restrict the range for cartesian-polar conversion // restrict the range for cartesian-polar conversion
for (auto &it: cd->scales) { for (auto &it: cd->scales) {
int fftSize = it.first; int fftSize = it.first;
@@ -485,9 +484,8 @@ R3StretcherImpl::analyseChannel(int c, int inhop, int prevOuthop)
} }
} }
// Use the classification scale to get a bin segmentation // Use the classification scale to get a bin segmentation and
// and calculate the adaptive frequency guide for this // calculate the adaptive frequency guide for this channel
// channel
cd->prevSegmentation = cd->segmentation; cd->prevSegmentation = cd->segmentation;
cd->segmentation = cd->nextSegmentation; cd->segmentation = cd->nextSegmentation;
cd->nextSegmentation = cd->segmenter->segment(readahead.mag.data()); cd->nextSegmentation = cd->segmenter->segment(readahead.mag.data());
@@ -541,9 +539,9 @@ R3StretcherImpl::synthesiseChannel(int c, int outhop)
} }
winscale = double(outhop) / winscale; winscale = double(outhop) / winscale;
// The frequency filter is applied naively in the // The frequency filter is applied naively in the frequency
// frequency domain. Aliasing is reduced by the // domain. Aliasing is reduced by the shorter resynthesis
// shorter resynthesis window // window
double factor = m_parameters.sampleRate / double(fftSize); double factor = m_parameters.sampleRate / double(fftSize);
for (int i = 0; i < fftSize/2 + 1; ++i) { for (int i = 0; i < fftSize/2 + 1; ++i) {
@@ -557,9 +555,9 @@ R3StretcherImpl::synthesiseChannel(int c, int outhop)
} }
} }
// Resynthesise each FFT size (scale) individually, then // Resynthesise each FFT size (scale) individually, then sum. This
// sum. This is easier to manage scaling for in situations // is easier to manage scaling for in situations with a varying
// with a varying resynthesis hop // resynthesis hop
for (auto &it : cd->scales) { for (auto &it : cd->scales) {
int fftSize = it.first; int fftSize = it.first;
@@ -587,12 +585,11 @@ R3StretcherImpl::synthesiseChannel(int c, int outhop)
v_fftshift(scale->timeDomain.data(), fftSize); v_fftshift(scale->timeDomain.data(), fftSize);
// Synthesis window is shorter than analysis window, // Synthesis window may be shorter than analysis window, so
// so copy and cut only from the middle of the // copy and cut only from the middle of the time-domain frame;
// time-domain frame; and the accumulator length // and the accumulator length always matches the longest FFT
// always matches the longest FFT size, so as to make // size, so as to make mixing straightforward, so there is an
// mixing straightforward, so there is an additional // additional offset needed for the target
// offset needed for the target
int synthesisWindowSize = scaleData->synthesisWindow.getSize(); int synthesisWindowSize = scaleData->synthesisWindow.getSize();
int fromOffset = (fftSize - synthesisWindowSize) / 2; int fromOffset = (fftSize - synthesisWindowSize) / 2;