32 L
"/Spectrum/MaxFreq", 20000 };
40 L
"/Spectrum/Algorithm", 0 };
42 L
"/Spectrum/ScaleType", 2 };
47 L
"/Spectrum/EnableSpectralSelection",
true };
49 L
"/Spectrum/FFTSize", 2048 };
51 L
"/Spectrum/FrequencyGain", 0 };
53 L
"/Spectrum/Gain", 20 };
55 L
"/Spectrum/Grayscale",
false };
57 L
"/Spectrum/MinFreq", 0 };
59 L
"/Spectrum/Range", 80 };
61 L
"/Spectrum/ZeroPaddingFactor", 2 };
63#ifdef EXPERIMENTAL_FIND_NOTES
65 L
"/Spectrum/FFTFindNotes",
false };
67 L
"/Spectrum/FindNotesMinA", -30.0 };
69 L
"/Spectrum/FindNotesN", 5 };
71 L
"/Spectrum/FindNotesQuantize",
false };
74#ifdef EXPERIMENTAL_FFT_Y_GRID
76 L
"/Spectrum/FFTYGrid",
false};
87#ifdef SPECTRAL_SELECTION_GLOBAL_SWITCH
94#ifdef SPECTRAL_SELECTION_GLOBAL_SWITCH
107key1{ [](
auto &) {
return nullptr; } };
111 auto &mutTrack =
const_cast<WaveTrack&
>(track);
129 auto uSettings = std::make_unique<SpectrogramSettings>();
130 pSettings = uSettings.get();
131 track.Attachments::Assign(
key1, std::move(uSettings));
157#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
161#ifdef EXPERIMENTAL_FFT_Y_GRID
162 , fftYGrid(other.fftYGrid)
164#ifdef EXPERIMENTAL_FIND_NOTES
165 , fftFindNotes(other.fftFindNotes)
166 , findNotesMinA(other.findNotesMinA)
167 , numberOfMaxima(other.numberOfMaxima)
168 , findNotesQuantize(other.findNotesQuantize)
181 if (
this != &other) {
192#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
196#ifdef EXPERIMENTAL_FFT_Y_GRID
197 fftYGrid = other.fftYGrid;
199#ifdef EXPERIMENTAL_FIND_NOTES
200 fftFindNotes = other.fftFindNotes;
201 findNotesMinA = other.findNotesMinA;
202 numberOfMaxima = other.numberOfMaxima;
203 findNotesQuantize = other.findNotesQuantize;
243 {
wxT(
"SpecColorNew"),
XC(
"Color (Roseus)",
"spectrum prefs") },
245 {
wxT(
"SpecColorTheme"),
XC(
"Color (classic)",
"spectrum prefs") },
247 {
wxT(
"SpecGrayscale"),
XC(
"Grayscale",
"spectrum prefs") },
249 {
wxT(
"SpecInvGrayscale"),
XC(
"Inverse grayscale",
"spectrum prefs") },
262 if (isGrayscale && !
gPrefs->
Read(
wxT(
"/Spectrum/ColorScheme"), &value)) {
270 wxT(
"/Spectrum/ColorScheme"),
312"Minimum frequency must be less than maximum frequency") );
334"The frequency gain must be no more than 60 dB/dec") );
382#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
388#ifdef EXPERIMENTAL_FFT_Y_GRID
389 fftYGrid = SpectrumYGrid.Read();
392#ifdef EXPERIMENTAL_FIND_NOTES
393 fftFindNotes = SpectrumFindNotes.Read();
394 findNotesMinA = SpectrumFindNotesMinA.Read();
395 numberOfMaxima = SpectrumFindNotesN.Read();
396 findNotesQuantize = SpectrumFindNotesQuantize.Read();
428#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
434#ifdef EXPERIMENTAL_FFT_Y_GRID
435 SpectrumYGrid.Write(fftYGrid);
438#ifdef EXPERIMENTAL_FIND_NOTES
439 SpectrumFindNotes.Write(fftFindNotes);
440 SpectrumFindNotesMinA.Write(findNotesMinA);
441 SpectrumFindNotesN.Write(numberOfMaxima);
442 SpectrumFindNotesQuantize.Write(findNotesQuantize);
480#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
488#ifdef EXPERIMENTAL_FFT_Y_GRID
489 if (fftYGrid ==
defaults().fftYGrid)
490 fftYGrid = SpectrumYGrid.Read();
493#ifdef EXPERIMENTAL_FIND_NOTES
494 if (fftFindNotes ==
defaults().fftFindNotes)
495 fftFindNotes = SpectrumFindNotes.Read();
497 if (findNotesMinA ==
defaults().findNotesMinA)
498 findNotesMinA = SpectrumFindNotesMinA.Read();
500 if (numberOfMaxima ==
defaults().numberOfMaxima)
501 numberOfMaxima = SpectrumFindNotesN.Read();
503 if (findNotesQuantize ==
defaults().findNotesQuantize)
504 findNotesQuantize = SpectrumFindNotesQuantize.Read();
523 return std::make_unique<SpectrogramSettings>(*
this);
546 const bool extra = padding > 0;
551 const size_t endOfWindow = padding +
windowSize;
553 for (ii = 0; ii < padding; ++ii) {
555 window[fftLen - ii - 1] = 0.0;
558 for (; ii < endOfWindow; ++ii)
568 for (
int jj = padding, multiplier = -(
int)
windowSize / 2; jj < (int)endOfWindow; ++jj, ++multiplier)
581 for (ii = padding; ii < endOfWindow; ++ii)
586 for (ii = padding; ii < endOfWindow; ++ii)
598 const auto padding = (
WindowSize() * (factor - 1)) / 2;
617 size >>= 1, ++logarithm;
639 float linearBin = frequency / binUnit;
689#ifdef SPECTRAL_SELECTION_GLOBAL_SWITCH
697key2{ [](
auto &) {
return std::make_unique<SpectrogramBounds>(); } };
724 return std::make_unique<SpectrogramBounds>(*
this);
731 const double rate = wt.
GetRate();
734 const auto type =
settings.scaleType;
736 const float top = (rate / 2.);
743 const auto half =
settings.GetFFTLength() / 2;
745 const float bin2 = rate / half;
753 float spectrumMax = mSpectrumMax;
759 max = std::clamp(spectrumMax, bottom, top);
763 float spectrumMin = mSpectrumMin;
767 min = std::max(bottom, top / 1000.0f);
769 min = std::clamp(spectrumMin, bottom, top);
Toolkit-neutral facade for basic user interface services.
void NewWindowFunc(int whichFunction, size_t NumSamplesIn, bool extraSample, float *in)
void DerivativeOfWindowFunc(int whichFunction, size_t NumSamples, bool extraSample, float *in)
audacity::BasicSettings * gPrefs
HFFT GetFFT(size_t fftlen)
IntSetting SpectrumMaxFreq
static const ChannelGroup::Attachments::RegisteredFactory key2
static const ChannelGroup::Attachments::RegisteredFactory key1
static Settings & settings()
std::vector< TranslatableString > TranslatableStrings
This specialization of Setting for bool adds a Toggle method to negate the saved value.
bool Write(const wxString &value)
Client code makes static instance from a factory of attachments; passes it to Get or Find as a retrie...
Specialization of Setting for double.
bool WriteEnum(Enum value)
Specialization of Setting for int.
bool Write(const T &value)
Write value to config and return true if successful.
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined */
PointerType Clone() const override
~SpectrogramBounds() override
void GetBounds(const WaveChannel &wc, float &min, float &max) const
static SpectrogramBounds & Get(WaveTrack &track)
Get either the global default settings, or the track's own if previously created.
void Migrate(wxString &value) override
Spectrogram settings, either for one track or as defaults.
static SpectrogramSettings & defaults()
void UpdatePrefs() override
static const TranslatableStrings & GetAlgorithmNames()
NumberScale GetScale(float minFreq, float maxFreq) const
bool SpectralSelectionEnabled() const
bool Validate(bool quiet)
static const EnumValueSymbols & GetScaleNames()
static SpectrogramSettings & Get(const WaveTrack &track)
size_t GetFFTLength() const
SpectrogramSettings & operator=(const SpectrogramSettings &other)
void ConvertToActualWindowSizes()
static const EnumValueSymbols & GetColorSchemeNames()
static SpectrogramSettings & Own(WaveChannel &wc)
PointerType Clone() const override
static ColorSchemeEnumSetting colorSchemeSetting
size_t ZeroPaddingFactor() const
float findBin(float frequency, float binUnit) const
static void Reset(WaveChannel &channel)
Make channel lose indpendent settings and use defaults.
void ConvertToEnumeratedWindowSizes()
size_t WindowSize() const
A Track that contains audio waveform data.
double GetRate() const override
virtual bool Flush() noexcept=0
virtual bool Read(const wxString &key, bool *value) const =0
MessageBoxResult ShowMessageBox(const TranslatableString &message, MessageBoxOptions options={})
Show a modal message box with either Ok or Yes and No, and optionally Cancel.
IntSetting SpectrumWindowFunction
BoolSetting SpectrumGrayscale
void RecreateWindow(Floats &window, int which, size_t fftLen, size_t padding, int windowType, size_t windowSize, double &scale)
BoolSetting SpectrumEnableSelection
IntSetting SpectrumFrequencyGain
IntSetting SpectrumZeroPaddingFactor
IntSetting SpectrumFFTSize
IntSetting SpectrumAlgorithm
IntSetting SpectrumMinFreq
Owner< Base > PointerType