Mercurial > hg > svgui
comparison layer/SpectrogramLayer.cpp @ 216:34bbbcb3c01f sv1-1.0pre1
* Make getPropertyRangeAndValue return the default separately from the current
value. Previously some contexts were incorrectly treating the current value
as a default.
author | Chris Cannam |
---|---|
date | Fri, 02 Mar 2007 14:00:12 +0000 |
parents | d2334a77db73 |
children | 9e739f92c0b8 |
comparison
equal
deleted
inserted
replaced
215:d2334a77db73 | 216:34bbbcb3c01f |
---|---|
79 setMaxFrequency(1500); | 79 setMaxFrequency(1500); |
80 setMinFrequency(40); | 80 setMinFrequency(40); |
81 setColourScale(LinearColourScale); | 81 setColourScale(LinearColourScale); |
82 setColourMap(ColourMapper::Sunset); | 82 setColourMap(ColourMapper::Sunset); |
83 setFrequencyScale(LogFrequencyScale); | 83 setFrequencyScale(LogFrequencyScale); |
84 m_initialGain = 20; | |
85 setGain(20); | 84 setGain(20); |
86 } else if (config == MelodicPeaks) { | 85 } else if (config == MelodicPeaks) { |
87 setWindowSize(4096); | 86 setWindowSize(4096); |
88 setWindowHopLevel(5); | 87 setWindowHopLevel(5); |
89 m_initialMaxFrequency = 2000; | 88 m_initialMaxFrequency = 2000; |
208 return QString(); | 207 return QString(); |
209 } | 208 } |
210 | 209 |
211 int | 210 int |
212 SpectrogramLayer::getPropertyRangeAndValue(const PropertyName &name, | 211 SpectrogramLayer::getPropertyRangeAndValue(const PropertyName &name, |
213 int *min, int *max) const | 212 int *min, int *max, int *deflt) const |
214 { | 213 { |
215 int deft = 0; | 214 int val = 0; |
216 | 215 |
217 int garbage0, garbage1; | 216 int garbage0, garbage1, garbage2; |
218 if (!min) min = &garbage0; | 217 if (!min) min = &garbage0; |
219 if (!max) max = &garbage1; | 218 if (!max) max = &garbage1; |
219 if (!deflt) deflt = &garbage2; | |
220 | 220 |
221 if (name == "Gain") { | 221 if (name == "Gain") { |
222 | 222 |
223 *min = -50; | 223 *min = -50; |
224 *max = 50; | 224 *max = 50; |
225 | 225 |
226 deft = lrintf(log10(m_initialGain) * 20.0); | 226 *deflt = lrintf(log10(m_initialGain) * 20.0);; |
227 if (deft < *min) deft = *min; | 227 if (*deflt < *min) *deflt = *min; |
228 if (deft > *max) deft = *max; | 228 if (*deflt > *max) *deflt = *max; |
229 | |
230 val = lrintf(log10(m_gain) * 20.0); | |
231 if (val < *min) val = *min; | |
232 if (val > *max) val = *max; | |
229 | 233 |
230 } else if (name == "Threshold") { | 234 } else if (name == "Threshold") { |
231 | 235 |
232 *min = -50; | 236 *min = -50; |
233 *max = 0; | 237 *max = 0; |
234 | 238 |
235 deft = lrintf(AudioLevel::multiplier_to_dB(m_initialThreshold)); | 239 *deflt = lrintf(AudioLevel::multiplier_to_dB(m_initialThreshold)); |
236 if (deft < *min) deft = *min; | 240 if (*deflt < *min) *deflt = *min; |
237 if (deft > *max) deft = *max; | 241 if (*deflt > *max) *deflt = *max; |
242 | |
243 val = lrintf(AudioLevel::multiplier_to_dB(m_threshold)); | |
244 if (val < *min) val = *min; | |
245 if (val > *max) val = *max; | |
238 | 246 |
239 } else if (name == "Colour Rotation") { | 247 } else if (name == "Colour Rotation") { |
240 | 248 |
241 *min = 0; | 249 *min = 0; |
242 *max = 256; | 250 *max = 256; |
243 | 251 *deflt = m_initialRotation; |
244 deft = m_initialRotation; | 252 |
253 val = m_colourRotation; | |
245 | 254 |
246 } else if (name == "Colour Scale") { | 255 } else if (name == "Colour Scale") { |
247 | 256 |
248 *min = 0; | 257 *min = 0; |
249 *max = 4; | 258 *max = 4; |
250 | 259 *deflt = int(dBColourScale); |
251 deft = (int)m_colourScale; | 260 |
261 val = (int)m_colourScale; | |
252 | 262 |
253 } else if (name == "Colour") { | 263 } else if (name == "Colour") { |
254 | 264 |
255 *min = 0; | 265 *min = 0; |
256 *max = ColourMapper::getColourMapCount() - 1; | 266 *max = ColourMapper::getColourMapCount() - 1; |
257 | 267 *deflt = 0; |
258 deft = m_colourMap; | 268 |
269 val = m_colourMap; | |
259 | 270 |
260 } else if (name == "Window Size") { | 271 } else if (name == "Window Size") { |
261 | 272 |
262 *min = 0; | 273 *min = 0; |
263 *max = 10; | 274 *max = 10; |
275 *deflt = 5; | |
264 | 276 |
265 deft = 0; | 277 val = 0; |
266 int ws = m_windowSize; | 278 int ws = m_windowSize; |
267 while (ws > 32) { ws >>= 1; deft ++; } | 279 while (ws > 32) { ws >>= 1; val ++; } |
268 | 280 |
269 } else if (name == "Window Increment") { | 281 } else if (name == "Window Increment") { |
270 | 282 |
271 *min = 0; | 283 *min = 0; |
272 *max = 5; | 284 *max = 5; |
273 | 285 *deflt = 2; |
274 deft = m_windowHopLevel; | 286 |
287 val = m_windowHopLevel; | |
275 | 288 |
276 } else if (name == "Zero Padding") { | 289 } else if (name == "Zero Padding") { |
277 | 290 |
278 *min = 0; | 291 *min = 0; |
279 *max = 1; | 292 *max = 1; |
293 *deflt = 0; | |
280 | 294 |
281 deft = m_zeroPadLevel > 0 ? 1 : 0; | 295 val = m_zeroPadLevel > 0 ? 1 : 0; |
282 | 296 |
283 } else if (name == "Min Frequency") { | 297 } else if (name == "Min Frequency") { |
284 | 298 |
285 *min = 0; | 299 *min = 0; |
286 *max = 9; | 300 *max = 9; |
301 *deflt = 1; | |
287 | 302 |
288 switch (m_minFrequency) { | 303 switch (m_minFrequency) { |
289 case 0: default: deft = 0; break; | 304 case 0: default: val = 0; break; |
290 case 10: deft = 1; break; | 305 case 10: val = 1; break; |
291 case 20: deft = 2; break; | 306 case 20: val = 2; break; |
292 case 40: deft = 3; break; | 307 case 40: val = 3; break; |
293 case 100: deft = 4; break; | 308 case 100: val = 4; break; |
294 case 250: deft = 5; break; | 309 case 250: val = 5; break; |
295 case 500: deft = 6; break; | 310 case 500: val = 6; break; |
296 case 1000: deft = 7; break; | 311 case 1000: val = 7; break; |
297 case 4000: deft = 8; break; | 312 case 4000: val = 8; break; |
298 case 10000: deft = 9; break; | 313 case 10000: val = 9; break; |
299 } | 314 } |
300 | 315 |
301 } else if (name == "Max Frequency") { | 316 } else if (name == "Max Frequency") { |
302 | 317 |
303 *min = 0; | 318 *min = 0; |
304 *max = 9; | 319 *max = 9; |
320 *deflt = 6; | |
305 | 321 |
306 switch (m_maxFrequency) { | 322 switch (m_maxFrequency) { |
307 case 500: deft = 0; break; | 323 case 500: val = 0; break; |
308 case 1000: deft = 1; break; | 324 case 1000: val = 1; break; |
309 case 1500: deft = 2; break; | 325 case 1500: val = 2; break; |
310 case 2000: deft = 3; break; | 326 case 2000: val = 3; break; |
311 case 4000: deft = 4; break; | 327 case 4000: val = 4; break; |
312 case 6000: deft = 5; break; | 328 case 6000: val = 5; break; |
313 case 8000: deft = 6; break; | 329 case 8000: val = 6; break; |
314 case 12000: deft = 7; break; | 330 case 12000: val = 7; break; |
315 case 16000: deft = 8; break; | 331 case 16000: val = 8; break; |
316 default: deft = 9; break; | 332 default: val = 9; break; |
317 } | 333 } |
318 | 334 |
319 } else if (name == "Frequency Scale") { | 335 } else if (name == "Frequency Scale") { |
320 | 336 |
321 *min = 0; | 337 *min = 0; |
322 *max = 1; | 338 *max = 1; |
323 deft = (int)m_frequencyScale; | 339 *deflt = int(LinearFrequencyScale); |
340 val = (int)m_frequencyScale; | |
324 | 341 |
325 } else if (name == "Bin Display") { | 342 } else if (name == "Bin Display") { |
326 | 343 |
327 *min = 0; | 344 *min = 0; |
328 *max = 2; | 345 *max = 2; |
329 deft = (int)m_binDisplay; | 346 *deflt = int(AllBins); |
347 val = (int)m_binDisplay; | |
330 | 348 |
331 } else if (name == "Normalize Columns") { | 349 } else if (name == "Normalize Columns") { |
332 | 350 |
333 deft = (m_normalizeColumns ? 1 : 0); | 351 *deflt = 0; |
352 val = (m_normalizeColumns ? 1 : 0); | |
334 | 353 |
335 } else if (name == "Normalize Visible Area") { | 354 } else if (name == "Normalize Visible Area") { |
336 | 355 |
337 deft = (m_normalizeVisibleArea ? 1 : 0); | 356 *deflt = 0; |
357 val = (m_normalizeVisibleArea ? 1 : 0); | |
338 | 358 |
339 } else { | 359 } else { |
340 deft = Layer::getPropertyRangeAndValue(name, min, max); | 360 val = Layer::getPropertyRangeAndValue(name, min, max, deflt); |
341 } | 361 } |
342 | 362 |
343 return deft; | 363 return val; |
344 } | 364 } |
345 | 365 |
346 QString | 366 QString |
347 SpectrogramLayer::getPropertyValueLabel(const PropertyName &name, | 367 SpectrogramLayer::getPropertyValueLabel(const PropertyName &name, |
348 int value) const | 368 int value) const |