1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-04-30 07:39:42 +02:00

Bug2555: change Spectro algorithm shouldn't change other settings...

... Problem began at commit 238bb95 and is fixed by supplying correct default
values to gPrefs->Read(...)

The bug was introduced only for Spectrogram settings, not for Waveform.
This commit is contained in:
Paul Licameli 2020-10-09 15:23:53 -04:00
parent c563d5cc40
commit 034b2ebe81

View File

@ -331,69 +331,69 @@ void SpectrogramSettings::SavePrefs()
void SpectrogramSettings::UpdatePrefs() void SpectrogramSettings::UpdatePrefs()
{ {
if (minFreq == defaults().minFreq) { if (minFreq == defaults().minFreq) {
gPrefs->Read(wxT("/Spectrum/MinFreq"), &minFreq); gPrefs->Read(wxT("/Spectrum/MinFreq"), &minFreq, 0L);
} }
if (maxFreq == defaults().maxFreq) { if (maxFreq == defaults().maxFreq) {
gPrefs->Read(wxT("/Spectrum/MaxFreq"), &maxFreq); gPrefs->Read(wxT("/Spectrum/MaxFreq"), &maxFreq, 8000L);
} }
if (range == defaults().range) { if (range == defaults().range) {
gPrefs->Read(wxT("/Spectrum/Range"), &range); gPrefs->Read(wxT("/Spectrum/Range"), &range, 80L);
} }
if (gain == defaults().gain) { if (gain == defaults().gain) {
gPrefs->Read(wxT("/Spectrum/Gain"), &gain); gPrefs->Read(wxT("/Spectrum/Gain"), &gain, 20L);
} }
if (frequencyGain == defaults().frequencyGain) { if (frequencyGain == defaults().frequencyGain) {
gPrefs->Read(wxT("/Spectrum/FrequencyGain"), &frequencyGain); gPrefs->Read(wxT("/Spectrum/FrequencyGain"), &frequencyGain, 0L);
} }
if (windowSize == defaults().windowSize) { if (windowSize == defaults().windowSize) {
gPrefs->Read(wxT("/Spectrum/FFTSize"), &windowSize); gPrefs->Read(wxT("/Spectrum/FFTSize"), &windowSize, 1024);
} }
#ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS #ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
if (zeroPaddingFactor == defaults().zeroPaddingFactor) { if (zeroPaddingFactor == defaults().zeroPaddingFactor) {
gPrefs->Read(wxT("/Spectrum/ZeroPaddingFactor"), &zeroPaddingFactor); gPrefs->Read(wxT("/Spectrum/ZeroPaddingFactor"), &zeroPaddingFactor, 1);
} }
#endif #endif
if (windowType == defaults().windowType) { if (windowType == defaults().windowType) {
gPrefs->Read(wxT("/Spectrum/WindowType"), &windowType); gPrefs->Read(wxT("/Spectrum/WindowType"), &windowType, eWinFuncHanning);
} }
if (isGrayscale == defaults().isGrayscale) { if (isGrayscale == defaults().isGrayscale) {
int temp; int temp;
gPrefs->Read(wxT("/Spectrum/Grayscale"), &temp); gPrefs->Read(wxT("/Spectrum/Grayscale"), &temp, 0L);
isGrayscale = (temp != 0); isGrayscale = (temp != 0);
} }
if (scaleType == defaults().scaleType) { if (scaleType == defaults().scaleType) {
int temp; int temp;
gPrefs->Read(wxT("/Spectrum/ScaleType"), &temp); gPrefs->Read(wxT("/Spectrum/ScaleType"), &temp, 0L);
scaleType = ScaleType(temp); scaleType = ScaleType(temp);
} }
#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH #ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
if (spectralSelection == defaults().spectralSelection) { if (spectralSelection == defaults().spectralSelection) {
int temp; int temp;
gPrefs->Read(wxT("/Spectrum/EnableSpectralSelection"), &temp); gPrefs->Read(wxT("/Spectrum/EnableSpectralSelection"), &temp, 0L);
spectralSelection = (temp != 0); spectralSelection = (temp != 0);
} }
#endif #endif
if (algorithm == defaults().algorithm) { if (algorithm == defaults().algorithm) {
int temp; int temp;
gPrefs->Read(wxT("/Spectrum/Algorithm"), &temp); gPrefs->Read(wxT("/Spectrum/Algorithm"), &temp, 0L);
algorithm = Algorithm(temp); algorithm = Algorithm(temp);
} }
#ifdef EXPERIMENTAL_FFT_Y_GRID #ifdef EXPERIMENTAL_FFT_Y_GRID
if (fftYGrid == defaults().fftYGrid) { if (fftYGrid == defaults().fftYGrid) {
int temp; int temp;
gPrefs->Read(wxT("/Spectrum/FFTYGrid"), &temp); gPrefs->Read(wxT("/Spectrum/FFTYGrid"), &temp, 0L);
fftYGrid = (temp != 0); fftYGrid = (temp != 0);
} }
#endif //EXPERIMENTAL_FFT_Y_GRID #endif //EXPERIMENTAL_FFT_Y_GRID
@ -401,21 +401,21 @@ void SpectrogramSettings::UpdatePrefs()
#ifdef EXPERIMENTAL_FIND_NOTES #ifdef EXPERIMENTAL_FIND_NOTES
if (fftFindNotes == defaults().fftFindNotes) { if (fftFindNotes == defaults().fftFindNotes) {
int temp; int temp;
gPrefs->Read(wxT("/Spectrum/FFTFindNotes"), &temp); gPrefs->Read(wxT("/Spectrum/FFTFindNotes"), &temp, 0L);
fftFindNotes = (temp != 0); fftFindNotes = (temp != 0);
} }
if (findNotesMinA == defaults().findNotesMinA) { if (findNotesMinA == defaults().findNotesMinA) {
gPrefs->Read(wxT("/Spectrum/FindNotesMinA"), &findNotesMinA); gPrefs->Read(wxT("/Spectrum/FindNotesMinA"), &findNotesMinA, -30.0);
} }
if (numberOfMaxima == defaults().numberOfMaxima) { if (numberOfMaxima == defaults().numberOfMaxima) {
numberOfMaxima = gPrefs->Read(wxT("/Spectrum/FindNotesN"), &numberOfMaxima); numberOfMaxima = gPrefs->Read(wxT("/Spectrum/FindNotesN"), &numberOfMaxima, 5L);
} }
if (findNotesQuantize == defaults().findNotesQuantize) { if (findNotesQuantize == defaults().findNotesQuantize) {
int temp; int temp;
gPrefs->Read(wxT("/Spectrum/FindNotesQuantize"), &temp); gPrefs->Read(wxT("/Spectrum/FindNotesQuantize"), &temp, 0L);
findNotesQuantize = (temp != 0); findNotesQuantize = (temp != 0);
} }
#endif //EXPERIMENTAL_FIND_NOTES #endif //EXPERIMENTAL_FIND_NOTES