Mercurial > hg > svgui
comparison layer/SpectrumLayer.cpp @ 274:b9380f679f70
* Fix centre line position
* Fix failure to update overview when generating peaks from wav file
* Provide y-coordinate scale values and differences for spectrum measurement
mode, and fix values for waveform (inc dB for both)
* Add Printer colour scheme (may be futile)
author | Chris Cannam |
---|---|
date | Mon, 02 Jul 2007 13:04:17 +0000 |
parents | 4ed1446ad604 |
children | bbe57afe9d7d |
comparison
equal
deleted
inserted
replaced
273:e954c00cbe55 | 274:b9380f679f70 |
---|---|
322 case LogBins: | 322 case LogBins: |
323 x = (log10f(freq) * w) / log10f(maxfreq); | 323 x = (log10f(freq) * w) / log10f(maxfreq); |
324 break; | 324 break; |
325 | 325 |
326 case InvertedLogBins: | 326 case InvertedLogBins: |
327 x = (w - log10f(maxfreq - freq) * w) / log10f(maxfreq); | 327 if (maxfreq == freq) x = w; |
328 else x = w - (log10f(maxfreq - freq) * w) / log10f(maxfreq); | |
328 break; | 329 break; |
329 } | 330 } |
330 | 331 |
331 return x; | 332 return x; |
332 } | 333 } |
339 int xorigin = m_xorigins.find(v)->second; | 340 int xorigin = m_xorigins.find(v)->second; |
340 value = getFrequencyForX(x - xorigin, v->width() - xorigin - 1); | 341 value = getFrequencyForX(x - xorigin, v->width() - xorigin - 1); |
341 unit = "Hz"; | 342 unit = "Hz"; |
342 return true; | 343 return true; |
343 } | 344 } |
345 | |
346 bool | |
347 SpectrumLayer::getYScaleValue(const View *v, int y, | |
348 float &value, QString &unit) const | |
349 { | |
350 value = getValueForY(y, v); | |
351 | |
352 if (m_energyScale == dBScale || m_energyScale == MeterScale) { | |
353 | |
354 float thresh = -80.f; | |
355 | |
356 if (value > 0.f) { | |
357 value = 10.f * log10f(value); | |
358 if (value < thresh) value = thresh; | |
359 } else value = thresh; | |
360 | |
361 unit = "dBV"; | |
362 | |
363 } else { | |
364 unit = "V"; | |
365 } | |
366 | |
367 return true; | |
368 } | |
369 | |
370 bool | |
371 SpectrumLayer::getYScaleDifference(const View *v, int y0, int y1, | |
372 float &diff, QString &unit) const | |
373 { | |
374 bool rv = SliceLayer::getYScaleDifference(v, y0, y1, diff, unit); | |
375 if (rv && (unit == "dBV")) unit = "dB"; | |
376 return rv; | |
377 } | |
378 | |
344 | 379 |
345 bool | 380 bool |
346 SpectrumLayer::getCrosshairExtents(View *v, QPainter &paint, | 381 SpectrumLayer::getCrosshairExtents(View *v, QPainter &paint, |
347 QPoint cursorPos, | 382 QPoint cursorPos, |
348 std::vector<QRect> &extents) const | 383 std::vector<QRect> &extents) const |