mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-16 08:34:10 +02:00
Checkbox for defaulting track spectrogram settings (not seen in Preferences)
This commit is contained in:
parent
298bc981bf
commit
e8e3b8bec5
@ -20,6 +20,7 @@
|
|||||||
#include <wx/defs.h>
|
#include <wx/defs.h>
|
||||||
#include <wx/intl.h>
|
#include <wx/intl.h>
|
||||||
#include <wx/msgdlg.h>
|
#include <wx/msgdlg.h>
|
||||||
|
#include <wx/checkbox.h>
|
||||||
|
|
||||||
#include "../FFT.h"
|
#include "../FFT.h"
|
||||||
#include "../Project.h"
|
#include "../Project.h"
|
||||||
@ -31,14 +32,21 @@
|
|||||||
SpectrumPrefs::SpectrumPrefs(wxWindow * parent, WaveTrack *wt)
|
SpectrumPrefs::SpectrumPrefs(wxWindow * parent, WaveTrack *wt)
|
||||||
: PrefsPanel(parent, _("Spectrograms"))
|
: PrefsPanel(parent, _("Spectrograms"))
|
||||||
, mWt(wt)
|
, mWt(wt)
|
||||||
|
, mPopulating(false)
|
||||||
{
|
{
|
||||||
SpectrogramSettings *const pSettings = mWt
|
if (mWt) {
|
||||||
? &mWt->GetIndependentSpectrogramSettings()
|
SpectrogramSettings &settings = wt->GetSpectrogramSettings();
|
||||||
: &SpectrogramSettings::defaults();
|
mDefaulted = (&SpectrogramSettings::defaults() == &settings);
|
||||||
|
mTempSettings = settings;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mTempSettings = SpectrogramSettings::defaults();
|
||||||
|
mDefaulted = false;
|
||||||
|
}
|
||||||
|
|
||||||
mTempSettings = *pSettings;
|
const int windowSize = mTempSettings.windowSize;
|
||||||
mTempSettings.ConvertToEnumeratedWindowSizes();
|
mTempSettings.ConvertToEnumeratedWindowSizes();
|
||||||
Populate(pSettings->windowSize);
|
Populate(windowSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpectrumPrefs::~SpectrumPrefs()
|
SpectrumPrefs::~SpectrumPrefs()
|
||||||
@ -48,8 +56,16 @@ SpectrumPrefs::~SpectrumPrefs()
|
|||||||
enum {
|
enum {
|
||||||
ID_WINDOW_SIZE = 10001,
|
ID_WINDOW_SIZE = 10001,
|
||||||
#ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
|
#ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
|
||||||
ID_PADDING_SIZE = 10002,
|
ID_WINDOW_TYPE,
|
||||||
|
ID_PADDING_SIZE,
|
||||||
|
ID_MINIMUM,
|
||||||
|
ID_MAXIMUM,
|
||||||
|
ID_GAIN,
|
||||||
|
ID_RANGE,
|
||||||
|
ID_FREQUENCY_GAIN,
|
||||||
|
ID_GRAYSCALE,
|
||||||
#endif
|
#endif
|
||||||
|
ID_DEFAULTS,
|
||||||
};
|
};
|
||||||
|
|
||||||
void SpectrumPrefs::Populate(int windowSize)
|
void SpectrumPrefs::Populate(int windowSize)
|
||||||
@ -125,10 +141,16 @@ void SpectrumPrefs::PopulatePaddingChoices(int windowSize)
|
|||||||
|
|
||||||
void SpectrumPrefs::PopulateOrExchange(ShuttleGui & S)
|
void SpectrumPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||||
{
|
{
|
||||||
|
mPopulating = true;
|
||||||
|
|
||||||
S.SetBorder(2);
|
S.SetBorder(2);
|
||||||
|
|
||||||
// S.StartStatic(_("Track Settings"));
|
// S.StartStatic(_("Track Settings"));
|
||||||
{
|
{
|
||||||
|
mDefaultsCheckbox = 0;
|
||||||
|
if (mWt) {
|
||||||
|
mDefaultsCheckbox = S.Id(ID_DEFAULTS).TieCheckBox(_("Defaults"), mDefaulted);
|
||||||
|
}
|
||||||
S.StartStatic(_("FFT Window"));
|
S.StartStatic(_("FFT Window"));
|
||||||
{
|
{
|
||||||
S.StartMultiColumn(2);
|
S.StartMultiColumn(2);
|
||||||
@ -138,7 +160,7 @@ void SpectrumPrefs::PopulateOrExchange(ShuttleGui & S)
|
|||||||
&mSizeChoices);
|
&mSizeChoices);
|
||||||
S.SetSizeHints(mSizeChoices);
|
S.SetSizeHints(mSizeChoices);
|
||||||
|
|
||||||
S.TieChoice(_("Window &type:"),
|
S.Id(ID_WINDOW_TYPE).TieChoice(_("Window &type:"),
|
||||||
mTempSettings.windowType,
|
mTempSettings.windowType,
|
||||||
&mTypeChoices);
|
&mTypeChoices);
|
||||||
S.SetSizeHints(mTypeChoices);
|
S.SetSizeHints(mTypeChoices);
|
||||||
@ -159,33 +181,33 @@ void SpectrumPrefs::PopulateOrExchange(ShuttleGui & S)
|
|||||||
S.StartTwoColumn();
|
S.StartTwoColumn();
|
||||||
{
|
{
|
||||||
mMinFreq =
|
mMinFreq =
|
||||||
S.TieNumericTextBox(_("Mi&nimum Frequency (Hz):"),
|
S.Id(ID_MINIMUM).TieNumericTextBox(_("Mi&nimum Frequency (Hz):"),
|
||||||
mTempSettings.minFreq,
|
mTempSettings.minFreq,
|
||||||
12);
|
12);
|
||||||
|
|
||||||
mMaxFreq =
|
mMaxFreq =
|
||||||
S.TieNumericTextBox(_("Ma&ximum Frequency (Hz):"),
|
S.Id(ID_MAXIMUM).TieNumericTextBox(_("Ma&ximum Frequency (Hz):"),
|
||||||
mTempSettings.maxFreq,
|
mTempSettings.maxFreq,
|
||||||
12);
|
12);
|
||||||
|
|
||||||
mGain =
|
mGain =
|
||||||
S.TieNumericTextBox(_("&Gain (dB):"),
|
S.Id(ID_GAIN).TieNumericTextBox(_("&Gain (dB):"),
|
||||||
mTempSettings.gain,
|
mTempSettings.gain,
|
||||||
8);
|
8);
|
||||||
|
|
||||||
mRange =
|
mRange =
|
||||||
S.TieNumericTextBox(_("&Range (dB):"),
|
S.Id(ID_RANGE).TieNumericTextBox(_("&Range (dB):"),
|
||||||
mTempSettings.range,
|
mTempSettings.range,
|
||||||
8);
|
8);
|
||||||
|
|
||||||
mFrequencyGain =
|
mFrequencyGain =
|
||||||
S.TieNumericTextBox(_("Frequency g&ain (dB/dec):"),
|
S.Id(ID_FREQUENCY_GAIN).TieNumericTextBox(_("Frequency g&ain (dB/dec):"),
|
||||||
mTempSettings.frequencyGain,
|
mTempSettings.frequencyGain,
|
||||||
4);
|
4);
|
||||||
}
|
}
|
||||||
S.EndTwoColumn();
|
S.EndTwoColumn();
|
||||||
|
|
||||||
S.TieCheckBox(_("S&how the spectrum using grayscale colors"),
|
S.Id(ID_GRAYSCALE).TieCheckBox(_("S&how the spectrum using grayscale colors"),
|
||||||
mTempSettings.isGrayscale);
|
mTempSettings.isGrayscale);
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_FFT_Y_GRID
|
#ifdef EXPERIMENTAL_FFT_Y_GRID
|
||||||
@ -223,6 +245,8 @@ void SpectrumPrefs::PopulateOrExchange(ShuttleGui & S)
|
|||||||
#endif //EXPERIMENTAL_FIND_NOTES
|
#endif //EXPERIMENTAL_FIND_NOTES
|
||||||
}
|
}
|
||||||
// S.EndStatic();
|
// S.EndStatic();
|
||||||
|
|
||||||
|
mPopulating = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpectrumPrefs::Validate()
|
bool SpectrumPrefs::Validate()
|
||||||
@ -301,17 +325,24 @@ bool SpectrumPrefs::Apply()
|
|||||||
|
|
||||||
mTempSettings.ConvertToActualWindowSizes();
|
mTempSettings.ConvertToActualWindowSizes();
|
||||||
if (mWt) {
|
if (mWt) {
|
||||||
SpectrogramSettings *pSettings =
|
if (mDefaulted) {
|
||||||
&mWt->GetIndependentSpectrogramSettings();
|
mWt->SetSpectrogramSettings(NULL);
|
||||||
*pSettings = mTempSettings;
|
if (partner)
|
||||||
if (partner) {
|
partner->SetSpectrogramSettings(NULL);
|
||||||
pSettings = &partner->GetIndependentSpectrogramSettings();
|
}
|
||||||
|
else {
|
||||||
|
SpectrogramSettings *pSettings =
|
||||||
|
&mWt->GetIndependentSpectrogramSettings();
|
||||||
*pSettings = mTempSettings;
|
*pSettings = mTempSettings;
|
||||||
|
if (partner) {
|
||||||
|
pSettings = &partner->GetIndependentSpectrogramSettings();
|
||||||
|
*pSettings = mTempSettings;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
SpectrogramSettings *const pSettings =
|
if (!mWt || mDefaulted) {
|
||||||
&SpectrogramSettings::defaults();
|
SpectrogramSettings *const pSettings = &SpectrogramSettings::defaults();
|
||||||
*pSettings = mTempSettings;
|
*pSettings = mTempSettings;
|
||||||
pSettings->SavePrefs();
|
pSettings->SavePrefs();
|
||||||
}
|
}
|
||||||
@ -329,17 +360,57 @@ bool SpectrumPrefs::Apply()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpectrumPrefs::OnWindowSize(wxCommandEvent &)
|
void SpectrumPrefs::OnControl(wxCommandEvent&)
|
||||||
{
|
{
|
||||||
|
// Common routine for most controls
|
||||||
|
// If any per-track setting is changed, break the association with defaults
|
||||||
|
// Skip this, and View Settings... will be able to change defaults instead
|
||||||
|
// when the checkbox is on, as in the original design.
|
||||||
|
|
||||||
|
if (mDefaultsCheckbox && !mPopulating) {
|
||||||
|
mDefaulted = false;
|
||||||
|
mDefaultsCheckbox->SetValue(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpectrumPrefs::OnWindowSize(wxCommandEvent &evt)
|
||||||
|
{
|
||||||
|
// Restrict choice of zero padding, so that product of window
|
||||||
|
// size and padding may not exceed the largest window size.
|
||||||
wxChoice *const pWindowSizeControl =
|
wxChoice *const pWindowSizeControl =
|
||||||
static_cast<wxChoice*>(wxWindow::FindWindowById(ID_WINDOW_SIZE, this));
|
static_cast<wxChoice*>(wxWindow::FindWindowById(ID_WINDOW_SIZE, this));
|
||||||
int windowSize = 1 <<
|
int windowSize = 1 <<
|
||||||
(pWindowSizeControl->GetSelection() + SpectrogramSettings::LogMinWindowSize);
|
(pWindowSizeControl->GetSelection() + SpectrogramSettings::LogMinWindowSize);
|
||||||
PopulatePaddingChoices(windowSize);
|
PopulatePaddingChoices(windowSize);
|
||||||
|
|
||||||
|
// Do the common part
|
||||||
|
OnControl(evt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpectrumPrefs::OnDefaults(wxCommandEvent &)
|
||||||
|
{
|
||||||
|
if (mDefaultsCheckbox->IsChecked()) {
|
||||||
|
mTempSettings = SpectrogramSettings::defaults();
|
||||||
|
mTempSettings.ConvertToEnumeratedWindowSizes();
|
||||||
|
mDefaulted = true;
|
||||||
|
ShuttleGui S(this, eIsSettingToDialog);
|
||||||
|
PopulateOrExchange(S);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(SpectrumPrefs, PrefsPanel)
|
BEGIN_EVENT_TABLE(SpectrumPrefs, PrefsPanel)
|
||||||
EVT_CHOICE(ID_WINDOW_SIZE, SpectrumPrefs::OnWindowSize)
|
EVT_CHOICE(ID_WINDOW_SIZE, SpectrumPrefs::OnWindowSize)
|
||||||
|
EVT_CHECKBOX(ID_DEFAULTS, SpectrumPrefs::OnDefaults)
|
||||||
|
|
||||||
|
// 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_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)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
SpectrumPrefsFactory::SpectrumPrefsFactory(WaveTrack *wt)
|
SpectrumPrefsFactory::SpectrumPrefsFactory(WaveTrack *wt)
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
#include "PrefsPanel.h"
|
#include "PrefsPanel.h"
|
||||||
#include "SpectrogramSettings.h"
|
#include "SpectrogramSettings.h"
|
||||||
|
|
||||||
|
class wxChoice;
|
||||||
|
class wxCheckBox;
|
||||||
class wxTextCtrl;
|
class wxTextCtrl;
|
||||||
struct FFTParam;
|
struct FFTParam;
|
||||||
class ShuttleGui;
|
class ShuttleGui;
|
||||||
@ -49,10 +51,13 @@ class SpectrumPrefs:public PrefsPanel
|
|||||||
void PopulatePaddingChoices(int windowSize);
|
void PopulatePaddingChoices(int windowSize);
|
||||||
void PopulateOrExchange(ShuttleGui & S);
|
void PopulateOrExchange(ShuttleGui & S);
|
||||||
|
|
||||||
|
void OnControl(wxCommandEvent &event);
|
||||||
void OnWindowSize(wxCommandEvent &event);
|
void OnWindowSize(wxCommandEvent &event);
|
||||||
|
void OnDefaults(wxCommandEvent&);
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
|
||||||
WaveTrack *const mWt;
|
WaveTrack *const mWt;
|
||||||
|
bool mDefaulted;
|
||||||
|
|
||||||
wxTextCtrl *mMinFreq;
|
wxTextCtrl *mMinFreq;
|
||||||
wxTextCtrl *mMaxFreq;
|
wxTextCtrl *mMaxFreq;
|
||||||
@ -75,7 +80,11 @@ class SpectrumPrefs:public PrefsPanel
|
|||||||
wxTextCtrl *mFindNotesN;
|
wxTextCtrl *mFindNotesN;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
wxCheckBox *mDefaultsCheckbox;
|
||||||
|
|
||||||
SpectrogramSettings mTempSettings;
|
SpectrogramSettings mTempSettings;
|
||||||
|
|
||||||
|
bool mPopulating;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SpectrumPrefsFactory : public PrefsPanelFactory
|
class SpectrumPrefsFactory : public PrefsPanelFactory
|
||||||
|
Loading…
x
Reference in New Issue
Block a user