MCPcopy Create free account
hub / github.com/audacity/audacity / GetBounds

Method GetBounds

libraries/lib-wave-track-settings/SpectrogramSettings.cpp:814–858  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

812}
813
814void 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}

Callers

nothing calls this directly

Calls 5

GetFunction · 0.85
maxFunction · 0.85
GetFFTLengthMethod · 0.80
GetTrackMethod · 0.45
GetRateMethod · 0.45

Tested by

no test coverage detected