1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-24 16:20:05 +02:00

Safe copy constructor and assignment for SpectrogramSettings

This commit is contained in:
Paul Licameli 2015-06-15 10:36:17 -04:00
parent 786c1da645
commit 778e7726df
2 changed files with 66 additions and 0 deletions

View File

@ -26,6 +26,69 @@ SpectrogramSettings::SpectrogramSettings()
UpdatePrefs(); UpdatePrefs();
} }
SpectrogramSettings::SpectrogramSettings(const SpectrogramSettings &other)
: minFreq(other.minFreq)
, maxFreq(other.maxFreq)
, logMinFreq(other.logMinFreq)
, logMaxFreq(other.logMaxFreq)
, range(other.range)
, gain(other.gain)
, frequencyGain(other.frequencyGain)
, windowType(other.windowType)
, windowSize(other.windowSize)
#ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
, zeroPaddingFactor(other.zeroPaddingFactor)
#endif
, isGrayscale(other.isGrayscale)
#ifdef EXPERIMENTAL_FFT_Y_GRID
, fftYGrid(other.fftYGrid)
#endif
#ifdef EXPERIMENTAL_FIND_NOTES
, fftFindNotes(other.fftFindNotes)
, findNotesMinA(other.findNotesMinA)
, numberOfMaxima(other.numberOfMaxima)
, findNotesQuantize(other.findNotesQuantize)
#endif
// Do not copy these!
, hFFT(0)
, window(0)
{
}
SpectrogramSettings &SpectrogramSettings::operator= (const SpectrogramSettings &other)
{
if (this != &other) {
minFreq = other.minFreq;
maxFreq = other.maxFreq;
logMinFreq = other.logMinFreq;
logMaxFreq = other.logMaxFreq;
range = other.range;
gain = other.gain;
frequencyGain = other.frequencyGain;
windowType = other.windowType;
windowSize = other.windowSize;
#ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
zeroPaddingFactor = other.zeroPaddingFactor;
#endif
isGrayscale = other.isGrayscale;
#ifdef EXPERIMENTAL_FFT_Y_GRID
fftYGrid = other.fftYGrid;
#endif
#ifdef EXPERIMENTAL_FIND_NOTES
fftFindNotes = other.fftFindNotes;
findNotesMinA = other.findNotesMinA;
numberOfMaxima = other.numberOfMaxima;
findNotesQuantize = other.findNotesQuantize;
#endif
// Do not copy these!
hFFT = 0;
window = 0;
}
return *this;
}
SpectrogramSettings& SpectrogramSettings::defaults() SpectrogramSettings& SpectrogramSettings::defaults()
{ {
static SpectrogramSettings instance; static SpectrogramSettings instance;
@ -112,6 +175,7 @@ void SpectrogramSettings::DestroyWindows()
#endif #endif
} }
namespace namespace
{ {
enum { WINDOW, TWINDOW, DWINDOW }; enum { WINDOW, TWINDOW, DWINDOW };

View File

@ -20,6 +20,8 @@ class SpectrogramSettings
public: public:
static SpectrogramSettings &defaults(); static SpectrogramSettings &defaults();
SpectrogramSettings(); SpectrogramSettings();
SpectrogramSettings(const SpectrogramSettings &other);
SpectrogramSettings& operator= (const SpectrogramSettings &other);
~SpectrogramSettings(); ~SpectrogramSettings();
void UpdatePrefs(); void UpdatePrefs();