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)
 
static SpectrogramSettingsGet (const WaveChannel &channel)
 
static SpectrogramSettingsOwn (WaveChannel &wc)
 
static void Reset (WaveChannel &channel)
 Make channel 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 29 of file SpectrogramSettings.h.

Member Typedef Documentation

◆ Algorithm

Definition at line 175 of file SpectrogramSettings.h.

◆ ScaleType

Definition at line 62 of file SpectrogramSettings.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
LogMinWindowSize 
LogMaxWindowSize 
NumWindowSizes 

Definition at line 52 of file SpectrogramSettings.h.

◆ AlgorithmValues

Enumerator
algSTFT 
algReassignment 
algPitchEAC 
algNumAlgorithms 

Definition at line 176 of file SpectrogramSettings.h.

◆ ColorScheme

Enumerator
csColorNew 
csColorTheme 
csGrayscale 
csInvGrayscale 
csNumColorScheme 

Definition at line 152 of file SpectrogramSettings.h.

152 : int {
153 // Keep in correspondence with AColor::colorSchemes, AColor::gradient_pre
154 csColorNew = 0,
158
160 };

◆ ScaleTypeValues

Enumerator
stLinear 
stLogarithmic 
stMel 
stBark 
stErb 
stPeriod 
stNumScaleTypes 

Definition at line 63 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 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 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 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() [1/2]

SpectrogramSettings & SpectrogramSettings::Get ( const WaveChannel channel)
static

Return either the track's independent settings or global defaults Mutative access to attachment even if the track argument is const

Definition at line 119 of file SpectrogramSettings.cpp.

120{
121 return Get(channel.GetTrack());
122}
static SpectrogramSettings & Get(const WaveTrack &track)
WaveTrack & GetTrack()
Definition: WaveTrack.h:841

References Get(), and WaveChannel::GetTrack().

Here is the call graph for this function:

◆ Get() [2/2]

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

Return either the track's independent settings or global defaults Mutative access to attachment even if the track argument is const

Definition at line 109 of file SpectrogramSettings.cpp.

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

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(), Get(), SpectrogramBounds::Get(), SpectrogramBounds::GetBounds(), NyquistBase::Init(), anonymous_namespace{SelectHandle.cpp}::isSpectralSelectionView(), anonymous_namespace{BrushHandle.cpp}::isSpectralSelectionView(), SpectrumVRulerMenuTable::OnSpectrumScaleType(), anonymous_namespace{BrushHandle.cpp}::PositionToFrequency(), anonymous_namespace{SelectHandle.cpp}::PositionToFrequency(), NyquistBase::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 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, Roseus is proper name of the color scheme */
243 { wxT("SpecColorNew"), XC("Color (Roseus)", "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
254 return result;
255}
wxT("CloseDown"))
#define XC(s, c)
Definition: Internat.h:37

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

102 {
103 return this == &defaults();
104 }

◆ 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 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 ( WaveChannel wc)
static

Definition at line 124 of file SpectrogramSettings.cpp.

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

References WaveChannel::GetTrack(), 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 ( WaveChannel channel)
static

Make channel lose indpendent settings and use defaults.

Definition at line 136 of file SpectrogramSettings.cpp.

137{
138 wc.GetTrack().Attachments::Assign(key1, nullptr);
139}

References WaveChannel::GetTrack(), 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 NyquistBase::Init(), anonymous_namespace{SelectHandle.cpp}::isSpectralSelectionView(), anonymous_namespace{BrushHandle.cpp}::isSpectralSelectionView(), and NyquistBase::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 BasicUI::ShowMessageBox( 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 BasicUI::ShowMessageBox( 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 BasicUI::ShowMessageBox( 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 BasicUI::ShowMessageBox( 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 NumWindowFuncs()
Definition: FFT.cpp:327
MessageBoxResult ShowMessageBox(const TranslatableString &message, MessageBoxOptions options={})
Show a modal message box with either Ok or Yes and No, and optionally Cancel.
Definition: BasicUI.h:287

References algNumAlgorithms, algorithm, colorScheme, ConvertToActualWindowSizes(), ConvertToEnumeratedWindowSizes(), csNumColorScheme, frequencyGain, maxFreq, min(), minFreq, NumWindowFuncs(), range, scaleType, BasicUI::ShowMessageBox(), 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 140 of file SpectrogramSettings.h.

140{ 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 145 of file SpectrogramSettings.h.

145 {
147 }

Referenced by CacheWindows().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ SpectrumPrefs

friend class SpectrumPrefs
friend

Definition at line 33 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 167 of file SpectrogramSettings.h.

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

◆ dWindow

Floats SpectrogramSettings::dWindow

Definition at line 204 of file SpectrogramSettings.h.

Referenced by CacheWindows(), and DestroyWindows().

◆ frequencyGain

int SpectrogramSettings::frequencyGain

◆ gain

int SpectrogramSettings::gain

◆ hFFT

HFFT SpectrogramSettings::hFFT

Definition at line 199 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 203 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: