Audacity 3.2.0
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 Types inherited from ClientData::Cloneable< ClientData::UniquePtr >
using Base = Cloneable
 
using PointerType = ClientData::UniquePtr< Base >
 

Public Member Functions

 SpectrogramSettings ()
 
 SpectrogramSettings (const SpectrogramSettings &other)
 
SpectrogramSettingsoperator= (const SpectrogramSettings &other)
 
 ~SpectrogramSettings ()
 
PointerType Clone () const override
 
bool IsDefault () const
 
bool Validate (bool quiet)
 
void LoadPrefs ()
 
void SavePrefs ()
 
void UpdatePrefs () override
 
void InvalidateCaches ()
 
void DestroyWindows ()
 
void CacheWindows ()
 
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 ()
 
virtual void UpdatePrefs ()=0
 
- Public Member Functions inherited from ClientData::Cloneable< ClientData::UniquePtr >
virtual ~Cloneable ()
 
virtual PointerType Clone () const=0
 

Static Public Member Functions

static const EnumValueSymbolsGetScaleNames ()
 
static const EnumValueSymbolsGetColorSchemeNames ()
 
static const TranslatableStringsGetAlgorithmNames ()
 
static SpectrogramSettingsGet (const WaveTrack &track)
 Mutative access to attachment even if the track argument is const. More...
 
static SpectrogramSettingsOwn (WaveTrack &track)
 
static void Reset (WaveTrack &track)
 Make track lose indpendent settings and use defaults. More...
 
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 28 of file SpectrogramSettings.h.

Member Typedef Documentation

◆ Algorithm

Definition at line 169 of file SpectrogramSettings.h.

◆ ScaleType

Definition at line 61 of file SpectrogramSettings.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
LogMinWindowSize 
LogMaxWindowSize 
NumWindowSizes 

Definition at line 51 of file SpectrogramSettings.h.

◆ AlgorithmValues

Enumerator
algSTFT 
algReassignment 
algPitchEAC 
algNumAlgorithms 

Definition at line 170 of file SpectrogramSettings.h.

◆ ColorScheme

Enumerator
csColorNew 
csColorTheme 
csGrayscale 
csInvGrayscale 
csNumColorScheme 

Definition at line 146 of file SpectrogramSettings.h.

146 : int {
147 // Keep in correspondence with AColor::colorSchemes, AColor::gradient_pre
148 csColorNew = 0,
152
154 };

◆ ScaleTypeValues

Enumerator
stLinear 
stLogarithmic 
stMel 
stBark 
stErb 
stPeriod 
stNumScaleTypes 

Definition at line 62 of file SpectrogramSettings.h.

Constructor & Destructor Documentation

◆ SpectrogramSettings() [1/2]

SpectrogramSettings::SpectrogramSettings ( )

Definition at line 141 of file SpectrogramSettings.cpp.

142{
143 LoadPrefs();
144}

References LoadPrefs().

Here is the call graph for this function:

◆ SpectrogramSettings() [2/2]

SpectrogramSettings::SpectrogramSettings ( const SpectrogramSettings other)

Definition at line 146 of file SpectrogramSettings.cpp.

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 // Do not copy these!
172 , hFFT{}
173 , window{}
174 , tWindow{}
175 , dWindow{}
176{
177}

◆ ~SpectrogramSettings()

SpectrogramSettings::~SpectrogramSettings ( )

Definition at line 517 of file SpectrogramSettings.cpp.

518{
520}

References DestroyWindows().

Here is the call graph for this function:

Member Function Documentation

◆ CacheWindows()

void SpectrogramSettings::CacheWindows ( )

Definition at line 592 of file SpectrogramSettings.cpp.

