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< Covariant, Owner >
using Base = std::conditional_t< std::is_void_v< Covariant >, Cloneable, Covariant >
 
using PointerType = Owner< 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< Covariant, Owner >
 Cloneable ()=default
 
 Cloneable (const Cloneable &)=default
 
Cloneableoperator= (const Cloneable &)=default
 
virtual ~Cloneable ()=default
 
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 140 of file SpectrogramSettings.cpp.

141{
142 LoadPrefs();
143}

References LoadPrefs().

Here is the call graph for this function:

◆ SpectrogramSettings() [2/2]

SpectrogramSettings::SpectrogramSettings ( const SpectrogramSettings other)

Definition at line 145 of file SpectrogramSettings.cpp.

146 : minFreq(other.minFreq)
147 , maxFreq(other.maxFreq)
148 , range(other.range)
149 , gain(other.gain)
151 , windowType(other.windowType)
152 , windowSize(other.windowSize)
154 , colorScheme(other.colorScheme)
155 , scaleType(other.scaleType)
156#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
158#endif
159 , algorithm(other.algorithm)
160#ifdef EXPERIMENTAL_FFT_Y_GRID
161 , fftYGrid(other.fftYGrid)
162#endif
163#ifdef EXPERIMENTAL_FIND_NOTES
164 , fftFindNotes(other.fftFindNotes)
165 , findNotesMinA(other.findNotesMinA)
166 , numberOfMaxima(other.numberOfMaxima)
167 , findNotesQuantize(other.findNotesQuantize)
168#endif
169
170 // Do not copy these!
171 , hFFT{}
172 , window{}
173 , tWindow{}
174 , dWindow{}
175{
176}

◆ ~SpectrogramSettings()

SpectrogramSettings::~SpectrogramSettings ( )

Definition at line 516 of file SpectrogramSettings.cpp.

517{
519}

References DestroyWindows().

Here is the call graph for this function:

Member Function Documentation

◆ CacheWindows()

void SpectrogramSettings::CacheWindows ( )

Definition at line 591 of file SpectrogramSettings.cpp.

592{
593 if (hFFT == NULL || window == NULL) {
594
595 double scale;
596 auto factor = ZeroPaddingFactor();
597 const auto fftLen = WindowSize() * factor;
598 const auto padding = (WindowSize() * (factor - 1)) / 2;
599
600 hFFT = GetFFT(fftLen);
601 RecreateWindow(window, WINDOW, fftLen, padding, windowType, windowSize, scale);
602 if (algorithm == algReassignment) {
603 RecreateWindow(tWindow, TWINDOW, fftLen, padding, windowType, windowSize, scale);
604 RecreateWindow(dWindow, DWINDOW, fftLen, padding, windowType, windowSize, scale);
605 }
606 }
607}
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< Covariant, Owner >.

Definition at line 521 of file SpectrogramSettings.cpp.

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

◆ ConvertToActualWindowSizes()

void SpectrogramSettings::ConvertToActualWindowSizes ( )

Definition at line 631 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 609 of file SpectrogramSettings.cpp.

610{
611 unsigned size;
612 int logarithm;
613
614 logarithm = -LogMinWindowSize;
615 size = unsigned(windowSize);
616 while (size > 1)
617 size >>= 1, ++logarithm;
618 windowSize = std::max(0, std::min(NumWindowSizes - 1, logarithm));
619
620 // Choices for zero padding begin at 1
621 logarithm = 0;
622 size = unsigned(zeroPaddingFactor);
623 while (zeroPaddingFactor > 1)
624 zeroPaddingFactor >>= 1, ++logarithm;
625 zeroPaddingFactor = std::max(0,
627 logarithm
628 ));
629}
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 211 of file SpectrogramSettings.cpp.

212{
213 static SpectrogramSettings instance;
214 return instance;
215}
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 526 of file SpectrogramSettings.cpp.

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

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

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

◆ Get()

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

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

Definition at line 110 of file SpectrogramSettings.cpp.

111{
112 auto &mutTrack = const_cast<WaveTrack&>(track);
113 auto pSettings = mutTrack.GetGroupData().Attachments
114 ::Find<SpectrogramSettings>(key1);
115 if (pSettings)
116 return *pSettings;
117 else
119}
static const ChannelGroup::Attachments::RegisteredFactory key1
static SpectrogramSettings & defaults()
ChannelGroupData & GetGroupData()
Definition: Track.cpp:159
A Track that contains audio waveform data.
Definition: WaveTrack.h:227

References defaults(), Track::GetGroupData(), 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(), 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 278 of file SpectrogramSettings.cpp.

279{
280 static const TranslatableStrings results{
281 // Keep in correspondence with enum SpectrogramSettings::Algorithm:
282 XO("Frequencies") ,
283 /* i18n-hint: the Reassignment algorithm for spectrograms */
284 XO("Reassignment") ,
285 /* i18n-hint: EAC abbreviates "Enhanced Autocorrelation" */
286 XO("Pitch (EAC)") ,
287 };
288 return results;
289}
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 237 of file SpectrogramSettings.cpp.

