Audacity 3.2.0
SpectrogramSettings.h
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5SpectrogramSettings.h
6
7Paul Licameli
8
9**********************************************************************/
10
11#ifndef __AUDACITY_SPECTROGRAM_SETTINGS__
12#define __AUDACITY_SPECTROGRAM_SETTINGS__
13
14#include "Prefs.h"
15#include "SampleFormat.h"
16#include "RealFFTf.h"
17
18#undef SPECTRAL_SELECTION_GLOBAL_SWITCH
19
21struct FFTParam;
22class NumberScale;
23class SpectrumPrefs;
24class wxArrayStringEx;
25
26class AUDACITY_DLL_API SpectrogramSettings : public PrefsListener
27{
28 friend class SpectrumPrefs;
29public:
30
31 // Singleton for settings that are not per-track
32 class AUDACITY_DLL_API Globals
33 {
34 public:
35 static Globals &Get();
36 void SavePrefs();
37
38#ifdef SPECTRAL_SELECTION_GLOBAL_SWITCH
39 bool spectralSelection;
40#endif
41
42 private:
43 Globals();
44 void LoadPrefs();
45 };
46
47 enum {
48 LogMinWindowSize = 3,
49 LogMaxWindowSize = 15,
50
51 NumWindowSizes = LogMaxWindowSize - LogMinWindowSize + 1,
52 };
53
54 // Do not assume that this enumeration will remain the
55 // same as NumberScaleType in future. That enum may become
56 // more general purpose.
57 typedef int ScaleType;
58 enum ScaleTypeValues : int {
65
67 };
68
69 static const EnumValueSymbols &GetScaleNames();
70 static const EnumValueSymbols &GetColorSchemeNames();
71 static const TranslatableStrings &GetAlgorithmNames();
72
73 static SpectrogramSettings &defaults();
76 SpectrogramSettings& operator= (const SpectrogramSettings &other);
78
79 bool IsDefault() const
80 {
81 return this == &defaults();
82 }
83
84 bool Validate(bool quiet);
85 void LoadPrefs();
86 void SavePrefs();
87
88 void UpdatePrefs() override;
89
90 void InvalidateCaches();
91 void DestroyWindows();
92 void CacheWindows() const;
93 void ConvertToEnumeratedWindowSizes();
94 void ConvertToActualWindowSizes();
95
96 // Need to be told what the bin unit is, as this structure does not know
97 // the rate
98 float findBin( float frequency, float binUnit ) const;
99
100 // If "bins" is false, units are Hz
101 NumberScale GetScale( float minFreq, float maxFreq ) const;
102
105
106 bool SpectralSelectionEnabled() const;
107
108public:
109 int range;
110 int gain;
112
114
115private:
117public:
118 size_t WindowSize() const { return windowSize; }
119
120private:
122public:
123 size_t ZeroPaddingFactor() const {
124 return algorithm == algPitchEAC ? 1 : zeroPaddingFactor;
125 }
126
127 size_t GetFFTLength() const; // window size (times zero padding, if STFT)
128 size_t NBins() const;
129
130 enum ColorScheme : int {
131 // Keep in correspondence with AColor::colorSchemes, AColor::gradient_pre
132 csColorNew = 0,
136
138 };
140
141 class ColorSchemeEnumSetting : public EnumSetting< ColorScheme > {
143 void Migrate(wxString &value) override;
144 };
146
148
149#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
150 bool spectralSelection; // But should this vary per track? -- PRL
151#endif
152
153 typedef int Algorithm;
154 enum AlgorithmValues : int {
155 algSTFT = 0,
158
160 };
162
163#ifdef EXPERIMENTAL_FFT_Y_GRID
164 bool fftYGrid;
165#endif //EXPERIMENTAL_FFT_Y_GRID
166
167#ifdef EXPERIMENTAL_FIND_NOTES
168 bool fftFindNotes;
169 double findNotesMinA;
170 int numberOfMaxima;
171 bool findNotesQuantize;
172#endif //EXPERIMENTAL_FIND_NOTES
173
174 // Following fields are derived from preferences.
175
176 // Variables used for computing the spectrum
177 mutable HFFT hFFT;
178 mutable Floats window;
179
180 // Two other windows for computing reassigned spectrogram
181 mutable Floats tWindow; // Window times time parameter
182 mutable Floats dWindow; // Derivative of window
183};
184
185extern AUDACITY_DLL_API IntSetting SpectrumMaxFreq;
186
187#endif
std::unique_ptr< FFTParam, FFTDeleter > HFFT
Definition: RealFFTf.h:22
AUDACITY_DLL_API IntSetting SpectrumMaxFreq
std::vector< TranslatableString > TranslatableStrings
Adapts EnumSettingBase to a particular enumeration type.
Definition: Prefs.h:507
Specialization of Setting for int.
Definition: Prefs.h:349
A listener notified of changes in preferences.
Definition: Prefs.h:543
virtual void UpdatePrefs()=0
Definition: Prefs.cpp:124
Spectrogram settings, either for one track or as defaults.
static ColorSchemeEnumSetting colorSchemeSetting
size_t ZeroPaddingFactor() const
A PrefsPanel for spectrum settings.
Definition: SpectrumPrefs.h:42
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:26