Audacity  3.0.3
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Private Attributes | Friends | List of all members
SpectrogramSettings Class Reference

Spectrogram settings, either for one track or as defaults. More...

#include <SpectrogramSettings.h>

Inheritance diagram for SpectrogramSettings:
[legend]
Collaboration diagram for SpectrogramSettings:
[legend]

Classes

class  ColorSchemeEnumSetting
 
class  Globals
 

Public Types

enum  { LogMinWindowSize = 3, LogMaxWindowSize = 15, NumWindowSizes = LogMaxWindowSize - LogMinWindowSize + 1 }
 
enum  ScaleTypeValues : int {
  stLinear, stLogarithmic, stMel, stBark,
  stErb, stPeriod, stNumScaleTypes
}
 
enum  ColorScheme : int {
  csColorNew = 0, csColorTheme, csGrayscale, csInvGrayscale,
  csNumColorScheme
}
 
enum  AlgorithmValues : int { algSTFT = 0, algReassignment, algPitchEAC, algNumAlgorithms }
 
typedef int ScaleType
 
typedef int Algorithm
 

Public Member Functions

 SpectrogramSettings ()
 
 SpectrogramSettings (const SpectrogramSettings &other)
 
SpectrogramSettingsoperator= (const SpectrogramSettings &other)
 
 ~SpectrogramSettings ()
 
bool IsDefault () const
 
bool Validate (bool quiet)
 
void LoadPrefs ()
 
void SavePrefs ()
 
void UpdatePrefs () override
 
void InvalidateCaches ()
 
void DestroyWindows ()
 
void CacheWindows () const
 
void ConvertToEnumeratedWindowSizes ()
 
void ConvertToActualWindowSizes ()
 
float findBin (float frequency, float binUnit) const
 
NumberScale GetScale (float minFreq, float maxFreq) const
 
bool SpectralSelectionEnabled () const
 
size_t WindowSize () const
 
size_t ZeroPaddingFactor () const
 
size_t GetFFTLength () const
 
size_t NBins () const
 
- Public Member Functions inherited from PrefsListener
 PrefsListener ()
 
virtual ~PrefsListener ()
 

Static Public Member Functions

static const EnumValueSymbolsGetScaleNames ()
 
static const EnumValueSymbolsGetColorSchemeNames ()
 
static const TranslatableStringsGetAlgorithmNames ()
 
static SpectrogramSettingsdefaults ()
 
- Static Public Member Functions inherited from PrefsListener
static void Broadcast (int id=0)
 Call this static function to notify all PrefsListener objects. More...
 

Public Attributes

int minFreq
 
int maxFreq
 
int range
 
int gain
 
int frequencyGain
 
int windowType
 
ColorScheme colorScheme
 
ScaleType scaleType
 
bool spectralSelection
 
Algorithm algorithm
 
HFFT hFFT
 
Floats window
 
Floats tWindow
 
Floats dWindow
 

Static Public Attributes

static ColorSchemeEnumSetting colorSchemeSetting
 

Private Attributes

int windowSize
 
int zeroPaddingFactor
 

Friends

class SpectrumPrefs
 

Additional Inherited Members

- Protected Member Functions inherited from PrefsListener
virtual void UpdateSelectedPrefs (int id)
 

Detailed Description

Spectrogram settings, either for one track or as defaults.

Definition at line 26 of file SpectrogramSettings.h.

Member Typedef Documentation

◆ Algorithm

Definition at line 153 of file SpectrogramSettings.h.

◆ ScaleType

Definition at line 57 of file SpectrogramSettings.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
LogMinWindowSize 
LogMaxWindowSize 
NumWindowSizes 

Definition at line 47 of file SpectrogramSettings.h.

47  {
48  LogMinWindowSize = 3,
49  LogMaxWindowSize = 15,
50 
52  };

◆ AlgorithmValues

Enumerator
algSTFT 
algReassignment 
algPitchEAC 
algNumAlgorithms 

Definition at line 154 of file SpectrogramSettings.h.

154  : int {
155  algSTFT = 0,
157  algPitchEAC,
158 
160  };

◆ ColorScheme

Enumerator
csColorNew 
csColorTheme 
csGrayscale 
csInvGrayscale 
csNumColorScheme 

Definition at line 130 of file SpectrogramSettings.h.

130  : int {
131  // Keep in correspondence with AColor::colorSchemes, AColor::gradient_pre
132  csColorNew = 0,
133  csColorTheme,
134  csGrayscale,
136 
138  };

◆ ScaleTypeValues

Enumerator
stLinear 
stLogarithmic 
stMel 
stBark 
stErb 
stPeriod 
stNumScaleTypes 

Definition at line 58 of file SpectrogramSettings.h.

58  : int {
59  stLinear,
61  stMel,
62  stBark,
63  stErb,
64  stPeriod,
65 
67  };

Constructor & Destructor Documentation

◆ SpectrogramSettings() [1/2]

SpectrogramSettings::SpectrogramSettings ( )

Definition at line 106 of file SpectrogramSettings.cpp.

107 {
108  LoadPrefs();
109 }

References LoadPrefs().

Here is the call graph for this function:

◆ SpectrogramSettings() [2/2]

SpectrogramSettings::SpectrogramSettings ( const SpectrogramSettings other)

