Mercurial > hg > svcore
comparison base/Preferences.cpp @ 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 | 3b8008d09541 |
comparison
equal
deleted
inserted
replaced
245:4cd620bd4c61 | 246:d7eeffbb8aaf |
---|---|
33 if (!m_instance) m_instance = new Preferences(); | 33 if (!m_instance) m_instance = new Preferences(); |
34 return m_instance; | 34 return m_instance; |
35 } | 35 } |
36 | 36 |
37 Preferences::Preferences() : | 37 Preferences::Preferences() : |
38 m_smoothSpectrogram(true), | 38 m_spectrogramSmoothing(SpectrogramZeroPadded), |
39 m_tuningFrequency(440), | 39 m_tuningFrequency(440), |
40 m_propertyBoxLayout(VerticallyStacked), | 40 m_propertyBoxLayout(VerticallyStacked), |
41 m_windowType(HanningWindow), | 41 m_windowType(HanningWindow), |
42 m_resampleQuality(1) | 42 m_resampleQuality(1) |
43 { | 43 { |
44 QSettings settings; | 44 QSettings settings; |
45 settings.beginGroup("Preferences"); | 45 settings.beginGroup("Preferences"); |
46 m_smoothSpectrogram = settings.value("smooth-spectrogram", true).toBool(); | 46 m_spectrogramSmoothing = SpectrogramSmoothing |
47 (settings.value("spectrogram-smoothing", int(m_spectrogramSmoothing)).toInt()); | |
47 m_tuningFrequency = settings.value("tuning-frequency", 440.f).toDouble(); | 48 m_tuningFrequency = settings.value("tuning-frequency", 440.f).toDouble(); |
48 m_propertyBoxLayout = PropertyBoxLayout | 49 m_propertyBoxLayout = PropertyBoxLayout |
49 (settings.value("property-box-layout", int(VerticallyStacked)).toInt()); | 50 (settings.value("property-box-layout", int(VerticallyStacked)).toInt()); |
50 m_windowType = WindowType | 51 m_windowType = WindowType |
51 (settings.value("window-type", int(HanningWindow)).toInt()); | 52 (settings.value("window-type", int(HanningWindow)).toInt()); |
59 | 60 |
60 Preferences::PropertyList | 61 Preferences::PropertyList |
61 Preferences::getProperties() const | 62 Preferences::getProperties() const |
62 { | 63 { |
63 PropertyList props; | 64 PropertyList props; |
64 props.push_back("Smooth Spectrogram"); | 65 props.push_back("Spectrogram Smoothing"); |
65 props.push_back("Tuning Frequency"); | 66 props.push_back("Tuning Frequency"); |
66 props.push_back("Property Box Layout"); | 67 props.push_back("Property Box Layout"); |
67 props.push_back("Window Type"); | 68 props.push_back("Window Type"); |
68 props.push_back("Resample Quality"); | 69 props.push_back("Resample Quality"); |
69 return props; | 70 return props; |
70 } | 71 } |
71 | 72 |
72 QString | 73 QString |
73 Preferences::getPropertyLabel(const PropertyName &name) const | 74 Preferences::getPropertyLabel(const PropertyName &name) const |
74 { | 75 { |
75 if (name == "Smooth Spectrogram") { | 76 if (name == "Spectrogram Smoothing") { |
76 return tr("Smooth spectrogram display by zero padding FFT"); | 77 return tr("Spectrogram y-axis smoothing:"); |
77 } | 78 } |
78 if (name == "Tuning Frequency") { | 79 if (name == "Tuning Frequency") { |
79 return tr("Frequency of concert A"); | 80 return tr("Frequency of concert A"); |
80 } | 81 } |
81 if (name == "Property Box Layout") { | 82 if (name == "Property Box Layout") { |
91 } | 92 } |
92 | 93 |
93 Preferences::PropertyType | 94 Preferences::PropertyType |
94 Preferences::getPropertyType(const PropertyName &name) const | 95 Preferences::getPropertyType(const PropertyName &name) const |
95 { | 96 { |
96 if (name == "Smooth Spectrogram") { | 97 if (name == "Spectrogram Smoothing") { |
97 return ToggleProperty; | 98 return ValueProperty; |
98 } | 99 } |
99 if (name == "Tuning Frequency") { | 100 if (name == "Tuning Frequency") { |
100 return RangeProperty; | 101 return RangeProperty; |
101 } | 102 } |
102 if (name == "Property Box Layout") { | 103 if (name == "Property Box Layout") { |
113 | 114 |
114 int | 115 int |
115 Preferences::getPropertyRangeAndValue(const PropertyName &name, | 116 Preferences::getPropertyRangeAndValue(const PropertyName &name, |
116 int *min, int *max, int *deflt) const | 117 int *min, int *max, int *deflt) const |
117 { | 118 { |
118 if (name == "Smooth Spectrogram") { | 119 if (name == "Spectrogram Smoothing") { |
119 if (min) *min = 0; | 120 if (min) *min = 0; |
120 if (max) *max = 1; | 121 if (max) *max = 2; |
121 if (deflt) *deflt = 1; | 122 if (deflt) *deflt = int(SpectrogramZeroPadded); |
122 return m_smoothSpectrogram ? 1 : 0; | 123 return int(m_spectrogramSmoothing); |
123 } | 124 } |
124 | 125 |
125 //!!! freq mapping | 126 //!!! freq mapping |
126 | 127 |
127 if (name == "Property Box Layout") { | 128 if (name == "Property Box Layout") { |
174 case 0: return tr("Fastest"); | 175 case 0: return tr("Fastest"); |
175 case 1: return tr("Standard"); | 176 case 1: return tr("Standard"); |
176 case 2: return tr("Highest quality"); | 177 case 2: return tr("Highest quality"); |
177 } | 178 } |
178 } | 179 } |
180 if (name == "Spectrogram Smoothing") { | |
181 switch (value) { | |
182 case NoSpectrogramSmoothing: return tr("None - blocky but accurate"); | |
183 case SpectrogramInterpolated: return tr("Interpolate - fast but fuzzy"); | |
184 case SpectrogramZeroPadded: return tr("Zero pad FFT - slow but clear"); | |
185 } | |
186 } | |
187 | |
179 return ""; | 188 return ""; |
180 } | 189 } |
181 | 190 |
182 QString | 191 QString |
183 Preferences::getPropertyContainerName() const | 192 Preferences::getPropertyContainerName() const |
192 } | 201 } |
193 | 202 |
194 void | 203 void |
195 Preferences::setProperty(const PropertyName &name, int value) | 204 Preferences::setProperty(const PropertyName &name, int value) |
196 { | 205 { |
197 if (name == "Smooth Spectrogram") { | 206 if (name == "Spectrogram Smoothing") { |
198 setSmoothSpectrogram(value > 0.1); | 207 setSpectrogramSmoothing(SpectrogramSmoothing(value)); |
199 } else if (name == "Tuning Frequency") { | 208 } else if (name == "Tuning Frequency") { |
200 //!!! | 209 //!!! |
201 } else if (name == "Property Box Layout") { | 210 } else if (name == "Property Box Layout") { |
202 setPropertyBoxLayout(value == 0 ? VerticallyStacked : Layered); | 211 setPropertyBoxLayout(value == 0 ? VerticallyStacked : Layered); |
203 } else if (name == "Window Type") { | 212 } else if (name == "Window Type") { |
206 setResampleQuality(value); | 215 setResampleQuality(value); |
207 } | 216 } |
208 } | 217 } |
209 | 218 |
210 void | 219 void |
211 Preferences::setSmoothSpectrogram(bool smooth) | 220 Preferences::setSpectrogramSmoothing(SpectrogramSmoothing smoothing) |
212 { | 221 { |
213 if (m_smoothSpectrogram != smooth) { | 222 if (m_spectrogramSmoothing != smoothing) { |
214 m_smoothSpectrogram = smooth; | 223 |
215 QSettings settings; | 224 // "smoothing" is one of those words that looks increasingly |
216 settings.beginGroup("Preferences"); | 225 // ridiculous the more you see it. Smoothing smoothing smoothing. |
217 settings.setValue("smooth-spectrogram", smooth); | 226 m_spectrogramSmoothing = smoothing; |
218 settings.endGroup(); | 227 |
219 emit propertyChanged("Smooth Spectrogram"); | 228 QSettings settings; |
229 settings.beginGroup("Preferences"); | |
230 settings.setValue("spectrogram-smoothing", int(smoothing)); | |
231 settings.endGroup(); | |
232 emit propertyChanged("Spectrogram Smoothing"); | |
220 } | 233 } |
221 } | 234 } |
222 | 235 |
223 void | 236 void |
224 Preferences::setTuningFrequency(float freq) | 237 Preferences::setTuningFrequency(float freq) |