comparison base/Preferences.cpp @ 164:da3701a3953e

* Make resampler quality configurable * Fall back to linear resampling when playing very fast * Switch off transient detection in time stretcher when playing very very fast
author Chris Cannam
date Thu, 21 Sep 2006 11:17:19 +0000
parents 059b0322009c
children 5ae5885d6ce3
comparison
equal deleted inserted replaced
163:4148ad087959 164:da3701a3953e
36 36
37 Preferences::Preferences() : 37 Preferences::Preferences() :
38 m_smoothSpectrogram(true), 38 m_smoothSpectrogram(true),
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 { 43 {
43 QSettings settings; 44 QSettings settings;
44 settings.beginGroup("Preferences"); 45 settings.beginGroup("Preferences");
45 m_smoothSpectrogram = settings.value("smooth-spectrogram", true).toBool(); 46 m_smoothSpectrogram = settings.value("smooth-spectrogram", true).toBool();
46 m_tuningFrequency = settings.value("tuning-frequency", 440.f).toDouble(); 47 m_tuningFrequency = settings.value("tuning-frequency", 440.f).toDouble();
47 m_propertyBoxLayout = PropertyBoxLayout 48 m_propertyBoxLayout = PropertyBoxLayout
48 (settings.value("property-box-layout", int(VerticallyStacked)).toInt()); 49 (settings.value("property-box-layout", int(VerticallyStacked)).toInt());
49 m_windowType = WindowType 50 m_windowType = WindowType
50 (settings.value("window-type", int(HanningWindow)).toInt()); 51 (settings.value("window-type", int(HanningWindow)).toInt());
52 m_resampleQuality = settings.value("resample-quality", 1).toInt();
51 settings.endGroup(); 53 settings.endGroup();
52 } 54 }
53 55
54 Preferences::~Preferences() 56 Preferences::~Preferences()
55 { 57 {
61 PropertyList props; 63 PropertyList props;
62 props.push_back("Smooth Spectrogram"); 64 props.push_back("Smooth Spectrogram");
63 props.push_back("Tuning Frequency"); 65 props.push_back("Tuning Frequency");
64 props.push_back("Property Box Layout"); 66 props.push_back("Property Box Layout");
65 props.push_back("Window Type"); 67 props.push_back("Window Type");
68 props.push_back("Resample Quality");
66 return props; 69 return props;
67 } 70 }
68 71
69 QString 72 QString
70 Preferences::getPropertyLabel(const PropertyName &name) const 73 Preferences::getPropertyLabel(const PropertyName &name) const
79 return tr("Property box layout"); 82 return tr("Property box layout");
80 } 83 }
81 if (name == "Window Type") { 84 if (name == "Window Type") {
82 return tr("Spectral analysis window shape"); 85 return tr("Spectral analysis window shape");
83 } 86 }
87 if (name == "Resample Quality") {
88 return tr("Resampler quality");
89 }
84 return name; 90 return name;
85 } 91 }
86 92
87 Preferences::PropertyType 93 Preferences::PropertyType
88 Preferences::getPropertyType(const PropertyName &name) const 94 Preferences::getPropertyType(const PropertyName &name) const
95 } 101 }
96 if (name == "Property Box Layout") { 102 if (name == "Property Box Layout") {
97 return ValueProperty; 103 return ValueProperty;
98 } 104 }
99 if (name == "Window Type") { 105 if (name == "Window Type") {
106 return ValueProperty;
107 }
108 if (name == "Resample Quality") {
100 return ValueProperty; 109 return ValueProperty;
101 } 110 }
102 return InvalidProperty; 111 return InvalidProperty;
103 } 112 }
104 113
122 131
123 if (name == "Window Type") { 132 if (name == "Window Type") {
124 if (min) *min = int(RectangularWindow); 133 if (min) *min = int(RectangularWindow);
125 if (max) *max = int(BlackmanHarrisWindow); 134 if (max) *max = int(BlackmanHarrisWindow);
126 return int(m_windowType); 135 return int(m_windowType);
136 }
137
138 if (name == "Resample Quality") {
139 if (min) *min = 0;
140 if (max) *max = 2;
141 return m_resampleQuality;
127 } 142 }
128 143
129 return 0; 144 return 0;
130 } 145 }
131 146
148 case ParzenWindow: return tr("Parzen"); 163 case ParzenWindow: return tr("Parzen");
149 case NuttallWindow: return tr("Nuttall"); 164 case NuttallWindow: return tr("Nuttall");
150 case BlackmanHarrisWindow: return tr("Blackman-Harris"); 165 case BlackmanHarrisWindow: return tr("Blackman-Harris");
151 } 166 }
152 } 167 }
168 if (name == "Resample Quality") {
169 switch (value) {
170 case 0: return tr("Fastest");
171 case 1: return tr("Medium quality");
172 case 2: return tr("Highest quality");
173 }
174 }
153 return ""; 175 return "";
154 } 176 }
155 177
156 QString 178 QString
157 Preferences::getPropertyContainerName() const 179 Preferences::getPropertyContainerName() const
174 //!!! 196 //!!!
175 } else if (name == "Property Box Layout") { 197 } else if (name == "Property Box Layout") {
176 setPropertyBoxLayout(value == 0 ? VerticallyStacked : Layered); 198 setPropertyBoxLayout(value == 0 ? VerticallyStacked : Layered);
177 } else if (name == "Window Type") { 199 } else if (name == "Window Type") {
178 setWindowType(WindowType(value)); 200 setWindowType(WindowType(value));
201 } else if (name == "Resample Quality") {
202 setResampleQuality(value);
179 } 203 }
180 } 204 }
181 205
182 void 206 void
183 Preferences::setSmoothSpectrogram(bool smooth) 207 Preferences::setSmoothSpectrogram(bool smooth)
229 settings.endGroup(); 253 settings.endGroup();
230 emit propertyChanged("Window Type"); 254 emit propertyChanged("Window Type");
231 } 255 }
232 } 256 }
233 257
258 void
259 Preferences::setResampleQuality(int q)
260 {
261 if (m_resampleQuality != q) {
262 m_resampleQuality = q;
263 QSettings settings;
264 settings.beginGroup("Preferences");
265 settings.setValue("resample-quality", q);
266 settings.endGroup();
267 emit propertyChanged("Resample Quality");
268 }
269 }