forked from audacity/audacity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpectrogramSettings.h
More file actions
170 lines (129 loc) · 3.7 KB
/
Copy pathSpectrogramSettings.h
File metadata and controls
170 lines (129 loc) · 3.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/**********************************************************************
Audacity: A Digital Audio Editor
SpectrogramSettings.h
Paul Licameli
**********************************************************************/
#ifndef __AUDACITY_SPECTROGRAM_SETTINGS__
#define __AUDACITY_SPECTROGRAM_SETTINGS__
#include "../Prefs.h"
#include "../SampleFormat.h"
#include "../RealFFTf.h"
#undef SPECTRAL_SELECTION_GLOBAL_SWITCH
class EnumValueSymbols;
struct FFTParam;
class NumberScale;
class SpectrumPrefs;
class wxArrayStringEx;
class SpectrogramSettings : public PrefsListener
{
friend class SpectrumPrefs;
public:
// Singleton for settings that are not per-track
class Globals
{
public:
static Globals &Get();
void SavePrefs();
#ifdef SPECTRAL_SELECTION_GLOBAL_SWITCH
bool spectralSelection;
#endif
private:
Globals();
void LoadPrefs();
};
enum {
LogMinWindowSize = 3,
LogMaxWindowSize = 15,
NumWindowSizes = LogMaxWindowSize - LogMinWindowSize + 1,
};
// Do not assume that this enumeration will remain the
// same as NumberScaleType in future. That enum may become
// more general purpose.
typedef int ScaleType;
enum ScaleTypeValues : int {
stLinear,
stLogarithmic,
stMel,
stBark,
stErb,
stPeriod,
stNumScaleTypes,
};
static const EnumValueSymbols &GetScaleNames();
static const TranslatableStrings &GetAlgorithmNames();
static SpectrogramSettings &defaults();
SpectrogramSettings();
SpectrogramSettings(const SpectrogramSettings &other);
SpectrogramSettings& operator= (const SpectrogramSettings &other);
~SpectrogramSettings();
bool IsDefault() const
{
return this == &defaults();
}
bool Validate(bool quiet);
void LoadPrefs();
void SavePrefs();
void UpdatePrefs() override;
void InvalidateCaches();
void DestroyWindows();
void CacheWindows() const;
void ConvertToEnumeratedWindowSizes();
void ConvertToActualWindowSizes();
// Need to be told what the bin unit is, as this structure does not know
// the rate
float findBin( float frequency, float binUnit ) const;
// If "bins" is false, units are Hz
NumberScale GetScale( float minFreq, float maxFreq ) const;
int minFreq;
int maxFreq;
bool SpectralSelectionEnabled() const;
public:
int range;
int gain;
int frequencyGain;
int windowType;
private:
int windowSize;
public:
size_t WindowSize() const { return windowSize; }
#ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
private:
int zeroPaddingFactor;
public:
size_t ZeroPaddingFactor() const {
return algorithm == algPitchEAC ? 1 : zeroPaddingFactor;
}
#endif
size_t GetFFTLength() const; // window size (times zero padding, if STFT)
size_t NBins() const;
bool isGrayscale;
ScaleType scaleType;
#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
bool spectralSelection; // But should this vary per track? -- PRL
#endif
typedef int Algorithm;
enum AlgorithmValues : int {
algSTFT = 0,
algReassignment,
algPitchEAC,
algNumAlgorithms,
};
Algorithm algorithm;
#ifdef EXPERIMENTAL_FFT_Y_GRID
bool fftYGrid;
#endif //EXPERIMENTAL_FFT_Y_GRID
#ifdef EXPERIMENTAL_FIND_NOTES
bool fftFindNotes;
double findNotesMinA;
int numberOfMaxima;
bool findNotesQuantize;
#endif //EXPERIMENTAL_FIND_NOTES
// Following fields are derived from preferences.
// Variables used for computing the spectrum
mutable HFFT hFFT;
mutable Floats window;
// Two other windows for computing reassigned spectrogram
mutable Floats tWindow; // Window times time parameter
mutable Floats dWindow; // Derivative of window
};
#endif