593{
594 if (hFFT == NULL || window == NULL) {
595
596 double scale;
597 auto factor = ZeroPaddingFactor();
598 const auto fftLen = WindowSize() * factor;
599 const auto padding = (WindowSize() * (factor - 1)) / 2;
600
601 hFFT = GetFFT(fftLen);
602 RecreateWindow(window, WINDOW, fftLen, padding, windowType, windowSize, scale);
603 if (algorithm == algReassignment) {
604 RecreateWindow(tWindow, TWINDOW, fftLen, padding, windowType, windowSize, scale);
605 RecreateWindow(dWindow, DWINDOW, fftLen, padding, windowType, windowSize, scale);
606 }
607 }
608}
HFFT GetFFT(size_t fftlen)
Definition: RealFFTf.cpp:104
size_t ZeroPaddingFactor() const
void RecreateWindow(Floats &window, int which, size_t fftLen, size_t padding, int windowType, size_t windowSize, double &scale)

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:

◆ Clone()

auto SpectrogramSettings::Clone ( ) const
overridevirtual

Implements ClientData::Cloneable< ClientData::UniquePtr >.

Definition at line 522 of file SpectrogramSettings.cpp.

523{
524 return std::make_unique<SpectrogramSettings>(*this);
525}

◆ ConvertToActualWindowSizes()

void SpectrogramSettings::ConvertToActualWindowSizes ( )

Definition at line 632 of file SpectrogramSettings.cpp.

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 610 of file SpectrogramSettings.cpp.

611{
612 unsigned size;
613 int logarithm;
614
615 logarithm = -LogMinWindowSize;
616 size = unsigned(windowSize);
617 while (size > 1)
618 size >>= 1, ++logarithm;
619 windowSize = std::max(0, std::min(NumWindowSizes - 1, logarithm));
620
621 // Choices for zero padding begin at 1
622 logarithm = 0;
623 size = unsigned(zeroPaddingFactor);
624 while (zeroPaddingFactor > 1)
625 zeroPaddingFactor >>= 1, ++logarithm;
626 zeroPaddingFactor = std::max(0,
628 logarithm
629 ));
630}
int min(int a, int b)

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

Referenced by SpectrumPrefs::OnDefaults(), SpectrumPrefs::Preview(), SpectrumPrefs::SpectrumPrefs(), 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 212 of file SpectrogramSettings.cpp.

213{
214 static SpectrogramSettings instance;
215 return instance;
216}
Spectrogram settings, either for one track or as defaults.

Referenced by SpectrumPrefs::Commit(), Get(), SpectrumPrefs::OnDefaults(), SpectrumPrefs::Preview(), SpectrumPrefs::Rollback(), SpectrumPrefs::SpectrumPrefs(), and UpdatePrefs().

Here is the caller graph for this function:

◆ DestroyWindows()

void SpectrogramSettings::DestroyWindows ( )

Definition at line 527 of file SpectrogramSettings.cpp.

528{
529 hFFT.reset();
530 window.reset();
531 dWindow.reset();
532 tWindow.reset();
533}

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 638 of file SpectrogramSettings.cpp.

639{
640 float linearBin = frequency / binUnit;
641 if (linearBin < 0)
642 return -1;
643 else
644 return linearBin;
645}

◆ Get()

SpectrogramSettings & SpectrogramSettings::Get ( const WaveTrack track)
static

Mutative access to attachment even if the track argument is const.

Definition at line 113 of file SpectrogramSettings.cpp.

114{
115 auto &mutTrack = const_cast<WaveTrack&>(track);
116 auto pSettings = static_cast<SpectrogramSettings*>(
117 mutTrack.WaveTrack::Attachments::Find(key1));
118 if (pSettings)
119 return *pSettings;
120 else
122}
static WaveTrack::Attachments::RegisteredFactory key1
static SpectrogramSettings & defaults()
A Track that contains audio waveform data.
Definition: WaveTrack.h:51

References defaults(), and key1.

