mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-26 07:13:49 +01:00
Conditional compilation (disabled) to make Spectral selection choice global...
... not per track, and the preferences or View Settings page has a separate static box for global settings as opposed to track settings. This is the only global setting for now.
This commit is contained in:
@@ -26,6 +26,33 @@ Paul Licameli
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
SpectrogramSettings::Globals::Globals()
|
||||
{
|
||||
LoadPrefs();
|
||||
}
|
||||
|
||||
void SpectrogramSettings::Globals::SavePrefs()
|
||||
{
|
||||
#ifdef SPECTRAL_SELECTION_GLOBAL_SWITCH
|
||||
gPrefs->Write(wxT("/Spectrum/EnableSpectralSelection"), spectralSelection);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SpectrogramSettings::Globals::LoadPrefs()
|
||||
{
|
||||
#ifdef SPECTRAL_SELECTION_GLOBAL_SWITCH
|
||||
spectralSelection
|
||||
= (gPrefs->Read(wxT("/Spectrum/EnableSpectralSelection"), 0L) != 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
SpectrogramSettings::Globals
|
||||
&SpectrogramSettings::Globals::Get()
|
||||
{
|
||||
static Globals instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
SpectrogramSettings::SpectrogramSettings()
|
||||
: hFFT(0)
|
||||
, window(0)
|
||||
@@ -48,7 +75,9 @@ SpectrogramSettings::SpectrogramSettings(const SpectrogramSettings &other)
|
||||
#endif
|
||||
, isGrayscale(other.isGrayscale)
|
||||
, scaleType(other.scaleType)
|
||||
#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
|
||||
, spectralSelection(other.spectralSelection)
|
||||
#endif
|
||||
#ifdef EXPERIMENTAL_FFT_Y_GRID
|
||||
, fftYGrid(other.fftYGrid)
|
||||
#endif
|
||||
@@ -82,7 +111,9 @@ SpectrogramSettings &SpectrogramSettings::operator= (const SpectrogramSettings &
|
||||
#endif
|
||||
isGrayscale = other.isGrayscale;
|
||||
scaleType = other.scaleType;
|
||||
#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
|
||||
spectralSelection = other.spectralSelection;
|
||||
#endif
|
||||
#ifdef EXPERIMENTAL_FFT_Y_GRID
|
||||
fftYGrid = other.fftYGrid;
|
||||
#endif
|
||||
@@ -219,7 +250,10 @@ void SpectrogramSettings::LoadPrefs()
|
||||
isGrayscale = (gPrefs->Read(wxT("/Spectrum/Grayscale"), 0L) != 0);
|
||||
|
||||
scaleType = ScaleType(gPrefs->Read(wxT("/Spectrum/ScaleType"), 0L));
|
||||
|
||||
#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
|
||||
spectralSelection = (gPrefs->Read(wxT("/Spectrum/EnableSpectralSelection"), 0L) != 0);
|
||||
#endif
|
||||
|
||||
#ifdef EXPERIMENTAL_FFT_Y_GRID
|
||||
fftYGrid = (gPrefs->Read(wxT("/Spectrum/FFTYGrid"), 0L) != 0);
|
||||
@@ -276,7 +310,10 @@ void SpectrogramSettings::SavePrefs()
|
||||
gPrefs->Write(wxT("/Spectrum/Grayscale"), isGrayscale);
|
||||
|
||||
gPrefs->Write(wxT("/Spectrum/ScaleType"), scaleType);
|
||||
|
||||
#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
|
||||
gPrefs->Write(wxT("/Spectrum/EnableSpectralSelection"), spectralSelection);
|
||||
#endif
|
||||
|
||||
#ifdef EXPERIMENTAL_FFT_Y_GRID
|
||||
gPrefs->Write(wxT("/Spectrum/FFTYGrid"), fftYGrid);
|
||||
@@ -486,3 +523,12 @@ int SpectrogramSettings::GetFFTLength(bool autocorrelation) const
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
bool SpectrogramSettings::SpectralSelectionEnabled() const
|
||||
{
|
||||
#ifdef SPECTRAL_SELECTION_GLOBAL_SWITCH
|
||||
return Globals::Get().spectralSelection;
|
||||
#else
|
||||
return spectralSelection;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ Paul Licameli
|
||||
|
||||
#include "../Experimental.h"
|
||||
|
||||
#undef SPECTRAL_SELECTION_GLOBAL_SWITCH
|
||||
|
||||
struct FFTParam;
|
||||
class SpectrumPrefs;
|
||||
class wxArrayString;
|
||||
@@ -22,6 +24,22 @@ class SpectrogramSettings
|
||||
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,
|
||||
@@ -72,6 +90,7 @@ public:
|
||||
int GetMaxFreq(double rate) const;
|
||||
int GetLogMinFreq(double rate) const;
|
||||
int GetLogMaxFreq(double rate) const;
|
||||
bool SpectralSelectionEnabled() const;
|
||||
|
||||
void SetMinFreq(int freq);
|
||||
void SetMaxFreq(int freq);
|
||||
@@ -95,7 +114,9 @@ public:
|
||||
|
||||
ScaleType scaleType;
|
||||
|
||||
#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
|
||||
bool spectralSelection; // But should this vary per track? -- PRL
|
||||
#endif
|
||||
|
||||
#ifdef EXPERIMENTAL_FFT_Y_GRID
|
||||
bool fftYGrid;
|
||||
@@ -116,5 +137,4 @@ public:
|
||||
mutable float *window;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -218,8 +218,11 @@ void SpectrumPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
|
||||
S.Id(ID_GRAYSCALE).TieCheckBox(_("S&how the spectrum using grayscale colors"),
|
||||
mTempSettings.isGrayscale);
|
||||
|
||||
#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
|
||||
S.Id(ID_SPECTRAL_SELECTION).TieCheckBox(_("Ena&ble spectral selection"),
|
||||
mTempSettings.spectralSelection);
|
||||
#endif
|
||||
|
||||
#ifdef EXPERIMENTAL_FFT_Y_GRID
|
||||
S.TieCheckBox(_("Show a grid along the &Y-axis"),
|
||||
@@ -257,6 +260,15 @@ void SpectrumPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
}
|
||||
// S.EndStatic();
|
||||
|
||||
#ifdef SPECTRAL_SELECTION_GLOBAL_SWITCH
|
||||
S.StartStatic(_("Global settings"));
|
||||
{
|
||||
S.TieCheckBox(_("Ena&ble spectral selection"),
|
||||
SpectrogramSettings::Globals::Get().spectralSelection);
|
||||
}
|
||||
S.EndStatic();
|
||||
#endif
|
||||
|
||||
S.StartMultiColumn(2, wxALIGN_RIGHT);
|
||||
{
|
||||
S.Id(ID_APPLY).AddButton(_("Appl&y"));
|
||||
@@ -340,7 +352,10 @@ bool SpectrumPrefs::Apply()
|
||||
ShuttleGui S(this, eIsGettingFromDialog);
|
||||
PopulateOrExchange(S);
|
||||
|
||||
|
||||
mTempSettings.ConvertToActualWindowSizes();
|
||||
SpectrogramSettings::Globals::Get().SavePrefs(); // always
|
||||
|
||||
if (mWt) {
|
||||
if (mDefaulted) {
|
||||
mWt->SetSpectrogramSettings(NULL);
|
||||
|
||||
Reference in New Issue
Block a user