1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-26 23:33:49 +01:00

Other spectrogram scales, easily defined!! -- and include bug fixes 1038, 1039

This commit is contained in:
Paul Licameli
2015-06-16 14:10:21 -04:00
parent 9b9ceab6ab
commit 846c5d454e
5 changed files with 158 additions and 11 deletions

View File

@@ -161,6 +161,10 @@ const wxArrayString &SpectrogramSettings::GetScaleNames()
// Keep in correspondence with enum SpectrogramSettings::ScaleType:
theArray.Add(_("Linear"));
theArray.Add(_("Logarithmic"));
theArray.Add(_("Mel"));
theArray.Add(_("Bark"));
theArray.Add(_("Erb"));
theArray.Add(_("Undertone"));
}
return theArray;
@@ -529,6 +533,7 @@ NumberScale SpectrogramSettings::GetScale
{
int minFreq, maxFreq;
NumberScaleType type = nstLinear;
const int half = GetFFTLength(autocorrelation) / 2;
// Don't assume the correspondence of the enums will remain direct in the future.
// Do this switch.
@@ -539,6 +544,14 @@ NumberScale SpectrogramSettings::GetScale
type = nstLinear; break;
case stLogarithmic:
type = nstLogarithmic; break;
case stMel:
type = nstMel; break;
case stBark:
type = nstBark; break;
case stErb:
type = nstErb; break;
case stUndertone:
type = nstUndertone; break;
}
switch (scaleType) {
@@ -549,12 +562,20 @@ NumberScale SpectrogramSettings::GetScale
maxFreq = GetMaxFreq(rate);
break;
case stLogarithmic:
case stMel:
case stBark:
case stErb:
minFreq = GetLogMinFreq(rate);
maxFreq = GetLogMaxFreq(rate);
break;
case stUndertone:
{
const float bin2 = rate / half;
minFreq = std::max(int(0.5 + bin2), GetLogMinFreq(rate));
maxFreq = GetLogMaxFreq(rate);
}
break;
}
const int half = GetFFTLength(autocorrelation) / 2;
return NumberScale(type, minFreq, maxFreq,
bins ? rate / (2 * half) : 1.0f);