Converts a position (mouse Y coordinate) to frequency, in Hz.
| 82 | /// Converts a position (mouse Y coordinate) to |
| 83 | /// frequency, in Hz. |
| 84 | double PositionToFrequency(const WaveChannel &wc, |
| 85 | bool maySnap, |
| 86 | wxInt64 mouseYCoordinate, |
| 87 | wxInt64 trackTopEdge, |
| 88 | int trackHeight) |
| 89 | { |
| 90 | const double rate = wc.GetRate(); |
| 91 | |
| 92 | // Handle snapping |
| 93 | if (maySnap && |
| 94 | mouseYCoordinate - trackTopEdge < FREQ_SNAP_DISTANCE) |
| 95 | return rate; |
| 96 | if (maySnap && |
| 97 | trackTopEdge + trackHeight - mouseYCoordinate < FREQ_SNAP_DISTANCE) |
| 98 | return -1; |
| 99 | |
| 100 | const auto &settings = SpectrogramSettings::Get(wc); |
| 101 | float minFreq, maxFreq; |
| 102 | SpectrogramBounds::Get(wc).GetBounds(wc, minFreq, maxFreq); |
| 103 | const NumberScale numberScale(settings.GetScale(minFreq, maxFreq)); |
| 104 | const double p = double(mouseYCoordinate - trackTopEdge) / trackHeight; |
| 105 | return numberScale.PositionToValue(1.0 - p); |
| 106 | } |
| 107 | |
| 108 | template<typename T> |
| 109 | inline void SetIfNotNull(T * pValue, const T Value) |
no test coverage detected