Mercurial > hg > svcore
changeset 246:d7eeffbb8aaf
* Add fuzzy interpolation option as an alternative to zero padding in
spectrogram (looks terrible though)
* Make spectrogram appear more quickly by having the FFT server notify of
updates more often near the start of its run
author | Chris Cannam |
---|---|
date | Mon, 05 Mar 2007 15:32:55 +0000 |
parents | 4cd620bd4c61 |
children | 21b9b25bff48 |
files | base/Preferences.cpp base/Preferences.h data/fft/FFTDataServer.cpp |
diffstat | 3 files changed, 52 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/base/Preferences.cpp Fri Mar 02 14:00:12 2007 +0000 +++ b/base/Preferences.cpp Mon Mar 05 15:32:55 2007 +0000 @@ -35,7 +35,7 @@ } Preferences::Preferences() : - m_smoothSpectrogram(true), + m_spectrogramSmoothing(SpectrogramZeroPadded), m_tuningFrequency(440), m_propertyBoxLayout(VerticallyStacked), m_windowType(HanningWindow), @@ -43,7 +43,8 @@ { QSettings settings; settings.beginGroup("Preferences"); - m_smoothSpectrogram = settings.value("smooth-spectrogram", true).toBool(); + m_spectrogramSmoothing = SpectrogramSmoothing + (settings.value("spectrogram-smoothing", int(m_spectrogramSmoothing)).toInt()); m_tuningFrequency = settings.value("tuning-frequency", 440.f).toDouble(); m_propertyBoxLayout = PropertyBoxLayout (settings.value("property-box-layout", int(VerticallyStacked)).toInt()); @@ -61,7 +62,7 @@ Preferences::getProperties() const { PropertyList props; - props.push_back("Smooth Spectrogram"); + props.push_back("Spectrogram Smoothing"); props.push_back("Tuning Frequency"); props.push_back("Property Box Layout"); props.push_back("Window Type"); @@ -72,8 +73,8 @@ QString Preferences::getPropertyLabel(const PropertyName &name) const { - if (name == "Smooth Spectrogram") { - return tr("Smooth spectrogram display by zero padding FFT"); + if (name == "Spectrogram Smoothing") { + return tr("Spectrogram y-axis smoothing:"); } if (name == "Tuning Frequency") { return tr("Frequency of concert A"); @@ -93,8 +94,8 @@ Preferences::PropertyType Preferences::getPropertyType(const PropertyName &name) const { - if (name == "Smooth Spectrogram") { - return ToggleProperty; + if (name == "Spectrogram Smoothing") { + return ValueProperty; } if (name == "Tuning Frequency") { return RangeProperty; @@ -115,11 +116,11 @@ Preferences::getPropertyRangeAndValue(const PropertyName &name, int *min, int *max, int *deflt) const { - if (name == "Smooth Spectrogram") { + if (name == "Spectrogram Smoothing") { if (min) *min = 0; - if (max) *max = 1; - if (deflt) *deflt = 1; - return m_smoothSpectrogram ? 1 : 0; + if (max) *max = 2; + if (deflt) *deflt = int(SpectrogramZeroPadded); + return int(m_spectrogramSmoothing); } //!!! freq mapping @@ -176,6 +177,14 @@ case 2: return tr("Highest quality"); } } + if (name == "Spectrogram Smoothing") { + switch (value) { + case NoSpectrogramSmoothing: return tr("None - blocky but accurate"); + case SpectrogramInterpolated: return tr("Interpolate - fast but fuzzy"); + case SpectrogramZeroPadded: return tr("Zero pad FFT - slow but clear"); + } + } + return ""; } @@ -194,8 +203,8 @@ void Preferences::setProperty(const PropertyName &name, int value) { - if (name == "Smooth Spectrogram") { - setSmoothSpectrogram(value > 0.1); + if (name == "Spectrogram Smoothing") { + setSpectrogramSmoothing(SpectrogramSmoothing(value)); } else if (name == "Tuning Frequency") { //!!! } else if (name == "Property Box Layout") { @@ -208,15 +217,19 @@ } void -Preferences::setSmoothSpectrogram(bool smooth) +Preferences::setSpectrogramSmoothing(SpectrogramSmoothing smoothing) { - if (m_smoothSpectrogram != smooth) { - m_smoothSpectrogram = smooth; + if (m_spectrogramSmoothing != smoothing) { + + // "smoothing" is one of those words that looks increasingly + // ridiculous the more you see it. Smoothing smoothing smoothing. + m_spectrogramSmoothing = smoothing; + QSettings settings; settings.beginGroup("Preferences"); - settings.setValue("smooth-spectrogram", smooth); + settings.setValue("spectrogram-smoothing", int(smoothing)); settings.endGroup(); - emit propertyChanged("Smooth Spectrogram"); + emit propertyChanged("Spectrogram Smoothing"); } }
--- a/base/Preferences.h Fri Mar 02 14:00:12 2007 +0000 +++ b/base/Preferences.h Mon Mar 05 15:32:55 2007 +0000 @@ -35,7 +35,14 @@ virtual QString getPropertyContainerName() const; virtual QString getPropertyContainerIconName() const; - bool getSmoothSpectrogram() const { return m_smoothSpectrogram; } + enum SpectrogramSmoothing { + NoSpectrogramSmoothing, + SpectrogramInterpolated, + SpectrogramZeroPadded, + SpectrogramZeroPaddedAndInterpolated + }; + + SpectrogramSmoothing getSpectrogramSmoothing() const { return m_spectrogramSmoothing; } float getTuningFrequency() const { return m_tuningFrequency; } WindowType getWindowType() const { return m_windowType; } int getResampleQuality() const { return m_resampleQuality; } @@ -50,7 +57,7 @@ public slots: virtual void setProperty(const PropertyName &, int); - void setSmoothSpectrogram(bool smooth); + void setSpectrogramSmoothing(SpectrogramSmoothing smoothing); void setTuningFrequency(float freq); void setPropertyBoxLayout(PropertyBoxLayout layout); void setWindowType(WindowType type); @@ -62,7 +69,7 @@ static Preferences *m_instance; - bool m_smoothSpectrogram; + SpectrogramSmoothing m_spectrogramSmoothing; float m_tuningFrequency; PropertyBoxLayout m_propertyBoxLayout; WindowType m_windowType;
--- a/data/fft/FFTDataServer.cpp Fri Mar 02 14:00:12 2007 +0000 +++ b/data/fft/FFTDataServer.cpp Mon Mar 05 15:32:55 2007 +0000 @@ -1135,8 +1135,9 @@ size_t remainingEnd = end; int counter = 0; - int updateAt = (end / m_server.m_windowIncrement) / 20; - if (updateAt < 100) updateAt = 100; + int updateAt = 1; + int maxUpdateAt = (end / m_server.m_windowIncrement) / 20; + if (maxUpdateAt < 100) maxUpdateAt = 100; if (m_fillFrom > start) { @@ -1166,6 +1167,10 @@ m_completion = size_t(100 * fabsf(float(f - m_fillFrom) / float(end - start))); counter = 0; + if (updateAt < maxUpdateAt) { + updateAt *= 2; + if (updateAt > maxUpdateAt) updateAt = maxUpdateAt; + } } } @@ -1200,6 +1205,10 @@ size_t(100 * fabsf(float(f - start) / float(end - start))); counter = 0; + if (updateAt < maxUpdateAt) { + updateAt *= 2; + if (updateAt > maxUpdateAt) updateAt = maxUpdateAt; + } } }