comparison base/Preferences.cpp @ 553:98077b21a9e1

* Restore (better quality) y-axis interpolation in spectrogram * Make spectrogram x axis interpolation a preference
author Chris Cannam
date Fri, 06 Feb 2009 15:06:23 +0000
parents 7aa1de571880
children 75f154085a4d
comparison
equal deleted inserted replaced
552:bbe503e368a9 553:98077b21a9e1
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_spectrogramSmoothing(SpectrogramZeroPadded), 38 m_spectrogramSmoothing(SpectrogramInterpolated),
39 m_spectrogramXSmoothing(SpectrogramXInterpolated),
39 m_tuningFrequency(440), 40 m_tuningFrequency(440),
40 m_propertyBoxLayout(VerticallyStacked), 41 m_propertyBoxLayout(VerticallyStacked),
41 m_windowType(HanningWindow), 42 m_windowType(HanningWindow),
42 m_resampleQuality(1), 43 m_resampleQuality(1),
43 m_omitRecentTemps(true), 44 m_omitRecentTemps(true),
48 m_showSplash(true) 49 m_showSplash(true)
49 { 50 {
50 QSettings settings; 51 QSettings settings;
51 settings.beginGroup("Preferences"); 52 settings.beginGroup("Preferences");
52 m_spectrogramSmoothing = SpectrogramSmoothing 53 m_spectrogramSmoothing = SpectrogramSmoothing
53 (settings.value("spectrogram-smoothing", int(m_spectrogramSmoothing)).toInt()); 54 (settings.value("spectrogram-y-smoothing", int(m_spectrogramSmoothing)).toInt());
55 m_spectrogramXSmoothing = SpectrogramXSmoothing
56 (settings.value("spectrogram-x-smoothing", int(m_spectrogramXSmoothing)).toInt());
54 m_tuningFrequency = settings.value("tuning-frequency", 440.f).toDouble(); 57 m_tuningFrequency = settings.value("tuning-frequency", 440.f).toDouble();
55 m_propertyBoxLayout = PropertyBoxLayout 58 m_propertyBoxLayout = PropertyBoxLayout
56 (settings.value("property-box-layout", int(VerticallyStacked)).toInt()); 59 (settings.value("property-box-layout", int(VerticallyStacked)).toInt());
57 m_windowType = WindowType 60 m_windowType = WindowType
58 (settings.value("window-type", int(HanningWindow)).toInt()); 61 (settings.value("window-type", int(HanningWindow)).toInt());
75 78
76 Preferences::PropertyList 79 Preferences::PropertyList
77 Preferences::getProperties() const 80 Preferences::getProperties() const
78 { 81 {
79 PropertyList props; 82 PropertyList props;
80 props.push_back("Spectrogram Smoothing"); 83 props.push_back("Spectrogram Y Smoothing");
84 props.push_back("Spectrogram X Smoothing");
81 props.push_back("Tuning Frequency"); 85 props.push_back("Tuning Frequency");
82 props.push_back("Property Box Layout"); 86 props.push_back("Property Box Layout");
83 props.push_back("Window Type"); 87 props.push_back("Window Type");
84 props.push_back("Resample Quality"); 88 props.push_back("Resample Quality");
85 props.push_back("Omit Temporaries from Recent Files"); 89 props.push_back("Omit Temporaries from Recent Files");
92 } 96 }
93 97
94 QString 98 QString
95 Preferences::getPropertyLabel(const PropertyName &name) const 99 Preferences::getPropertyLabel(const PropertyName &name) const
96 { 100 {
97 if (name == "Spectrogram Smoothing") { 101 if (name == "Spectrogram Y Smoothing") {
98 return tr("Spectrogram y-axis interpolation:"); 102 return tr("Spectrogram y-axis interpolation:");
103 }
104 if (name == "Spectrogram X Smoothing") {
105 return tr("Spectrogram x-axis interpolation:");
99 } 106 }
100 if (name == "Tuning Frequency") { 107 if (name == "Tuning Frequency") {
101 return tr("Frequency of concert A"); 108 return tr("Frequency of concert A");
102 } 109 }
103 if (name == "Property Box Layout") { 110 if (name == "Property Box Layout") {
131 } 138 }
132 139
133 Preferences::PropertyType 140 Preferences::PropertyType
134 Preferences::getPropertyType(const PropertyName &name) const 141 Preferences::getPropertyType(const PropertyName &name) const
135 { 142 {
136 if (name == "Spectrogram Smoothing") { 143 if (name == "Spectrogram Y Smoothing") {
144 return ValueProperty;
145 }
146 if (name == "Spectrogram X Smoothing") {
137 return ValueProperty; 147 return ValueProperty;
138 } 148 }
139 if (name == "Tuning Frequency") { 149 if (name == "Tuning Frequency") {
140 return RangeProperty; 150 return RangeProperty;
141 } 151 }
172 182
173 int 183 int
174 Preferences::getPropertyRangeAndValue(const PropertyName &name, 184 Preferences::getPropertyRangeAndValue(const PropertyName &name,
175 int *min, int *max, int *deflt) const 185 int *min, int *max, int *deflt) const
176 { 186 {
177 if (name == "Spectrogram Smoothing") { 187 if (name == "Spectrogram Y Smoothing") {
178 if (min) *min = 0; 188 if (min) *min = 0;
179 if (max) *max = 2; 189 if (max) *max = 3;
180 if (deflt) *deflt = int(SpectrogramZeroPadded); 190 if (deflt) *deflt = int(SpectrogramInterpolated);
181 return int(m_spectrogramSmoothing); 191 return int(m_spectrogramSmoothing);
192 }
193 if (name == "Spectrogram X Smoothing") {
194 if (min) *min = 0;
195 if (max) *max = 1;
196 if (deflt) *deflt = int(SpectrogramXInterpolated);
197 return int(m_spectrogramXSmoothing);
182 } 198 }
183 199
184 //!!! freq mapping 200 //!!! freq mapping
185 201
186 if (name == "Property Box Layout") { 202 if (name == "Property Box Layout") {
255 case 0: return tr("Fastest"); 271 case 0: return tr("Fastest");
256 case 1: return tr("Standard"); 272 case 1: return tr("Standard");
257 case 2: return tr("Highest quality"); 273 case 2: return tr("Highest quality");
258 } 274 }
259 } 275 }
260 if (name == "Spectrogram Smoothing") { 276 if (name == "Spectrogram Y Smoothing") {
261 switch (value) { 277 switch (value) {
262 case NoSpectrogramSmoothing: return tr("None - blocky but accurate"); 278 case NoSpectrogramSmoothing: return tr("None");
263 case SpectrogramInterpolated: return tr("Linear - fast but fuzzy"); 279 case SpectrogramInterpolated: return tr("Linear interpolation");
264 case SpectrogramZeroPadded: return tr("4 x Oversampled - slow but clear"); 280 case SpectrogramZeroPadded: return tr("4 x Oversampling");
281 case SpectrogramZeroPaddedAndInterpolated: return tr("4 x Oversampling with interpolation");
282 }
283 }
284 if (name == "Spectrogram X Smoothing") {
285 switch (value) {
286 case NoSpectrogramXSmoothing: return tr("None");
287 case SpectrogramXInterpolated: return tr("Linear interpolation");
265 } 288 }
266 } 289 }
267 if (name == "Background Mode") { 290 if (name == "Background Mode") {
268 switch (value) { 291 switch (value) {
269 case BackgroundFromTheme: return tr("Follow desktop theme"); 292 case BackgroundFromTheme: return tr("Follow desktop theme");
288 } 311 }
289 312
290 void 313 void
291 Preferences::setProperty(const PropertyName &name, int value) 314 Preferences::setProperty(const PropertyName &name, int value)
292 { 315 {
293 if (name == "Spectrogram Smoothing") { 316 if (name == "Spectrogram Y Smoothing") {
294 setSpectrogramSmoothing(SpectrogramSmoothing(value)); 317 setSpectrogramSmoothing(SpectrogramSmoothing(value));
318 } else if (name == "Spectrogram X Smoothing") {
319 setSpectrogramXSmoothing(SpectrogramXSmoothing(value));
295 } else if (name == "Tuning Frequency") { 320 } else if (name == "Tuning Frequency") {
296 //!!! 321 //!!!
297 } else if (name == "Property Box Layout") { 322 } else if (name == "Property Box Layout") {
298 setPropertyBoxLayout(value == 0 ? VerticallyStacked : Layered); 323 setPropertyBoxLayout(value == 0 ? VerticallyStacked : Layered);
299 } else if (name == "Window Type") { 324 } else if (name == "Window Type") {
320 // ridiculous the more you see it. Smoothing smoothing smoothing. 345 // ridiculous the more you see it. Smoothing smoothing smoothing.
321 m_spectrogramSmoothing = smoothing; 346 m_spectrogramSmoothing = smoothing;
322 347
323 QSettings settings; 348 QSettings settings;
324 settings.beginGroup("Preferences"); 349 settings.beginGroup("Preferences");
325 settings.setValue("spectrogram-smoothing", int(smoothing)); 350 settings.setValue("spectrogram-y-smoothing", int(smoothing));
326 settings.endGroup(); 351 settings.endGroup();
327 emit propertyChanged("Spectrogram Smoothing"); 352 emit propertyChanged("Spectrogram Y Smoothing");
353 }
354 }
355
356 void
357 Preferences::setSpectrogramXSmoothing(SpectrogramXSmoothing smoothing)
358 {
359 if (m_spectrogramXSmoothing != smoothing) {
360
361 // "smoothing" is one of those words that looks increasingly
362 // ridiculous the more you see it. Smoothing smoothing smoothing.
363 m_spectrogramXSmoothing = smoothing;
364
365 QSettings settings;
366 settings.beginGroup("Preferences");
367 settings.setValue("spectrogram-x-smoothing", int(smoothing));
368 settings.endGroup();
369 emit propertyChanged("Spectrogram X Smoothing");
328 } 370 }
329 } 371 }
330 372
331 void 373 void
332 Preferences::setTuningFrequency(float freq) 374 Preferences::setTuningFrequency(float freq)