Definition at line 111 of file SpectrogramSettings.cpp.

112  : minFreq(other.minFreq)
113  , maxFreq(other.maxFreq)
114  , range(other.range)
115  , gain(other.gain)
117  , windowType(other.windowType)
118  , windowSize(other.windowSize)
120  , colorScheme(other.colorScheme)
121  , scaleType(other.scaleType)
122 #ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
124 #endif
125  , algorithm(other.algorithm)
126 #ifdef EXPERIMENTAL_FFT_Y_GRID
127  , fftYGrid(other.fftYGrid)
128 #endif
129 #ifdef EXPERIMENTAL_FIND_NOTES
130  , fftFindNotes(other.fftFindNotes)
131  , findNotesMinA(other.findNotesMinA)
132  , numberOfMaxima(other.numberOfMaxima)
133  , findNotesQuantize(other.findNotesQuantize)
134 #endif
135 
136  // Do not copy these!
137  , hFFT{}
138  , window{}
139  , tWindow{}
140  , dWindow{}
141 {
142 }

◆ ~SpectrogramSettings()

SpectrogramSettings::~SpectrogramSettings ( )

Definition at line 482 of file SpectrogramSettings.cpp.

483 {
484  DestroyWindows();
485 }

References DestroyWindows().

Here is the call graph for this function:

Member Function Documentation

◆ CacheWindows()

void SpectrogramSettings::CacheWindows ( ) const

Definition at line 552 of file SpectrogramSettings.cpp.

553 {
554  if (hFFT == NULL || window == NULL) {
555 
556  double scale;
557  auto factor = ZeroPaddingFactor();
558  const auto fftLen = WindowSize() * factor;
559  const auto padding = (WindowSize() * (factor - 1)) / 2;
560 
561  hFFT = GetFFT(fftLen);
562  RecreateWindow(window, WINDOW, fftLen, padding, windowType, windowSize, scale);
563  if (algorithm == algReassignment) {
564  RecreateWindow(tWindow, TWINDOW, fftLen, padding, windowType, windowSize, scale);
565  RecreateWindow(dWindow, DWINDOW, fftLen, padding, windowType, windowSize, scale);
566  }
567  }
568 }

References algorithm, algReassignment, anonymous_namespace{SpectrogramSettings.cpp}::DWINDOW, dWindow, GetFFT(), hFFT, anonymous_namespace{SpectrogramSettings.cpp}::RecreateWindow(), anonymous_namespace{SpectrogramSettings.cpp}::TWINDOW, tWindow, anonymous_namespace{SpectrogramSettings.cpp}::WINDOW, window, windowSize, WindowSize(), windowType, and ZeroPaddingFactor().

Here is the call graph for this function:

◆ ConvertToActualWindowSizes()

void SpectrogramSettings::ConvertToActualWindowSizes ( )

Definition at line 592 of file SpectrogramSettings.cpp.

593 {
596 }

References LogMinWindowSize, windowSize, and zeroPaddingFactor.

Referenced by SpectrumPrefs::Preview(), SpectrumPrefs::Validate(), and Validate().

Here is the caller graph for this function:

◆ ConvertToEnumeratedWindowSizes()

void SpectrogramSettings::ConvertToEnumeratedWindowSizes ( )

Definition at line 570 of file SpectrogramSettings.cpp.

571 {
572  unsigned size;
573  int logarithm;
574 
575  logarithm = -LogMinWindowSize;
576  size = unsigned(windowSize);
577  while (size > 1)
578  size >>= 1, ++logarithm;
579  windowSize = std::max(0, std::min(NumWindowSizes - 1, logarithm));
580 
581  // Choices for zero padding begin at 1
582  logarithm = 0;
583  size = unsigned(zeroPaddingFactor);
584  while (zeroPaddingFactor > 1)
585  zeroPaddingFactor >>= 1, ++logarithm;
586  zeroPaddingFactor = std::max(0,
588  logarithm
589  ));
590 }

References LogMaxWindowSize, LogMinWindowSize, min(), NumWindowSizes, size, windowSize, and zeroPaddingFactor.

Referenced by SpectrumPrefs::OnDefaults(), SpectrumPrefs::Preview(), SpectrumPrefs::Validate(), and Validate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ defaults()

SpectrogramSettings & SpectrogramSettings::defaults ( )
static

Definition at line 177 of file SpectrogramSettings.cpp.

178 {
179  static SpectrogramSettings instance;
180  return instance;
181 }

Referenced by SpectrumPrefs::Commit(), WaveTrack::GetIndependentSpectrogramSettings(), WaveTrack::GetSpectrogramSettings(), SpectrumPrefs::OnDefaults(), SpectrumPrefs::Preview(), SpectrumPrefs::Rollback(), and UpdatePrefs().

Here is the caller graph for this function:

◆ DestroyWindows()

void SpectrogramSettings::DestroyWindows ( )

Definition at line 487 of file SpectrogramSettings.cpp.

488 {
489  hFFT.reset();
490  window.reset();
491  dWindow.reset();
492  tWindow.reset();
493 }

References dWindow, hFFT, tWindow, and window.

Referenced by InvalidateCaches(), operator=(), and ~SpectrogramSettings().

Here is the caller graph for this function:

◆ findBin()

float SpectrogramSettings::findBin ( float  frequency,
float  binUnit 
) const

Definition at line 598 of file SpectrogramSettings.cpp.

599 {
600  float linearBin = frequency / binUnit;
601  if (linearBin < 0)
602  return -1;
603  else
604  return linearBin;
605 }

◆ GetAlgorithmNames()

const TranslatableStrings & SpectrogramSettings::GetAlgorithmNames ( )
static

Definition at line 244 of file SpectrogramSettings.cpp.

245 {
246  static const TranslatableStrings results{
247  // Keep in correspondence with enum SpectrogramSettings::Algorithm:
248  XO("Frequencies") ,
249  /* i18n-hint: the Reassignment algorithm for spectrograms */
250  XO("Reassignment") ,
251  /* i18n-hint: EAC abbreviates "Enhanced Autocorrelation" */
252  XO("Pitch (EAC)") ,
253  };
254  return results;
255 }

References XO.

Referenced by SpectrumPrefs::PopulateOrExchange().

Here is the caller graph for this function:

◆ GetColorSchemeNames()

const EnumValueSymbols & SpectrogramSettings::GetColorSchemeNames ( )
static

Definition at line 203 of file SpectrogramSettings.cpp.

204 {
205  static const EnumValueSymbols result{
206  // Keep in correspondence with enum SpectrogramSettings::ColorScheme:
207  /* i18n-hint: New color scheme for spectrograms */
208  { wxT("SpecColorNew"), XC("Color (default)", "spectrum prefs") },
209  /* i18n-hint: Classic color scheme(from theme) for spectrograms */
210  { wxT("SpecColorTheme"), XC("Color (classic)", "spectrum prefs") },
211  /* i18n-hint: Grayscale color scheme for spectrograms */
212  { wxT("SpecGrayscale"), XC("Grayscale", "spectrum prefs") },
213  /* i18n-hint: Inverse grayscale color scheme for spectrograms */
214  { wxT("SpecInvGrayscale"), XC("Inverse grayscale", "spectrum prefs") },
215  };
216 
217  wxASSERT(csNumColorScheme == result.size());
218  static_assert(csNumColorScheme == AColor::colorSchemes, "Broken correspondence");
219 
220  return result;
221 }

References AColor::colorSchemes, csNumColorScheme, and XC.

Referenced by SetTrackVisualsCommand::DefineParams(), SpectrogramSettings::ColorSchemeEnumSetting::Migrate(), SetTrackVisualsCommand::PopulateOrExchange(), and SpectrumPrefs::PopulateOrExchange().

Here is the caller graph for this function:

◆ GetFFTLength()

size_t SpectrogramSettings::GetFFTLength ( ) const

Definition at line 607 of file SpectrogramSettings.cpp.

608 {
609 //#ifndef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
610  // return windowSize;
611 //#else
612  return windowSize * ((algorithm != algPitchEAC) ? zeroPaddingFactor : 1);
613 //#endif
614 }

References algorithm, algPitchEAC, windowSize, and zeroPaddingFactor.

Referenced by SpectrumVZoomHandle::DoZoom(), and NBins().

Here is the caller graph for this function:

◆ GetScale()

NumberScale SpectrogramSettings::GetScale ( float  minFreq,
float  maxFreq 
) const

Definition at line 622 of file SpectrogramSettings.cpp.

623 {
624  NumberScaleType type = nstLinear;
625 
626  // Don't assume the correspondence of the enums will remain direct in the future.
627  // Do this switch.
628  switch (scaleType) {
629  default:
630  wxASSERT(false);
631  case stLinear:
632  type = nstLinear; break;
633  case stLogarithmic:
634  type = nstLogarithmic; break;
635  case stMel:
636  type = nstMel; break;
637  case stBark:
638  type = nstBark; break;
639  case stErb:
640  type = nstErb; break;
641  case stPeriod:
642  type = nstPeriod; break;
643  }
644 
645  return NumberScale(type, minFreqIn, maxFreqIn);
646 }

References nstBark, nstErb, nstLinear, nstLogarithmic, nstMel, nstPeriod, scaleType, stBark, stErb, stLinear, stLogarithmic, stMel, and stPeriod.

Referenced by SpectrumVRulerControls::DoUpdateVRuler(), and SpectrumVZoomHandle::DoZoom().

Here is the caller graph for this function:

◆ GetScaleNames()

const EnumValueSymbols & SpectrogramSettings::GetScaleNames ( )
static

Definition at line 184 of file SpectrogramSettings.cpp.

185 {
186  static const EnumValueSymbols result{
187  // Keep in correspondence with enum SpectrogramSettings::ScaleType:
188  XO("Linear") ,
189  XO("Logarithmic") ,
190  /* i18n-hint: The name of a frequency scale in psychoacoustics */
191  XO("Mel") ,
192  /* i18n-hint: The name of a frequency scale in psychoacoustics, named for Heinrich Barkhausen */
193  XO("Bark") ,
194  /* i18n-hint: The name of a frequency scale in psychoacoustics, abbreviates Equivalent Rectangular Bandwidth */
195  XO("ERB") ,
196  /* i18n-hint: Time units, that is Period = 1 / Frequency */
197  XO("Period") ,
198  };
199  return result;
200 }

