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

Pitch is no longer a special view type... && bug fixes 1040, 1041

... It is a choice of algorithm in spectrogram settings, and any frequency
scale may be chosen with it.  Spectral selection works in it.
This commit is contained in:
Paul Licameli
2015-06-20 12:15:49 -04:00
parent 981acf0bd2
commit adb4a534e8
11 changed files with 125 additions and 59 deletions

View File

@@ -78,6 +78,7 @@ SpectrogramSettings::SpectrogramSettings(const SpectrogramSettings &other)
#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
, spectralSelection(other.spectralSelection)
#endif
, algorithm(other.algorithm)
#ifdef EXPERIMENTAL_FFT_Y_GRID
, fftYGrid(other.fftYGrid)
#endif
@@ -114,6 +115,7 @@ SpectrogramSettings &SpectrogramSettings::operator= (const SpectrogramSettings &
#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
spectralSelection = other.spectralSelection;
#endif
algorithm = other.algorithm;
#ifdef EXPERIMENTAL_FFT_Y_GRID
fftYGrid = other.fftYGrid;
#endif
@@ -144,12 +146,19 @@ namespace
static wxArrayString theArray;
return theArray;
}
wxArrayString &algorithmNamesArray()
{
static wxArrayString theArray;
return theArray;
}
}
//static
void SpectrogramSettings::InvalidateNames()
{
scaleNamesArray().Clear();
algorithmNamesArray().Clear();
}
//static
@@ -170,6 +179,20 @@ const wxArrayString &SpectrogramSettings::GetScaleNames()
return theArray;
}
//static
const wxArrayString &SpectrogramSettings::GetAlgorithmNames()
{
wxArrayString &theArray = algorithmNamesArray();
if (theArray.IsEmpty()) {
// Keep in correspondence with enum SpectrogramSettings::Algorithm:
theArray.Add(_("STFT"));
theArray.Add(_("Pitch (enhanced autocorrelation)"));
}
return theArray;
}
bool SpectrogramSettings::Validate(bool quiet)
{
if (!quiet &&
@@ -227,6 +250,9 @@ bool SpectrogramSettings::Validate(bool quiet)
ScaleType(std::max(0,
std::min(int(SpectrogramSettings::stNumScaleTypes) - 1,
int(scaleType))));
algorithm = Algorithm(
std::max(0, std::min(int(algNumAlgorithms) - 1, int(algorithm)))
);
ConvertToEnumeratedWindowSizes();
ConvertToActualWindowSizes();
@@ -259,6 +285,8 @@ void SpectrogramSettings::LoadPrefs()
spectralSelection = (gPrefs->Read(wxT("/Spectrum/EnableSpectralSelection"), 0L) != 0);
#endif
algorithm = Algorithm(gPrefs->Read(wxT("/Spectrum/Algorithm"), 0L));
#ifdef EXPERIMENTAL_FFT_Y_GRID
fftYGrid = (gPrefs->Read(wxT("/Spectrum/FFTYGrid"), 0L) != 0);
#endif //EXPERIMENTAL_FFT_Y_GRID
@@ -319,6 +347,8 @@ void SpectrogramSettings::SavePrefs()
gPrefs->Write(wxT("/Spectrum/EnableSpectralSelection"), spectralSelection);
#endif
gPrefs->Write(wxT("/Spectrum/Algorithm"), algorithm);
#ifdef EXPERIMENTAL_FFT_Y_GRID
gPrefs->Write(wxT("/Spectrum/FFTYGrid"), fftYGrid);
#endif //EXPERIMENTAL_FFT_Y_GRID
@@ -519,21 +549,21 @@ void SpectrogramSettings::SetLogMaxFreq(int freq)
logMaxFreq = freq;
}
int SpectrogramSettings::GetFFTLength(bool autocorrelation) const
int SpectrogramSettings::GetFFTLength() const
{
return windowSize
#ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
* (!autocorrelation ? zeroPaddingFactor : 1);
* ((algorithm == algSTFT) ? zeroPaddingFactor : 1);
#endif
;
}
NumberScale SpectrogramSettings::GetScale
(double rate, bool bins, bool autocorrelation) const
(double rate, bool bins) const
{
int minFreq, maxFreq;
NumberScaleType type = nstLinear;
const int half = GetFFTLength(autocorrelation) / 2;
const int half = GetFFTLength() / 2;
// Don't assume the correspondence of the enums will remain direct in the future.
// Do this switch.