238{
239 static const EnumValueSymbols result{
240 // Keep in correspondence with enum SpectrogramSettings::ColorScheme:
241 /* i18n-hint: New color scheme for spectrograms, Roseus is proper name of the color scheme */
242 { wxT("SpecColorNew"), XC("Color (Roseus)", "spectrum prefs") },
243 /* i18n-hint: Classic color scheme(from theme) for spectrograms */
244 { wxT("SpecColorTheme"), XC("Color (classic)", "spectrum prefs") },
245 /* i18n-hint: Grayscale color scheme for spectrograms */
246 { wxT("SpecGrayscale"), XC("Grayscale", "spectrum prefs") },
247 /* i18n-hint: Inverse grayscale color scheme for spectrograms */
248 { wxT("SpecInvGrayscale"), XC("Inverse grayscale", "spectrum prefs") },
249 };
250
251 wxASSERT(csNumColorScheme == result.size());
252 static_assert(csNumColorScheme == AColor::colorSchemes, "Broken correspondence");
253
254 return result;
255}
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 646 of file SpectrogramSettings.cpp.

647{
648//#ifndef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
649 // return windowSize;
650//#else
652//#endif
653}

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

662{
664
665 // Don't assume the correspondence of the enums will remain direct in the future.
666 // Do this switch.
667 switch (scaleType) {
668 default:
669 wxASSERT(false);
670 case stLinear:
671 type = nstLinear; break;
672 case stLogarithmic:
673 type = nstLogarithmic; break;
674 case stMel:
675 type = nstMel; break;
676 case stBark:
677 type = nstBark; break;
678 case stErb:
679 type = nstErb; break;
680 case stPeriod:
681 type = nstPeriod; break;
682 }
683
684 return NumberScale(type, minFreqIn, maxFreqIn);
685}
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 218 of file SpectrogramSettings.cpp.

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

References XO().

Referenced by 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 511 of file SpectrogramSettings.cpp.

512{
514}

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

363{
365
367
371
373
375
377
379
380 scaleType = static_cast<ScaleType>(SpectrumScale.Read());
381
382#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
384#endif
385
386 algorithm = static_cast<Algorithm>(SpectrumAlgorithm.Read());
387
388#ifdef EXPERIMENTAL_FFT_Y_GRID
389 fftYGrid = SpectrumYGrid.Read();
390#endif //EXPERIMENTAL_FFT_Y_GRID
391
392#ifdef EXPERIMENTAL_FIND_NOTES
393 fftFindNotes = SpectrumFindNotes.Read();
394 findNotesMinA = SpectrumFindNotesMinA.Read();
395 numberOfMaxima = SpectrumFindNotesN.Read();
396 findNotesQuantize = SpectrumFindNotesQuantize.Read();
397#endif //EXPERIMENTAL_FIND_NOTES
398
399 // Enforce legal values
400 Validate(true);
401
403}
IntSetting SpectrumMaxFreq
Enum ReadEnum() const
Definition: Prefs.h:534
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:207
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 655 of file SpectrogramSettings.cpp.

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

References GetFFTLength().

Here is the call graph for this function:

◆ operator=()

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

Definition at line 178 of file SpectrogramSettings.cpp.

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

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

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

References Track::GetGroupData(), and key1.

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

Here is the call graph for this function:
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 134 of file SpectrogramSettings.cpp.

135{
136 track.GetGroupData().Attachments
137 ::Assign(key1, nullptr);
138}

References Track::GetGroupData(), and key1.

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

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

◆ SavePrefs()

void SpectrogramSettings::SavePrefs ( )

Definition at line 405 of file SpectrogramSettings.cpp.

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

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

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

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

448{
449 if (minFreq == defaults().minFreq)
451
452 if (maxFreq == defaults().maxFreq)
454
455 if (range == defaults().range)
457
458 if (gain == defaults().gain)
460
463
466
469
472
475 }
476
478 scaleType = static_cast<ScaleType>(SpectrumScale.Read());
479
480#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
483#endif
484
486 algorithm = static_cast<Algorithm>(SpectrumAlgorithm.Read());
487
488#ifdef EXPERIMENTAL_FFT_Y_GRID
489 if (fftYGrid == defaults().fftYGrid)
490 fftYGrid = SpectrumYGrid.Read();
491#endif //EXPERIMENTAL_FFT_Y_GRID
492
493#ifdef EXPERIMENTAL_FIND_NOTES
494 if (fftFindNotes == defaults().fftFindNotes)
495 fftFindNotes = SpectrumFindNotes.Read();
496
497 if (findNotesMinA == defaults().findNotesMinA)
498 findNotesMinA = SpectrumFindNotesMinA.Read();
499
500 if (numberOfMaxima == defaults().numberOfMaxima)
501 numberOfMaxima = SpectrumFindNotesN.Read();
502
503 if (findNotesQuantize == defaults().findNotesQuantize)
504 findNotesQuantize = SpectrumFindNotesQuantize.Read();
505#endif //EXPERIMENTAL_FIND_NOTES
506
507 // Enforce legal values
508 Validate(true);
509}

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

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