References XO.

Referenced by BeginSection(), and SpectrumPrefs::PopulateOrExchange().

Here is the caller graph for this function:

◆ InvalidateCaches()

void SpectrogramSettings::InvalidateCaches ( )

Definition at line 477 of file SpectrogramSettings.cpp.

478 {
479  DestroyWindows();
480 }

References DestroyWindows().

Referenced by LoadPrefs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsDefault()

bool SpectrogramSettings::IsDefault ( ) const
inline

Definition at line 79 of file SpectrogramSettings.h.

80  {
81  return this == &defaults();
82  }

◆ LoadPrefs()

void SpectrogramSettings::LoadPrefs ( )

Definition at line 328 of file SpectrogramSettings.cpp.

329 {
331 
333 
335  gain = SpectrumGain.Read();
337 
339 
341 
343 
345 
346  scaleType = static_cast<ScaleType>(SpectrumScale.Read());
347 
348 #ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
350 #endif
351 
352  algorithm = static_cast<Algorithm>(SpectrumAlgorithm.Read());
353 
354 #ifdef EXPERIMENTAL_FFT_Y_GRID
355  fftYGrid = SpectrumYGrid.Read();
356 #endif //EXPERIMENTAL_FFT_Y_GRID
357 
358 #ifdef EXPERIMENTAL_FIND_NOTES
359  fftFindNotes = SpectrumFindNotes.Read();
360  findNotesMinA = SpectrumFindNotesMinA.Read();
361  numberOfMaxima = SpectrumFindNotesN.Read();
362  findNotesQuantize = SpectrumFindNotesQuantize.Read();
363 #endif //EXPERIMENTAL_FIND_NOTES
364 
365  // Enforce legal values
366  Validate(true);
367 
369 }

References algorithm, colorScheme, colorSchemeSetting, frequencyGain, gain, InvalidateCaches(), maxFreq, minFreq, range, Setting< T >::Read(), EnumSetting< Enum >::ReadEnum(), scaleType, spectralSelection, anonymous_namespace{SpectrogramSettings.cpp}::SpectrumAlgorithm, anonymous_namespace{SpectrogramSettings.cpp}::SpectrumEnableSelection, anonymous_namespace{SpectrogramSettings.cpp}::SpectrumFFTSize, anonymous_namespace{SpectrogramSettings.cpp}::SpectrumFrequencyGain, anonymous_namespace{SpectrogramSettings.cpp}::SpectrumGain, SpectrumMaxFreq, anonymous_namespace{SpectrogramSettings.cpp}::SpectrumMinFreq, anonymous_namespace{SpectrogramSettings.cpp}::SpectrumRange, anonymous_namespace{SpectrogramSettings.cpp}::SpectrumScale, anonymous_namespace{SpectrogramSettings.cpp}::SpectrumWindowFunction, anonymous_namespace{SpectrogramSettings.cpp}::SpectrumZeroPaddingFactor, Validate(), windowSize, windowType, and zeroPaddingFactor.

Referenced by SpectrumPrefs::Commit(), and SpectrogramSettings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NBins()

size_t SpectrogramSettings::NBins ( ) const

Definition at line 616 of file SpectrogramSettings.cpp.

617 {
618  // Omit the Nyquist frequency bin
619  return GetFFTLength() / 2;
620 }

References GetFFTLength().

Here is the call graph for this function:

◆ operator=()

SpectrogramSettings & SpectrogramSettings::operator= ( const SpectrogramSettings other)

Definition at line 144 of file SpectrogramSettings.cpp.

145 {
146  if (this != &other) {
147  minFreq = other.minFreq;
148  maxFreq = other.maxFreq;
149  range = other.range;
150  gain = other.gain;
152  windowType = other.windowType;
153  windowSize = other.windowSize;
155  colorScheme = other.colorScheme;
156  scaleType = other.scaleType;
157 #ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
159 #endif
160  algorithm = other.algorithm;
161 #ifdef EXPERIMENTAL_FFT_Y_GRID
162  fftYGrid = other.fftYGrid;
163 #endif
164 #ifdef EXPERIMENTAL_FIND_NOTES
165  fftFindNotes = other.fftFindNotes;
166  findNotesMinA = other.findNotesMinA;
167  numberOfMaxima = other.numberOfMaxima;
168  findNotesQuantize = other.findNotesQuantize;
169 #endif
170 
171  // Invalidate the caches
172  DestroyWindows();
173  }
174  return *this;
175 }

References algorithm, colorScheme, DestroyWindows(), frequencyGain, gain, maxFreq, minFreq, range, scaleType, spectralSelection, windowSize, windowType, and zeroPaddingFactor.

Here is the call graph for this function:

◆ SavePrefs()

void SpectrogramSettings::SavePrefs ( )

Definition at line 371 of file SpectrogramSettings.cpp.

