mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-26 07:13:49 +01:00
WaveTrack::WaveTrackDisplay does not encode scale or spectral selection...
... SpectrogramSettings does that instead, and Preferences or View Settings are the user interface for changing it. Handle invalidation of spectrogram pixel cache for scale type changes, just as for other changes of settings. No more TrackArtist::InvalidateSpectrumCache(). View type of track now switches to Spectrum when applying or OKing the View Settings... dialog and the Spectrogram page is open (and for now it is still the only page)
This commit is contained in:
@@ -47,6 +47,8 @@ SpectrogramSettings::SpectrogramSettings(const SpectrogramSettings &other)
|
||||
, zeroPaddingFactor(other.zeroPaddingFactor)
|
||||
#endif
|
||||
, isGrayscale(other.isGrayscale)
|
||||
, scaleType(other.scaleType)
|
||||
, spectralSelection(other.spectralSelection)
|
||||
#ifdef EXPERIMENTAL_FFT_Y_GRID
|
||||
, fftYGrid(other.fftYGrid)
|
||||
#endif
|
||||
@@ -79,6 +81,8 @@ SpectrogramSettings &SpectrogramSettings::operator= (const SpectrogramSettings &
|
||||
zeroPaddingFactor = other.zeroPaddingFactor;
|
||||
#endif
|
||||
isGrayscale = other.isGrayscale;
|
||||
scaleType = other.scaleType;
|
||||
spectralSelection = other.spectralSelection;
|
||||
#ifdef EXPERIMENTAL_FFT_Y_GRID
|
||||
fftYGrid = other.fftYGrid;
|
||||
#endif
|
||||
@@ -102,6 +106,35 @@ SpectrogramSettings& SpectrogramSettings::defaults()
|
||||
return instance;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
wxArrayString &scaleNamesArray()
|
||||
{
|
||||
static wxArrayString theArray;
|
||||
return theArray;
|
||||
}
|
||||
}
|
||||
|
||||
//static
|
||||
void SpectrogramSettings::InvalidateNames()
|
||||
{
|
||||
scaleNamesArray().Clear();
|
||||
}
|
||||
|
||||
//static
|
||||
const wxArrayString &SpectrogramSettings::GetScaleNames()
|
||||
{
|
||||
wxArrayString &theArray = scaleNamesArray();
|
||||
|
||||
if (theArray.IsEmpty()) {
|
||||
// Keep in correspondence with enum SpectrogramSettings::ScaleType:
|
||||
theArray.Add(_("Linear"));
|
||||
theArray.Add(_("Logarithmic"));
|
||||
}
|
||||
|
||||
return theArray;
|
||||
}
|
||||
|
||||
bool SpectrogramSettings::Validate(bool quiet)
|
||||
{
|
||||
if (!quiet &&
|
||||
@@ -155,6 +188,10 @@ bool SpectrogramSettings::Validate(bool quiet)
|
||||
// preference files, which could be or from future versions. Validate quietly.
|
||||
windowType =
|
||||
std::max(0, std::min(NumWindowFuncs() - 1, windowType));
|
||||
scaleType =
|
||||
ScaleType(std::max(0,
|
||||
std::min(int(SpectrogramSettings::stNumScaleTypes) - 1,
|
||||
int(scaleType))));
|
||||
ConvertToEnumeratedWindowSizes();
|
||||
ConvertToActualWindowSizes();
|
||||
|
||||
@@ -181,6 +218,9 @@ void SpectrogramSettings::LoadPrefs()
|
||||
|
||||
isGrayscale = (gPrefs->Read(wxT("/Spectrum/Grayscale"), 0L) != 0);
|
||||
|
||||
scaleType = ScaleType(gPrefs->Read(wxT("/Spectrum/ScaleType"), 0L));
|
||||
spectralSelection = (gPrefs->Read(wxT("/Spectrum/EnableSpectralSelection"), 0L) != 0);
|
||||
|
||||
#ifdef EXPERIMENTAL_FFT_Y_GRID
|
||||
fftYGrid = (gPrefs->Read(wxT("/Spectrum/FFTYGrid"), 0L) != 0);
|
||||
#endif //EXPERIMENTAL_FFT_Y_GRID
|
||||
@@ -235,6 +275,9 @@ void SpectrogramSettings::SavePrefs()
|
||||
|
||||
gPrefs->Write(wxT("/Spectrum/Grayscale"), isGrayscale);
|
||||
|
||||
gPrefs->Write(wxT("/Spectrum/ScaleType"), scaleType);
|
||||
gPrefs->Write(wxT("/Spectrum/EnableSpectralSelection"), spectralSelection);
|
||||
|
||||
#ifdef EXPERIMENTAL_FFT_Y_GRID
|
||||
gPrefs->Write(wxT("/Spectrum/FFTYGrid"), fftYGrid);
|
||||
#endif //EXPERIMENTAL_FFT_Y_GRID
|
||||
|
||||
@@ -15,6 +15,7 @@ Paul Licameli
|
||||
|
||||
struct FFTParam;
|
||||
class SpectrumPrefs;
|
||||
class wxArrayString;
|
||||
|
||||
class SpectrogramSettings
|
||||
{
|
||||
@@ -28,6 +29,19 @@ public:
|
||||
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.
|
||||
enum ScaleType {
|
||||
stLinear,
|
||||
stLogarithmic,
|
||||
|
||||
stNumScaleTypes,
|
||||
};
|
||||
|
||||
static void InvalidateNames(); // in case of language change
|
||||
static const wxArrayString &GetScaleNames();
|
||||
|
||||
static SpectrogramSettings &defaults();
|
||||
SpectrogramSettings();
|
||||
SpectrogramSettings(const SpectrogramSettings &other);
|
||||
@@ -79,6 +93,10 @@ public:
|
||||
|
||||
bool isGrayscale;
|
||||
|
||||
ScaleType scaleType;
|
||||
|
||||
bool spectralSelection; // But should this vary per track? -- PRL
|
||||
|
||||
#ifdef EXPERIMENTAL_FFT_Y_GRID
|
||||
bool fftYGrid;
|
||||
#endif //EXPERIMENTAL_FFT_Y_GRID
|
||||
|
||||
@@ -59,12 +59,14 @@ enum {
|
||||
#ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
|
||||
ID_WINDOW_TYPE,
|
||||
ID_PADDING_SIZE,
|
||||
ID_SCALE,
|
||||
ID_MINIMUM,
|
||||
ID_MAXIMUM,
|
||||
ID_GAIN,
|
||||
ID_RANGE,
|
||||
ID_FREQUENCY_GAIN,
|
||||
ID_GRAYSCALE,
|
||||
ID_SPECTRAL_SELECTION,
|
||||
#endif
|
||||
ID_DEFAULTS,
|
||||
ID_APPLY,
|
||||
@@ -93,6 +95,7 @@ void SpectrumPrefs::Populate(int windowSize)
|
||||
mTypeChoices.Add(WindowFuncName(i));
|
||||
}
|
||||
|
||||
mScaleChoices = SpectrogramSettings::GetScaleNames();
|
||||
|
||||
//------------------------- Main section --------------------
|
||||
// Now construct the GUI itself.
|
||||
@@ -182,6 +185,10 @@ void SpectrumPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
{
|
||||
S.StartTwoColumn();
|
||||
{
|
||||
S.Id(ID_SCALE).TieChoice(_("S&cale") + wxString(wxT(":")),
|
||||
*(int*)&mTempSettings.scaleType,
|
||||
&mScaleChoices);
|
||||
|
||||
mMinFreq =
|
||||
S.Id(ID_MINIMUM).TieNumericTextBox(_("Mi&nimum Frequency (Hz):"),
|
||||
mTempSettings.minFreq,
|
||||
@@ -211,6 +218,8 @@ void SpectrumPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
|
||||
S.Id(ID_GRAYSCALE).TieCheckBox(_("S&how the spectrum using grayscale colors"),
|
||||
mTempSettings.isGrayscale);
|
||||
S.Id(ID_SPECTRAL_SELECTION).TieCheckBox(_("Ena&ble spectral selection"),
|
||||
mTempSettings.spectralSelection);
|
||||
|
||||
#ifdef EXPERIMENTAL_FFT_Y_GRID
|
||||
S.TieCheckBox(_("Show a grid along the &Y-axis"),
|
||||
@@ -358,11 +367,9 @@ bool SpectrumPrefs::Apply()
|
||||
|
||||
if (mWt && isOpenPage) {
|
||||
// Future: open page will determine the track view type
|
||||
/*
|
||||
mWt->SetDisplay(WaveTrack::Spectrum);
|
||||
if (partner)
|
||||
partner->SetDisplay(WaveTrack::Spectrum);
|
||||
*/
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -421,14 +428,17 @@ BEGIN_EVENT_TABLE(SpectrumPrefs, PrefsPanel)
|
||||
// Several controls with common routine that unchecks the default box
|
||||
EVT_CHOICE(ID_WINDOW_TYPE, SpectrumPrefs::OnControl)
|
||||
EVT_CHOICE(ID_PADDING_SIZE, SpectrumPrefs::OnControl)
|
||||
EVT_CHOICE(ID_SCALE, SpectrumPrefs::OnControl)
|
||||
EVT_TEXT(ID_MINIMUM, SpectrumPrefs::OnControl)
|
||||
EVT_TEXT(ID_MAXIMUM, SpectrumPrefs::OnControl)
|
||||
EVT_TEXT(ID_GAIN, SpectrumPrefs::OnControl)
|
||||
EVT_TEXT(ID_RANGE, SpectrumPrefs::OnControl)
|
||||
EVT_TEXT(ID_FREQUENCY_GAIN, SpectrumPrefs::OnControl)
|
||||
EVT_CHECKBOX(ID_GRAYSCALE, SpectrumPrefs::OnControl)
|
||||
EVT_CHECKBOX(ID_SPECTRAL_SELECTION, SpectrumPrefs::OnControl)
|
||||
|
||||
EVT_BUTTON(ID_APPLY, SpectrumPrefs::OnApply)
|
||||
|
||||
END_EVENT_TABLE()
|
||||
|
||||
SpectrumPrefsFactory::SpectrumPrefsFactory(WaveTrack *wt)
|
||||
|
||||
@@ -74,6 +74,7 @@ class SpectrumPrefs:public PrefsPanel
|
||||
#endif
|
||||
|
||||
wxArrayString mTypeChoices;
|
||||
wxArrayString mScaleChoices;
|
||||
|
||||
|
||||
#ifdef EXPERIMENTAL_FIND_NOTES
|
||||
|
||||
@@ -65,17 +65,8 @@ void TracksPrefs::Populate()
|
||||
mViewChoices.Add(_("Waveform (dB)"));
|
||||
mViewCodes.Add(int(WaveTrack::WaveformDBDisplay));
|
||||
|
||||
mViewChoices.Add(_("Spectrogram"));
|
||||
mViewCodes.Add(int(WaveTrack::SpectrumDisplay));
|
||||
|
||||
mViewChoices.Add(_("Spectrogram log(f)"));
|
||||
mViewCodes.Add(int(WaveTrack::SpectrumLogDisplay));
|
||||
|
||||
mViewChoices.Add(_("Spectral Selection"));
|
||||
mViewCodes.Add(int(WaveTrack::SpectralSelectionDisplay));
|
||||
|
||||
mViewChoices.Add(_("Spectral Selection log(f)"));
|
||||
mViewCodes.Add(int(WaveTrack::SpectralSelectionLogDisplay));
|
||||
mViewChoices.Add(_("Spectrum"));
|
||||
mViewCodes.Add(WaveTrack::Spectrum);
|
||||
|
||||
mViewChoices.Add(_("Pitch (EAC)"));
|
||||
mViewCodes.Add(int(WaveTrack::PitchDisplay));
|
||||
|
||||
Reference in New Issue
Block a user