Referenced by SetTrackVisualsCommand::ApplyInner(), BrushHandle::BrushHandle(), SpectrumView::DoSetMinimized(), SpectrumVRulerControls::DoUpdateVRuler(), SpectrumVZoomHandle::DoZoom(), anonymous_namespace{SpectrumView.cpp}::DrawClipSpectrum(), for(), anonymous_namespace{BrushHandle.cpp}::FrequencyToPosition(), anonymous_namespace{SelectHandle.cpp}::FrequencyToPosition(), SpectrogramBounds::Get(), SpectrogramBounds::GetBounds(), WaveClipSpectrumCache::GetSpectrogram(), NyquistEffect::Init(), anonymous_namespace{BrushHandle.cpp}::isSpectralSelectionView(), anonymous_namespace{SelectHandle.cpp}::isSpectralSelectionView(), SpectrumVRulerMenuTable::OnSpectrumScaleType(), anonymous_namespace{BrushHandle.cpp}::PositionToFrequency(), anonymous_namespace{SelectHandle.cpp}::PositionToFrequency(), NyquistEffect::ProcessOne(), SelectHandle::SnapCenterOnce(), SpectrumPrefs::SpectrumPrefs(), and SelectHandle::StartSnappingFreqSelection().

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

◆ GetAlgorithmNames()

const TranslatableStrings & SpectrogramSettings::GetAlgorithmNames ( )
static

Definition at line 279 of file SpectrogramSettings.cpp.

280{
281 static const TranslatableStrings results{
282 // Keep in correspondence with enum SpectrogramSettings::Algorithm:
283 XO("Frequencies") ,
284 /* i18n-hint: the Reassignment algorithm for spectrograms */
285 XO("Reassignment") ,
286 /* i18n-hint: EAC abbreviates "Enhanced Autocorrelation" */
287 XO("Pitch (EAC)") ,
288 };
289 return results;
290}
XO("Cut/Copy/Paste")
std::vector< TranslatableString > TranslatableStrings

References XO().

Referenced by SpectrumPrefs::PopulateOrExchange().

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

◆ GetColorSchemeNames()

const EnumValueSymbols & SpectrogramSettings::GetColorSchemeNames ( )
static

Definition at line 238 of file SpectrogramSettings.cpp.

239{
240 static const EnumValueSymbols result{
241 // Keep in correspondence with enum SpectrogramSettings::ColorScheme:
242 /* i18n-hint: New color scheme for spectrograms */
243 { wxT("SpecColorNew"), XC("Color (default)", "spectrum prefs") },
244 /* i18n-hint: Classic color scheme(from theme) for spectrograms */
245 { wxT("SpecColorTheme"), XC("Color (classic)", "spectrum prefs") },
246 /* i18n-hint: Grayscale color scheme for spectrograms */
247 { wxT("SpecGrayscale"), XC("Grayscale", "spectrum prefs") },
248 /* i18n-hint: Inverse grayscale color scheme for spectrograms */
249 { wxT("SpecInvGrayscale"), XC("Inverse grayscale", "spectrum prefs") },
250 };
251
252 wxASSERT(csNumColorScheme == result.size());
253 static_assert(csNumColorScheme == AColor::colorSchemes, "Broken correspondence");
254
255 return result;
256}
wxT("CloseDown"))
#define XC(s, c)
Definition: Internat.h:37
static const int colorSchemes
Definition: AColor.h:136

References AColor::colorSchemes, csNumColorScheme, wxT(), and XC.

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

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

◆ GetFFTLength()

size_t SpectrogramSettings::GetFFTLength ( ) const

Definition at line 647 of file SpectrogramSettings.cpp.

648{
649//#ifndef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
650 // return windowSize;
651//#else
653//#endif
654}

References algorithm, algPitchEAC, windowSize, and zeroPaddingFactor.

Referenced by NBins().

Here is the caller graph for this function:

◆ GetScale()

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

Definition at line 662 of file SpectrogramSettings.cpp.