372 {
375 
376  // Nothing wrote these. They only varied from the linear scale bounds in-session. -- PRL
377  // gPrefs->Write(wxT("/SpectrumLog/MaxFreq"), logMinFreq);
378  // gPrefs->Write(wxT("/SpectrumLog/MinFreq"), logMaxFreq);
379 
383 
385 
387 
389 
391 
392  SpectrumScale.Write(static_cast<int>(scaleType));
393 
394 #ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
396 #endif
397 
398  SpectrumAlgorithm.Write(static_cast<int>(algorithm));
399 
400 #ifdef EXPERIMENTAL_FFT_Y_GRID
401  SpectrumYGrid.Write(fftYGrid);
402 #endif //EXPERIMENTAL_FFT_Y_GRID
403 
404 #ifdef EXPERIMENTAL_FIND_NOTES
405  SpectrumFindNotes.Write(fftFindNotes);
406  SpectrumFindNotesMinA.Write(findNotesMinA);
407  SpectrumFindNotesN.Write(numberOfMaxima);
408  SpectrumFindNotesQuantize.Write(findNotesQuantize);
409 #endif //EXPERIMENTAL_FIND_NOTES
410 }

References algorithm, colorScheme, colorSchemeSetting, frequencyGain, gain, maxFreq, minFreq, range, scaleType, spectralSelection, anonymous_namespace{SpectrogramSettings.cpp}::SpectrumAlgorithm, anonymous_namespace{SpectrogramSettings.cpp}::SpectrumEnableSelection, anonymous_namespace{SpectrogramSettings.cpp}::SpectrumFFTSize, anonymous_namespace{SpectrogramSettings.cpp}::SpectrumFrequencyGain, anonymous_namespace{SpectrogramSettings.cpp}::SpectrumGain, SpectrumMaxFreq, anonymous_namespace{SpectrogramSettings.cpp}::SpectrumMinFreq, anonymous_namespace{SpectrogramSettings.cpp}::SpectrumRange, anonymous_namespace{SpectrogramSettings.cpp}::SpectrumScale, anonymous_namespace{SpectrogramSettings.cpp}::SpectrumWindowFunction, anonymous_namespace{SpectrogramSettings.cpp}::SpectrumZeroPaddingFactor, windowSize, windowType, Setting< T >::Write(), EnumSetting< Enum >::WriteEnum(), and zeroPaddingFactor.

Referenced by SpectrumPrefs::Commit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SpectralSelectionEnabled()

bool SpectrogramSettings::SpectralSelectionEnabled ( ) const

Definition at line 648 of file SpectrogramSettings.cpp.

649 {
650 #ifdef SPECTRAL_SELECTION_GLOBAL_SWITCH
651  return Globals::Get().spectralSelection;
652 #else
653  return spectralSelection;
654 #endif
655 }

References SpectrogramSettings::Globals::Get(), and spectralSelection.

Referenced by NyquistEffect::ProcessOne().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdatePrefs()

void SpectrogramSettings::UpdatePrefs ( )
overridevirtual

Implements PrefsListener.

Definition at line 413 of file SpectrogramSettings.cpp.

414 {
415  if (minFreq == defaults().minFreq)
417 
418  if (maxFreq == defaults().maxFreq)
420 
421  if (range == defaults().range)
423 
424  if (gain == defaults().gain)
425  gain = SpectrumGain.Read();
426 
429 
430  if (windowSize == defaults().windowSize)
432 
435 
436  if (windowType == defaults().windowType)
438 
439  if (colorScheme == defaults().colorScheme) {
441  }
442 
443  if (scaleType == defaults().scaleType)
444  scaleType = static_cast<ScaleType>(SpectrumScale.Read());
445 
446 #ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
449 #endif
450 
451  if (algorithm == defaults().algorithm)
452  algorithm = static_cast<Algorithm>(SpectrumAlgorithm.Read());
453 
454 #ifdef EXPERIMENTAL_FFT_Y_GRID
455  if (fftYGrid == defaults().fftYGrid)
456  fftYGrid = SpectrumYGrid.Read();
457 #endif //EXPERIMENTAL_FFT_Y_GRID
458 
459 #ifdef EXPERIMENTAL_FIND_NOTES
460  if (fftFindNotes == defaults().fftFindNotes)
461  fftFindNotes = SpectrumFindNotes.Read();
462 
463  if (findNotesMinA == defaults().findNotesMinA)
464  findNotesMinA = SpectrumFindNotesMinA.Read();
465 
466  if (numberOfMaxima == defaults().numberOfMaxima)
467  numberOfMaxima = SpectrumFindNotesN.Read();
468 
469  if (findNotesQuantize == defaults().findNotesQuantize)
470  findNotesQuantize = SpectrumFindNotesQuantize.Read();
471 #endif //EXPERIMENTAL_FIND_NOTES
472 
473  // Enforce legal values
474  Validate(true);
475 }

References algorithm, colorScheme, colorSchemeSetting, defaults(), frequencyGain, gain, maxFreq, minFreq, range, Setting< T >::Read(), EnumSetting< Enum >::ReadEnum(), scaleType, spectralSelection, anonymous_namespace{SpectrogramSettings.cpp}::SpectrumAlgorithm, anonymous_namespace{SpectrogramSettings.cpp}::SpectrumEnableSelection, anonymous_namespace{SpectrogramSettings.cpp}::SpectrumFFTSize, anonymous_namespace{SpectrogramSettings.cpp}::SpectrumFrequencyGain, anonymous_namespace{SpectrogramSettings.cpp}::SpectrumGain, SpectrumMaxFreq, anonymous_namespace{SpectrogramSettings.cpp}::SpectrumMinFreq, anonymous_namespace{SpectrogramSettings.cpp}::SpectrumRange, anonymous_namespace{SpectrogramSettings.cpp}::SpectrumScale, anonymous_namespace{SpectrogramSettings.cpp}::SpectrumWindowFunction, anonymous_namespace{SpectrogramSettings.cpp}::SpectrumZeroPaddingFactor, Validate(), windowSize, windowType, and zeroPaddingFactor.

Here is the call graph for this function:

◆ Validate()

bool SpectrogramSettings::Validate ( bool  quiet)

Definition at line 257 of file SpectrogramSettings.cpp.

258 {
259  if (!quiet &&
260  maxFreq < 100) {
261  AudacityMessageBox( XO("Maximum frequency must be 100 Hz or above") );
262  return false;
263  }
264  else
265  maxFreq = std::max(100, maxFreq);
266 
267  if (!quiet &&
268  minFreq < 0) {
269  AudacityMessageBox( XO("Minimum frequency must be at least 0 Hz") );
270  return false;
271  }
272  else
273  minFreq = std::max(0, minFreq);
274 
275  if (!quiet &&
276  maxFreq <= minFreq) {
278 "Minimum frequency must be less than maximum frequency") );
279  return false;
280  }
281  else
282  maxFreq = std::max(1 + minFreq, maxFreq);
283 
284  if (!quiet &&
285  range <= 0) {
286  AudacityMessageBox( XO("The range must be at least 1 dB") );
287  return false;
288  }
289  else
290  range = std::max(1, range);
291 
292  if (!quiet &&
293  frequencyGain < 0) {
294  AudacityMessageBox( XO("The frequency gain cannot be negative") );
295  return false;
296  }
297  else if (!quiet &&
298  frequencyGain > 60) {
300 "The frequency gain must be no more than 60 dB/dec") );
301  return false;
302  }
303  else
304  frequencyGain =
305  std::max(0, std::min(60, frequencyGain));
306 
307  // The rest are controlled by drop-down menus so they can't go wrong
308  // in the Preferences dialog, but we also come here after reading fom saved
309  // preference files, which could be or from future versions. Validate quietly.
310  windowType =
311  std::max(0, std::min(NumWindowFuncs() - 1, windowType));
312  scaleType =
313  ScaleType(std::max(0,
315  (int)(scaleType))));
317  std::max(0, std::min<int>(csNumColorScheme-1, colorScheme))
318  );
320  std::max(0, std::min((int)(algNumAlgorithms) - 1, (int)(algorithm)))
321  );
324 
325  return true;
326 }

References algNumAlgorithms, algorithm, AudacityMessageBox(), colorScheme, ConvertToActualWindowSizes(), ConvertToEnumeratedWindowSizes(), csNumColorScheme, frequencyGain, maxFreq, min(), minFreq, NumWindowFuncs(), range, scaleType, stNumScaleTypes, windowType, and XO.

Referenced by LoadPrefs(), UpdatePrefs(), and SpectrumPrefs::Validate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WindowSize()

size_t SpectrogramSettings::WindowSize ( ) const
inline

Definition at line 118 of file SpectrogramSettings.h.

118 { return windowSize; }

Referenced by CacheWindows().

Here is the caller graph for this function:

◆ ZeroPaddingFactor()

size_t SpectrogramSettings::ZeroPaddingFactor ( ) const
inline

Definition at line 123 of file SpectrogramSettings.h.

123  {
124  return algorithm == algPitchEAC ? 1 : zeroPaddingFactor;
125  }

Referenced by CacheWindows().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ SpectrumPrefs

friend class SpectrumPrefs
friend

Definition at line 28 of file SpectrogramSettings.h.

Member Data Documentation

◆ algorithm

Algorithm SpectrogramSettings::algorithm

◆ colorScheme

ColorScheme SpectrogramSettings::colorScheme

◆ colorSchemeSetting

SpectrogramSettings::ColorSchemeEnumSetting SpectrogramSettings::colorSchemeSetting
static
Initial value:
{
wxT("/Spectrum/ColorScheme"),
}

Definition at line 145 of file SpectrogramSettings.h.

Referenced by LoadPrefs(), SavePrefs(), and UpdatePrefs().

◆ dWindow

Floats SpectrogramSettings::dWindow
mutable

Definition at line 182 of file SpectrogramSettings.h.

Referenced by CacheWindows(), and DestroyWindows().

◆ frequencyGain

int SpectrogramSettings::frequencyGain

◆ gain

int SpectrogramSettings::gain

◆ hFFT

HFFT SpectrogramSettings::hFFT
mutable

Definition at line 177 of file SpectrogramSettings.h.

Referenced by CacheWindows(), and DestroyWindows().

◆ maxFreq

int SpectrogramSettings::maxFreq

◆ minFreq

int SpectrogramSettings::minFreq

◆ range

int SpectrogramSettings::range

◆ scaleType

ScaleType SpectrogramSettings::scaleType

◆ spectralSelection

bool SpectrogramSettings::spectralSelection

◆ tWindow

Floats SpectrogramSettings::tWindow
mutable

Definition at line 181 of file SpectrogramSettings.h.

Referenced by CacheWindows(), and DestroyWindows().

◆ window

