Mercurial > hg > svcore
changeset 1576:0f62bce0f0be spectrogramparam
Further adjustments to peak picking, to try to avoid a surfeit of peaks in the higher frequencies
author | Chris Cannam |
---|---|
date | Tue, 13 Nov 2018 13:29:37 +0000 |
parents | 054bbf17ac17 |
children | 50fe6d6a5ef0 |
files | data/model/FFTModel.cpp data/model/FFTModel.h |
diffstat | 2 files changed, 23 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/data/model/FFTModel.cpp Mon Nov 12 14:48:15 2018 +0000 +++ b/data/model/FFTModel.cpp Tue Nov 13 13:29:37 2018 +0000 @@ -431,7 +431,7 @@ sv_samplerate_t sampleRate = getSampleRate(); vector<int> inrange; - float dist = 0.5; + double dist = 0.5; int medianWinSize = getPeakPickWindowSize(type, sampleRate, ymin, dist); int halfWin = medianWinSize/2; @@ -507,9 +507,9 @@ int FFTModel::getPeakPickWindowSize(PeakPickType type, sv_samplerate_t sampleRate, - int bin, float &percentile) const + int bin, double &dist) const { - percentile = 0.5; + dist = 0.5; // dist is percentile / 100.0 if (type == MajorPeaks) return 10; if (bin == 0) return 3; @@ -518,18 +518,33 @@ int hibin = int(lrint((hifreq * m_fftSize) / sampleRate)); int medianWinSize = hibin - bin; + if (medianWinSize < 3) { medianWinSize = 3; } + + // We want to avoid the median window size changing too often, as + // it requires a reallocation. So snap to a nearby round number. + if (medianWinSize > 20) { medianWinSize = (1 + medianWinSize / 10) * 10; } - if (medianWinSize > 500) { - medianWinSize = 500; + if (medianWinSize > 200) { + medianWinSize = (1 + medianWinSize / 100) * 100; + } + if (medianWinSize > 2000) { + medianWinSize = (1 + medianWinSize / 1000) * 1000; + } + if (medianWinSize > 20000) { + medianWinSize = 20000; } - percentile = 0.5f + float(binfreq / sampleRate); - if (percentile > 0.9f) percentile = 0.9f; + if (medianWinSize < 100) { + dist = 1.0 - (4.0 / medianWinSize); + } else { + dist = 1.0 - (8.0 / medianWinSize); + } + if (dist < 0.5) dist = 0.5; return medianWinSize; }
--- a/data/model/FFTModel.h Mon Nov 12 14:48:15 2018 +0000 +++ b/data/model/FFTModel.h Tue Nov 13 13:29:37 2018 +0000 @@ -156,7 +156,7 @@ mutable breakfastquay::FFT m_fft; int getPeakPickWindowSize(PeakPickType type, sv_samplerate_t sampleRate, - int bin, float &percentile) const; + int bin, double &dist) const; std::pair<sv_frame_t, sv_frame_t> getSourceSampleRange(int column) const { sv_frame_t startFrame = m_windowIncrement * sv_frame_t(column);