663{
665
666 // Don't assume the correspondence of the enums will remain direct in the future.
667 // Do this switch.
668 switch (scaleType) {
669 default:
670 wxASSERT(false);
671 case stLinear:
672 type = nstLinear; break;
673 case stLogarithmic:
674 type = nstLogarithmic; break;
675 case stMel:
676 type = nstMel; break;
677 case stBark:
678 type = nstBark; break;
679 case stErb:
680 type = nstErb; break;
681 case stPeriod:
682 type = nstPeriod; break;
683 }
684
685 return NumberScale(type, minFreqIn, maxFreqIn);
686}
NumberScaleType
Definition: NumberScale.h:18
@ nstMel
Definition: NumberScale.h:21
@ nstErb
Definition: NumberScale.h:23
@ nstPeriod
Definition: NumberScale.h:24
@ nstLinear
Definition: NumberScale.h:19
@ nstLogarithmic
Definition: NumberScale.h:20
@ nstBark
Definition: NumberScale.h:22

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

◆ GetScaleNames()

const EnumValueSymbols & SpectrogramSettings::GetScaleNames ( )
static

Definition at line 219 of file SpectrogramSettings.cpp.

220{
221 static const EnumValueSymbols result{
222 // Keep in correspondence with enum SpectrogramSettings::ScaleType:
223 XO("Linear") ,
224 XO("Logarithmic") ,
225 /* i18n-hint: The name of a frequency scale in psychoacoustics */
226 XO("Mel") ,
227 /* i18n-hint: The name of a frequency scale in psychoacoustics, named for Heinrich Barkhausen */
228 XO("Bark") ,
229 /* i18n-hint: The name of a frequency scale in psychoacoustics, abbreviates Equivalent Rectangular Bandwidth */
230 XO("ERB") ,
231 /* i18n-hint: Time units, that is Period = 1 / Frequency */
232 XO("Period") ,
233 };
234 return result;
235}

References XO().

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

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

◆ InvalidateCaches()

void SpectrogramSettings::InvalidateCaches ( )

Definition at line 512 of file SpectrogramSettings.cpp.

513{
515}

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 95 of file SpectrogramSettings.h.

96 {
97 return this == &defaults();
98 }

◆ LoadPrefs()

void SpectrogramSettings::LoadPrefs ( )

Definition at line 363 of file SpectrogramSettings.cpp.

364{
366
368
372
374
376
378
380
381 scaleType = static_cast<ScaleType>(SpectrumScale.Read());
382
383#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
385#endif
386
387 algorithm = static_cast<Algorithm>(SpectrumAlgorithm.Read());
388
389#ifdef EXPERIMENTAL_FFT_Y_GRID
390 fftYGrid = SpectrumYGrid.Read();
391#endif //EXPERIMENTAL_FFT_Y_GRID
392
393#ifdef EXPERIMENTAL_FIND_NOTES
394 fftFindNotes = SpectrumFindNotes.Read();
395 findNotesMinA = SpectrumFindNotesMinA.Read();
396 numberOfMaxima = SpectrumFindNotesN.Read();
397 findNotesQuantize = SpectrumFindNotesQuantize.Read();
398#endif //EXPERIMENTAL_FIND_NOTES
399
400 // Enforce legal values
401 Validate(true);
402
404}
IntSetting SpectrumMaxFreq
Enum ReadEnum() const
Definition: Prefs.h:527
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:200
static ColorSchemeEnumSetting colorSchemeSetting

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 656 of file SpectrogramSettings.cpp.

657{
658 // Omit the Nyquist frequency bin
659 return GetFFTLength() / 2;
660}

References GetFFTLength().

Here is the call graph for this function:

◆ operator=()

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

Definition at line 179 of file SpectrogramSettings.cpp.

180{
181 if (this != &other) {
182 minFreq = other.minFreq;
183 maxFreq = other.maxFreq;
184 range = other.range;
185 gain = other.gain;
187 windowType = other.windowType;
188 windowSize = other.windowSize;
190 colorScheme = other.colorScheme;
191 scaleType = other.scaleType;
192#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
194#endif
195 algorithm = other.algorithm;
196#ifdef EXPERIMENTAL_FFT_Y_GRID
197 fftYGrid = other.fftYGrid;
198#endif
199#ifdef EXPERIMENTAL_FIND_NOTES
200 fftFindNotes = other.fftFindNotes;
201 findNotesMinA = other.findNotesMinA;
202 numberOfMaxima = other.numberOfMaxima;
203 findNotesQuantize = other.findNotesQuantize;
204#endif
205
206 // Invalidate the caches
208 }
209 return *this;
210}

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

