# HG changeset patch # User Chris Cannam # Date 1542034095 0 # Node ID 054bbf17ac17bf6e604b38fa4ed9871d8675e002 # Parent cfcfec216c214aa5bbc35684cee983ae1a62b6dc Slightly simplify median-window size calculation - but this is not the best way to do this for spectrum views, need to reconsider diff -r cfcfec216c21 -r 054bbf17ac17 data/model/FFTModel.cpp --- a/data/model/FFTModel.cpp Fri Nov 09 15:22:01 2018 +0000 +++ b/data/model/FFTModel.cpp Mon Nov 12 14:48:15 2018 +0000 @@ -389,7 +389,7 @@ FFTModel::getPeaks(PeakPickType type, int x, int ymin, int ymax) const { Profiler profiler("FFTModel::getPeaks"); - + FFTModel::PeakLocationSet peaks; if (!isOK()) return peaks; @@ -518,10 +518,19 @@ int hibin = int(lrint((hifreq * m_fftSize) / sampleRate)); int medianWinSize = hibin - bin; - if (medianWinSize < 3) medianWinSize = 3; + if (medianWinSize < 3) { + medianWinSize = 3; + } + if (medianWinSize > 20) { + medianWinSize = (1 + medianWinSize / 10) * 10; + } + if (medianWinSize > 500) { + medianWinSize = 500; + } percentile = 0.5f + float(binfreq / sampleRate); - + if (percentile > 0.9f) percentile = 0.9f; + return medianWinSize; }