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

143{
144 LoadPrefs();
145}

References LoadPrefs().

Here is the call graph for this function:

◆ SpectrogramSettings() [2/2]

SpectrogramSettings::SpectrogramSettings ( const SpectrogramSettings other)

Definition at line 147 of file SpectrogramSettings.cpp.

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

◆ ~SpectrogramSettings()

SpectrogramSettings::~SpectrogramSettings ( )

Definition at line 518 of file SpectrogramSettings.cpp.

519{
521}

References DestroyWindows().

Here is the call graph for this function:

Member Function Documentation

◆ CacheWindows()

void SpectrogramSettings::CacheWindows ( )

Definition at line 593 of file SpectrogramSettings.cpp.

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

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

◆ ConvertToActualWindowSizes()

void SpectrogramSettings::ConvertToActualWindowSizes ( )

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

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

214{
215 static SpectrogramSettings instance;
216 return instance;
217}
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 528 of file SpectrogramSettings.cpp.

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

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

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

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

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

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

111{
112 auto &mutTrack = const_cast<WaveTrack&>(track);
113 auto pSettings = mutTrack.Attachments::Find<SpectrogramSettings>(key1);
114 if (pSettings)
115 return *pSettings;
116 else
118}
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(), NyquistEffect::Init(), anonymous_namespace{SelectHandle.cpp}::isSpectralSelectionView(), anonymous_namespace{BrushHandle.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 280 of file SpectrogramSettings.cpp.

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

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

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

649{
650//#ifndef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
651 // return windowSize;
652//#else
654//#endif
655}

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

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

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

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

514{
516}

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

365{
367
369
373
375
377
379
381
382 scaleType = static_cast<ScaleType>(SpectrumScale.Read());
383
384#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
386#endif
387
388 algorithm = static_cast<Algorithm>(SpectrumAlgorithm.Read());
389
390#ifdef EXPERIMENTAL_FFT_Y_GRID
391 fftYGrid = SpectrumYGrid.Read();
392#endif //EXPERIMENTAL_FFT_Y_GRID
393
394#ifdef EXPERIMENTAL_FIND_NOTES
395 fftFindNotes = SpectrumFindNotes.Read();
396 findNotesMinA = SpectrumFindNotesMinA.Read();
397 numberOfMaxima = SpectrumFindNotesN.Read();
398 findNotesQuantize = SpectrumFindNotesQuantize.Read();
399#endif //EXPERIMENTAL_FIND_NOTES
400
401 // Enforce legal values
402 Validate(true);
403
405}
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 657 of file SpectrogramSettings.cpp.

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

References GetFFTLength().

Here is the call graph for this function:

◆ operator=()

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

Definition at line 180 of file SpectrogramSettings.cpp.

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

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

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

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

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

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

408{
411
412 // Nothing wrote these. They only varied from the linear scale bounds in-session. -- PRL
413 // gPrefs->Write(wxT("/SpectrumLog/MaxFreq"), logMinFreq);
414 // gPrefs->Write(wxT("/SpectrumLog/MinFreq"), logMaxFreq);
415
419
421
423
425
427
428 SpectrumScale.Write(static_cast<int>(scaleType));
429
430#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
432#endif
433
434 SpectrumAlgorithm.Write(static_cast<int>(algorithm));
435
436#ifdef EXPERIMENTAL_FFT_Y_GRID
437 SpectrumYGrid.Write(fftYGrid);
438#endif //EXPERIMENTAL_FFT_Y_GRID
439
440#ifdef EXPERIMENTAL_FIND_NOTES
441 SpectrumFindNotes.Write(fftFindNotes);
442 SpectrumFindNotesMinA.Write(findNotesMinA);
443 SpectrumFindNotesN.Write(numberOfMaxima);
444 SpectrumFindNotesQuantize.Write(findNotesQuantize);
445#endif //EXPERIMENTAL_FIND_NOTES
446}
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 689 of file SpectrogramSettings.cpp.

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

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

Referenced by NyquistEffect::Init(), anonymous_namespace{SelectHandle.cpp}::isSpectralSelectionView(), anonymous_namespace{BrushHandle.cpp}::isSpectralSelectionView(), 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 449 of file SpectrogramSettings.cpp.

450{
451 if (minFreq == defaults().minFreq)
453
454 if (maxFreq == defaults().maxFreq)
456
457 if (range == defaults().range)
459
460 if (gain == defaults().gain)
462
465
468
471
474
477 }
478
480 scaleType = static_cast<ScaleType>(SpectrumScale.Read());
481
482#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
485#endif
486
488 algorithm = static_cast<Algorithm>(SpectrumAlgorithm.Read());
489
490#ifdef EXPERIMENTAL_FFT_Y_GRID
491 if (fftYGrid == defaults().fftYGrid)
492 fftYGrid = SpectrumYGrid.Read();
493#endif //EXPERIMENTAL_FFT_Y_GRID
494
495#ifdef EXPERIMENTAL_FIND_NOTES
496 if (fftFindNotes == defaults().fftFindNotes)
497 fftFindNotes = SpectrumFindNotes.Read();
498
499 if (findNotesMinA == defaults().findNotesMinA)
500 findNotesMinA = SpectrumFindNotesMinA.Read();
501
502 if (numberOfMaxima == defaults().numberOfMaxima)
503 numberOfMaxima = SpectrumFindNotesN.Read();
504
505 if (findNotesQuantize == defaults().findNotesQuantize)
506 findNotesQuantize = SpectrumFindNotesQuantize.Read();
507#endif //EXPERIMENTAL_FIND_NOTES
508
509 // Enforce legal values
510 Validate(true);
511}

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

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