Here is the call graph for this function:

◆ Own()

SpectrogramSettings & SpectrogramSettings::Own ( WaveTrack track)
static

Definition at line 124 of file SpectrogramSettings.cpp.

125{
126 auto pSettings = static_cast<SpectrogramSettings*>(
127 track.WaveTrack::Attachments::Find(key1));
128 if (!pSettings) {
129 auto uSettings = std::make_unique<SpectrogramSettings>();
130 pSettings = uSettings.get();
131 track.WaveTrack::Attachments::Assign(key1, std::move(uSettings));
132 }
133 return *pSettings;
134}

References key1.

Referenced by SetTrackVisualsCommand::ApplyInner(), SpectrumVRulerControls::DoHandleWheelRotation(), SpectrumVRulerMenuTable::OnSpectrumScaleType(), SpectrumPrefs::Preview(), and SpectrumPrefs::Rollback().

Here is the caller graph for this function:

◆ Reset()

void SpectrogramSettings::Reset ( WaveTrack track)
static

Make track lose indpendent settings and use defaults.

Definition at line 136 of file SpectrogramSettings.cpp.

137{
138 track.WaveTrack::Attachments::Assign(key1, nullptr);
139}

References key1.

Referenced by SetTrackVisualsCommand::ApplyInner(), SpectrumPrefs::Preview(), and SpectrumPrefs::Rollback().

Here is the caller graph for this function:

◆ SavePrefs()

void SpectrogramSettings::SavePrefs ( )

Definition at line 406 of file SpectrogramSettings.cpp.

407{
410
411 // Nothing wrote these. They only varied from the linear scale bounds in-session. -- PRL
412 // gPrefs->Write(wxT("/SpectrumLog/MaxFreq"), logMinFreq);
413 // gPrefs->Write(wxT("/SpectrumLog/MinFreq"), logMaxFreq);
414
418
420
422
424
426
427 SpectrumScale.Write(static_cast<int>(scaleType));
428
429#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
431#endif
432
433 SpectrumAlgorithm.Write(static_cast<int>(algorithm));
434
435#ifdef EXPERIMENTAL_FFT_Y_GRID
436 SpectrumYGrid.Write(fftYGrid);
437#endif //EXPERIMENTAL_FFT_Y_GRID
438
439#ifdef EXPERIMENTAL_FIND_NOTES
440 SpectrumFindNotes.Write(fftFindNotes);
441 SpectrumFindNotesMinA.Write(findNotesMinA);
442 SpectrumFindNotesN.Write(numberOfMaxima);
443 SpectrumFindNotesQuantize.Write(findNotesQuantize);
444#endif //EXPERIMENTAL_FIND_NOTES
445}
bool WriteEnum(Enum value)
Definition: Prefs.h:539
bool Write(const T &value)
Write value to config and return true if successful.
Definition: Prefs.h:252

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 688 of file SpectrogramSettings.cpp.

689{
690#ifdef SPECTRAL_SELECTION_GLOBAL_SWITCH
691 return Globals::Get().spectralSelection;
692#else
693 return spectralSelection;
694#endif
695}

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

Referenced by NyquistEffect::Init(), and 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 448 of file SpectrogramSettings.cpp.

449{
450 if (minFreq == defaults().minFreq)
452
453 if (maxFreq == defaults().maxFreq)
455
456 if (range == defaults().range)
458
459 if (gain == defaults().gain)
461
464
467
470
473
476 }
477
479 scaleType = static_cast<ScaleType>(SpectrumScale.Read());
480
481#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
484#endif
485
487 algorithm = static_cast<Algorithm>(SpectrumAlgorithm.Read());
488
489#ifdef EXPERIMENTAL_FFT_Y_GRID
490 if (fftYGrid == defaults().fftYGrid)
491 fftYGrid = SpectrumYGrid.Read();
492#endif //EXPERIMENTAL_FFT_Y_GRID
493
494#ifdef EXPERIMENTAL_FIND_NOTES
495 if (fftFindNotes == defaults().fftFindNotes)
496 fftFindNotes = SpectrumFindNotes.Read();
497
498 if (findNotesMinA == defaults().findNotesMinA)
499 findNotesMinA = SpectrumFindNotesMinA.Read();
500
501 if (numberOfMaxima == defaults().numberOfMaxima)
502 numberOfMaxima = SpectrumFindNotesN.Read();
503
504 if (findNotesQuantize == defaults().findNotesQuantize)
505 findNotesQuantize = SpectrumFindNotesQuantize.Read();
506#endif //EXPERIMENTAL_FIND_NOTES
507
508 // Enforce legal values
509 Validate(true);
510}

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 292 of file SpectrogramSettings.cpp.

293{
294 if (!quiet &&
295 maxFreq < 100) {
296 AudacityMessageBox( XO("Maximum frequency must be 100 Hz or above") );
297 return false;
298 }
299 else
300 maxFreq = std::max(100, maxFreq);
301
302 if (!quiet &&
303 minFreq < 0) {
304 AudacityMessageBox( XO("Minimum frequency must be at least 0 Hz") );
305 return false;
306 }
307 else
308 minFreq = std::max(0, minFreq);
309
310 if (!quiet &&
311 maxFreq <= minFreq) {
313"Minimum frequency must be less than maximum frequency") );
314 return false;
315 }
316 else
317 maxFreq = std::max(1 + minFreq, maxFreq);
318
319 if (!quiet &&
320 range <= 0) {
321 AudacityMessageBox( XO("The range must be at least 1 dB") );
322 return false;
323 }
324 else
325 range = std::max(1, range);
326
327 if (!quiet &&
328 frequencyGain < 0) {
329 AudacityMessageBox( XO("The frequency gain cannot be negative") );
330 return false;
331 }
332 else if (!quiet &&
333 frequencyGain > 60) {
335"The frequency gain must be no more than 60 dB/dec") );
336 return false;
337 }
338 else
340 std::max(0, std::min(60, frequencyGain));
341
342 // The rest are controlled by drop-down menus so they can't go wrong
343 // in the Preferences dialog, but we also come here after reading fom saved
344 // preference files, which could be or from future versions. Validate quietly.
345 windowType =
346 std::max(0, std::min(NumWindowFuncs() - 1, windowType));
347 scaleType =
348 ScaleType(std::max(0,
350 (int)(scaleType))));
352 std::max(0, std::min<int>(csNumColorScheme-1, colorScheme))
353 );
355 std::max(0, std::min((int)(algNumAlgorithms) - 1, (int)(algorithm)))
356 );
359
360 return true;
361}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
int NumWindowFuncs()
Definition: FFT.cpp:327

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 134 of file SpectrogramSettings.h.

134{ return windowSize; }

Referenced by CacheWindows(), and SpectrumPrefs::SpectrumPrefs().

Here is the caller graph for this function:

◆ ZeroPaddingFactor()

size_t SpectrogramSettings::ZeroPaddingFactor ( ) const
inline

Definition at line 139 of file SpectrogramSettings.h.

139 {
141 }

Referenced by CacheWindows().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ SpectrumPrefs

friend class SpectrumPrefs
friend

Definition at line 32 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"),
}
static const EnumValueSymbols & GetColorSchemeNames()

Definition at line 161 of file SpectrogramSettings.h.

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

◆ dWindow

Floats SpectrogramSettings::dWindow

Definition at line 198 of file SpectrogramSettings.h.

Referenced by CacheWindows(), and DestroyWindows().

◆ frequencyGain

int SpectrogramSettings::frequencyGain

◆ gain

int SpectrogramSettings::gain

◆ hFFT

HFFT SpectrogramSettings::hFFT

Definition at line 193 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

Definition at line 197 of file SpectrogramSettings.h.

Referenced by CacheWindows(), and DestroyWindows().

◆ window

Floats SpectrogramSettings::window

◆ 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: