| 812 | } |
| 813 | |
| 814 | void SpectrogramBounds::GetBounds( |
| 815 | const WaveChannel &wc, float &min, float &max) const |
| 816 | { |
| 817 | auto &wt = wc.GetTrack(); |
| 818 | const double rate = wt.GetRate(); |
| 819 | |
| 820 | const auto &settings = SpectrogramSettings::Get(wt); |
| 821 | const auto type = settings.scaleType; |
| 822 | |
| 823 | const float top = (rate / 2.); |
| 824 | |
| 825 | float bottom; |
| 826 | if (type == SpectrogramSettings::stLinear) |
| 827 | bottom = 0.0f; |
| 828 | else if (type == SpectrogramSettings::stPeriod) { |
| 829 | // special case |
| 830 | const auto half = settings.GetFFTLength() / 2; |
| 831 | // EAC returns no data for below this frequency: |
| 832 | const float bin2 = rate / half; |
| 833 | bottom = bin2; |
| 834 | } |
| 835 | else |
| 836 | // logarithmic, etc. |
| 837 | bottom = 1.0f; |
| 838 | |
| 839 | { |
| 840 | float spectrumMax = mSpectrumMax; |
| 841 | if (spectrumMax < 0) |
| 842 | spectrumMax = settings.maxFreq; |
| 843 | if (spectrumMax < 0) |
| 844 | max = top; |
| 845 | else |
| 846 | max = std::clamp(spectrumMax, bottom, top); |
| 847 | } |
| 848 | |
| 849 | { |
| 850 | float spectrumMin = mSpectrumMin; |
| 851 | if (spectrumMin < 0) |
| 852 | spectrumMin = settings.minFreq; |
| 853 | if (spectrumMin < 0) |
| 854 | min = std::max(bottom, top / 1000.0f); |
| 855 | else |
| 856 | min = std::clamp(spectrumMin, bottom, top); |
| 857 | } |
| 858 | } |
nothing calls this directly
no test coverage detected