Floats SpectrogramSettings::window
mutable

◆ windowSize

int SpectrogramSettings::windowSize
private

◆ windowType

int SpectrogramSettings::windowType

◆ zeroPaddingFactor

int SpectrogramSettings::zeroPaddingFactor
private

The documentation for this class was generated from the following files:
size
size_t size
Definition: ffmpeg-2.3.6-single-header.h:412
anonymous_namespace{SpectrogramSettings.cpp}::SpectrumZeroPaddingFactor
IntSetting SpectrumZeroPaddingFactor
Definition: SpectrogramSettings.cpp:60
nstMel
@ nstMel
Definition: NumberScale.h:20
anonymous_namespace{SpectrogramSettings.cpp}::SpectrumEnableSelection
BoolSetting SpectrumEnableSelection
Definition: SpectrogramSettings.cpp:46
SpectrogramSettings::maxFreq
int maxFreq
Definition: SpectrogramSettings.h:104
SpectrogramSettings
Spectrogram settings, either for one track or as defaults.
Definition: SpectrogramSettings.h:27
SpectrogramSettings::stErb
@ stErb
Definition: SpectrogramSettings.h:63
SpectrumMaxFreq
IntSetting SpectrumMaxFreq
Definition: SpectrogramSettings.cpp:31
SpectrogramSettings::windowType
int windowType
Definition: SpectrogramSettings.h:113
AudacityMessageBox
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
Definition: AudacityMessageBox.cpp:17
SpectrogramSettings::gain
int gain
Definition: SpectrogramSettings.h:110
TranslatableStrings
std::vector< TranslatableString > TranslatableStrings
Definition: TranslatableString.h:295
SpectrogramSettings::colorSchemeSetting
static ColorSchemeEnumSetting colorSchemeSetting
Definition: SpectrogramSettings.h:145
SpectrogramSettings::stNumScaleTypes
@ stNumScaleTypes
Definition: SpectrogramSettings.h:66
SpectrogramSettings::LogMinWindowSize
@ LogMinWindowSize
Definition: SpectrogramSettings.h:48
Setting::Write
bool Write(const T &value)
Write value to config and return true if successful.
Definition: Prefs.h:172
anonymous_namespace{SpectrogramSettings.cpp}::WINDOW
@ WINDOW
Definition: SpectrogramSettings.cpp:498
SpectrogramSettings::Validate
bool Validate(bool quiet)
Definition: SpectrogramSettings.cpp:257
SpectrogramSettings::ZeroPaddingFactor
size_t ZeroPaddingFactor() const
Definition: SpectrogramSettings.h:123
NumWindowFuncs
int NumWindowFuncs()
Definition: FFT.cpp:329
SpectrogramSettings::stMel
@ stMel
Definition: SpectrogramSettings.h:61
nstLinear
@ nstLinear
Definition: NumberScale.h:18
XO
#define XO(s)
Definition: Internat.h:31
XC
#define XC(s, c)
Definition: Internat.h:37
SpectrogramSettings::GetColorSchemeNames
static const EnumValueSymbols & GetColorSchemeNames()
Definition: SpectrogramSettings.cpp:203
SpectrogramSettings::range
int range
Definition: SpectrogramSettings.h:109
SpectrogramSettings::DestroyWindows
void DestroyWindows()
Definition: SpectrogramSettings.cpp:487
SpectrogramSettings::algorithm
Algorithm algorithm
Definition: SpectrogramSettings.h:161
Setting::Read
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:128
SpectrogramSettings::stBark
@ stBark
Definition: SpectrogramSettings.h:62
anonymous_namespace{SpectrogramSettings.cpp}::DWINDOW
@ DWINDOW
Definition: SpectrogramSettings.cpp:498
SpectrogramSettings::csGrayscale
@ csGrayscale
Definition: SpectrogramSettings.h:134
SpectrogramSettings::Algorithm
int Algorithm
Definition: SpectrogramSettings.h:153
EnumValueSymbols
Definition: Prefs.h:239
SpectrogramSettings::algSTFT
@ algSTFT
Definition: SpectrogramSettings.h:155
anonymous_namespace{SpectrogramSettings.cpp}::SpectrumFrequencyGain
IntSetting SpectrumFrequencyGain
Definition: SpectrogramSettings.cpp:50
SpectrogramSettings::windowSize
int windowSize
Definition: SpectrogramSettings.h:116
anonymous_namespace{SpectrogramSettings.cpp}::SpectrumAlgorithm
IntSetting SpectrumAlgorithm
Definition: SpectrogramSettings.cpp:39
SpectrogramSettings::spectralSelection
bool spectralSelection
Definition: SpectrogramSettings.h:150
anonymous_namespace{SpectrogramSettings.cpp}::SpectrumMinFreq
IntSetting SpectrumMinFreq
Definition: SpectrogramSettings.cpp:56
anonymous_namespace{SpectrogramSettings.cpp}::SpectrumGain
IntSetting SpectrumGain
Definition: SpectrogramSettings.cpp:52
SpectrogramSettings::ColorScheme
ColorScheme
Definition: SpectrogramSettings.h:130
SpectrogramSettings::NumWindowSizes
@ NumWindowSizes
Definition: SpectrogramSettings.h:51
SpectrogramSettings::Globals::Get
static Globals & Get()
Definition: SpectrogramSettings.cpp:100
anonymous_namespace{SpectrogramSettings.cpp}::SpectrumWindowFunction
IntSetting SpectrumWindowFunction
Definition: SpectrogramSettings.cpp:43
SpectrogramSettings::InvalidateCaches
void InvalidateCaches()
Definition: SpectrogramSettings.cpp:477
SpectrogramSettings::GetFFTLength
size_t GetFFTLength() const
Definition: SpectrogramSettings.cpp:607
anonymous_namespace{SpectrogramSettings.cpp}::SpectrumFFTSize
IntSetting SpectrumFFTSize
Definition: SpectrogramSettings.cpp:48
SpectrogramSettings::ScaleType
int ScaleType
Definition: SpectrogramSettings.h:57
SpectrogramSettings::csInvGrayscale
@ csInvGrayscale
Definition: SpectrogramSettings.h:135
SpectrogramSettings::WindowSize
size_t WindowSize() const
Definition: SpectrogramSettings.h:118
SpectrogramSettings::scaleType
ScaleType scaleType
Definition: SpectrogramSettings.h:147
SpectrogramSettings::stLinear
@ stLinear
Definition: SpectrogramSettings.h:59
anonymous_namespace{SpectrogramSettings.cpp}::RecreateWindow
void RecreateWindow(Floats &window, int which, size_t fftLen, size_t padding, int windowType, size_t windowSize, double &scale)
Definition: SpectrogramSettings.cpp:499
SpectrogramSettings::csNumColorScheme
@ csNumColorScheme
Definition: SpectrogramSettings.h:137
SpectrogramSettings::stLogarithmic
@ stLogarithmic
Definition: SpectrogramSettings.h:60
SpectrogramSettings::LoadPrefs
void LoadPrefs()
Definition: SpectrogramSettings.cpp:328
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
SpectrogramSettings::colorScheme
ColorScheme colorScheme
Definition: SpectrogramSettings.h:139
nstPeriod
@ nstPeriod
Definition: NumberScale.h:23
nstBark
@ nstBark
Definition: NumberScale.h:21
EnumSetting::ReadEnum
Enum ReadEnum() const
Definition: Prefs.h:373
nstLogarithmic
@ nstLogarithmic
Definition: NumberScale.h:19
SpectrogramSettings::LogMaxWindowSize
@ LogMaxWindowSize
Definition: SpectrogramSettings.h:49
SpectrogramSettings::tWindow
Floats tWindow
Definition: SpectrogramSettings.h:181
SpectrogramSettings::algNumAlgorithms
@ algNumAlgorithms
Definition: SpectrogramSettings.h:159
nstErb
@ nstErb
Definition: NumberScale.h:22
SpectrogramSettings::algPitchEAC
@ algPitchEAC
Definition: SpectrogramSettings.h:157
SpectrogramSettings::window
Floats window
Definition: SpectrogramSettings.h:178
anonymous_namespace{SpectrogramSettings.cpp}::TWINDOW
@ TWINDOW
Definition: SpectrogramSettings.cpp:498
SpectrogramSettings::zeroPaddingFactor
int zeroPaddingFactor
Definition: SpectrogramSettings.h:121
SpectrogramSettings::algReassignment
@ algReassignment
Definition: SpectrogramSettings.h:156
anonymous_namespace{SpectrogramSettings.cpp}::SpectrumScale
IntSetting SpectrumScale
Definition: SpectrogramSettings.cpp:41
anonymous_namespace{SpectrogramSettings.cpp}::SpectrumRange
IntSetting SpectrumRange
Definition: SpectrogramSettings.cpp:58
AColor::colorSchemes
static const int colorSchemes
Definition: AColor.h:125
SpectrogramSettings::ConvertToActualWindowSizes
void ConvertToActualWindowSizes()
Definition: SpectrogramSettings.cpp:592
NumberScale
Definition: NumberScale.h:31
NumberScaleType
NumberScaleType
Definition: NumberScale.h:17
GetFFT
HFFT GetFFT(size_t fftlen)
Definition: RealFFTf.cpp:105
SpectrogramSettings::csColorNew
@ csColorNew
Definition: SpectrogramSettings.h:132
SpectrogramSettings::ConvertToEnumeratedWindowSizes
void ConvertToEnumeratedWindowSizes()
Definition: SpectrogramSettings.cpp:570
SpectrogramSettings::hFFT
HFFT hFFT
Definition: SpectrogramSettings.h:177
SpectrogramSettings::dWindow
Floats dWindow
Definition: SpectrogramSettings.h:182
SpectrogramSettings::csColorTheme
@ csColorTheme
Definition: SpectrogramSettings.h:133
SpectrogramSettings::stPeriod
@ stPeriod
Definition: SpectrogramSettings.h:64
SpectrogramSettings::frequencyGain
int frequencyGain
Definition: SpectrogramSettings.h:111
EnumSetting::WriteEnum
bool WriteEnum(Enum value)
Definition: Prefs.h:385
SpectrogramSettings::defaults
static SpectrogramSettings & defaults()
Definition: SpectrogramSettings.cpp:177
SpectrogramSettings::minFreq
int minFreq
Definition: SpectrogramSettings.h:103