Mercurial > hg > svgui
comparison layer/SpectrogramLayer.cpp @ 901:0fe1f4407261 cxx11
Fixes to go with latest svcore
author | Chris Cannam |
---|---|
date | Wed, 04 Mar 2015 13:53:05 +0000 |
parents | d7f6f60a8b30 |
children | b66fb15de477 |
comparison
equal
deleted
inserted
replaced
900:1fc4f29feb2e | 901:0fe1f4407261 |
---|---|
3428 } | 3428 } |
3429 | 3429 |
3430 class SpectrogramRangeMapper : public RangeMapper | 3430 class SpectrogramRangeMapper : public RangeMapper |
3431 { | 3431 { |
3432 public: | 3432 public: |
3433 SpectrogramRangeMapper(int sr, int /* fftsize */) : | 3433 SpectrogramRangeMapper(sv_samplerate_t sr, int /* fftsize */) : |
3434 m_dist(float(sr) / 2), | 3434 m_dist(sr / 2), |
3435 m_s2(sqrtf(sqrtf(2))) { } | 3435 m_s2(sqrt(sqrt(2))) { } |
3436 ~SpectrogramRangeMapper() { } | 3436 ~SpectrogramRangeMapper() { } |
3437 | 3437 |
3438 virtual int getPositionForValue(float value) const { | 3438 virtual int getPositionForValue(double value) const { |
3439 | 3439 |
3440 float dist = m_dist; | 3440 double dist = m_dist; |
3441 | 3441 |
3442 int n = 0; | 3442 int n = 0; |
3443 | 3443 |
3444 while (dist > (value + 0.00001) && dist > 0.1f) { | 3444 while (dist > (value + 0.00001) && dist > 0.1) { |
3445 dist /= m_s2; | 3445 dist /= m_s2; |
3446 ++n; | 3446 ++n; |
3447 } | 3447 } |
3448 | 3448 |
3449 return n; | 3449 return n; |
3450 } | 3450 } |
3451 | 3451 |
3452 virtual int getPositionForValueUnclamped(float value) const { | 3452 virtual int getPositionForValueUnclamped(double value) const { |
3453 // We don't really support this | 3453 // We don't really support this |
3454 return getPositionForValue(value); | 3454 return getPositionForValue(value); |
3455 } | 3455 } |
3456 | 3456 |
3457 virtual float getValueForPosition(int position) const { | 3457 virtual double getValueForPosition(int position) const { |
3458 | 3458 |
3459 // Vertical zoom step 0 shows the entire range from DC -> | 3459 // Vertical zoom step 0 shows the entire range from DC -> |
3460 // Nyquist frequency. Step 1 shows 2^(1/4) of the range of | 3460 // Nyquist frequency. Step 1 shows 2^(1/4) of the range of |
3461 // step 0, and so on until the visible range is smaller than | 3461 // step 0, and so on until the visible range is smaller than |
3462 // the frequency step between bins at the current fft size. | 3462 // the frequency step between bins at the current fft size. |
3463 | 3463 |
3464 float dist = m_dist; | 3464 double dist = m_dist; |
3465 | 3465 |
3466 int n = 0; | 3466 int n = 0; |
3467 while (n < position) { | 3467 while (n < position) { |
3468 dist /= m_s2; | 3468 dist /= m_s2; |
3469 ++n; | 3469 ++n; |
3470 } | 3470 } |
3471 | 3471 |
3472 return dist; | 3472 return dist; |
3473 } | 3473 } |
3474 | 3474 |
3475 virtual float getValueForPositionUnclamped(int position) const { | 3475 virtual double getValueForPositionUnclamped(int position) const { |
3476 // We don't really support this | 3476 // We don't really support this |
3477 return getValueForPosition(position); | 3477 return getValueForPosition(position); |
3478 } | 3478 } |
3479 | 3479 |
3480 virtual QString getUnit() const { return "Hz"; } | 3480 virtual QString getUnit() const { return "Hz"; } |
3481 | 3481 |
3482 protected: | 3482 protected: |
3483 float m_dist; | 3483 double m_dist; |
3484 float m_s2; | 3484 double m_s2; |
3485 }; | 3485 }; |
3486 | 3486 |
3487 int | 3487 int |
3488 SpectrogramLayer::getVerticalZoomSteps(int &defaultStep) const | 3488 SpectrogramLayer::getVerticalZoomSteps(int &defaultStep) const |
3489 { | 3489 { |