mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-16 08:34:10 +02:00
Add "View Settings..." to track drop-down and Apply button to Spectrogram prefs
This commit is contained in:
commit
504d4b5331
@ -217,7 +217,8 @@ is time to refresh some aspect of the screen.
|
|||||||
|
|
||||||
#include "ondemand/ODManager.h"
|
#include "ondemand/ODManager.h"
|
||||||
|
|
||||||
#include "prefs/SpectrogramSettings.h"
|
#include "prefs/PrefsDialog.h"
|
||||||
|
#include "prefs/SpectrumPrefs.h"
|
||||||
|
|
||||||
#include "toolbars/ControlToolBar.h"
|
#include "toolbars/ControlToolBar.h"
|
||||||
#include "toolbars/ToolManager.h"
|
#include "toolbars/ToolManager.h"
|
||||||
@ -330,6 +331,7 @@ enum {
|
|||||||
OnSpectralSelID,
|
OnSpectralSelID,
|
||||||
OnSpectralSelLogID,
|
OnSpectralSelLogID,
|
||||||
OnPitchID,
|
OnPitchID,
|
||||||
|
OnViewSettingsID,
|
||||||
|
|
||||||
OnSplitStereoID,
|
OnSplitStereoID,
|
||||||
OnSplitStereoMonoID,
|
OnSplitStereoMonoID,
|
||||||
@ -369,6 +371,7 @@ BEGIN_EVENT_TABLE(TrackPanel, wxWindow)
|
|||||||
EVT_MENU_RANGE(OnChannelLeftID, OnChannelMonoID,
|
EVT_MENU_RANGE(OnChannelLeftID, OnChannelMonoID,
|
||||||
TrackPanel::OnChannelChange)
|
TrackPanel::OnChannelChange)
|
||||||
EVT_MENU_RANGE(OnWaveformID, OnPitchID, TrackPanel::OnSetDisplay)
|
EVT_MENU_RANGE(OnWaveformID, OnPitchID, TrackPanel::OnSetDisplay)
|
||||||
|
EVT_MENU(OnViewSettingsID, TrackPanel::OnViewSettings)
|
||||||
EVT_MENU_RANGE(OnRate8ID, OnRate384ID, TrackPanel::OnRateChange)
|
EVT_MENU_RANGE(OnRate8ID, OnRate384ID, TrackPanel::OnRateChange)
|
||||||
EVT_MENU_RANGE(On16BitID, OnFloatID, TrackPanel::OnFormatChange)
|
EVT_MENU_RANGE(On16BitID, OnFloatID, TrackPanel::OnFormatChange)
|
||||||
EVT_MENU(OnRateOtherID, TrackPanel::OnRateOther)
|
EVT_MENU(OnRateOtherID, TrackPanel::OnRateOther)
|
||||||
@ -731,9 +734,10 @@ void TrackPanel::BuildMenus(void)
|
|||||||
mWaveTrackMenu->Append(OnSpectralSelID, _("S&pectral Selection"));
|
mWaveTrackMenu->Append(OnSpectralSelID, _("S&pectral Selection"));
|
||||||
/* i18n-hint: short form of 'logarithm'*/
|
/* i18n-hint: short form of 'logarithm'*/
|
||||||
mWaveTrackMenu->Append(OnSpectralSelLogID, _("Spectral Selection lo&g(f)"));
|
mWaveTrackMenu->Append(OnSpectralSelLogID, _("Spectral Selection lo&g(f)"));
|
||||||
|
|
||||||
mWaveTrackMenu->Append(OnPitchID, _("Pitc&h (EAC)"));
|
mWaveTrackMenu->Append(OnPitchID, _("Pitc&h (EAC)"));
|
||||||
|
mWaveTrackMenu->Append(OnViewSettingsID, _("View& Settings...")); // PRL: all the other letters already taken for accelerators!
|
||||||
mWaveTrackMenu->AppendSeparator();
|
mWaveTrackMenu->AppendSeparator();
|
||||||
|
|
||||||
mWaveTrackMenu->AppendRadioItem(OnChannelMonoID, _("&Mono"));
|
mWaveTrackMenu->AppendRadioItem(OnChannelMonoID, _("&Mono"));
|
||||||
mWaveTrackMenu->AppendRadioItem(OnChannelLeftID, _("&Left Channel"));
|
mWaveTrackMenu->AppendRadioItem(OnChannelLeftID, _("&Left Channel"));
|
||||||
mWaveTrackMenu->AppendRadioItem(OnChannelRightID, _("&Right Channel"));
|
mWaveTrackMenu->AppendRadioItem(OnChannelRightID, _("&Right Channel"));
|
||||||
@ -8569,6 +8573,7 @@ void TrackPanel::OnTrackMenu(Track *t)
|
|||||||
theMenu->Enable(OnSpectralSelID, display != WaveTrack::SpectralSelectionDisplay);
|
theMenu->Enable(OnSpectralSelID, display != WaveTrack::SpectralSelectionDisplay);
|
||||||
theMenu->Enable(OnSpectralSelLogID, display != WaveTrack::SpectralSelectionLogDisplay);
|
theMenu->Enable(OnSpectralSelLogID, display != WaveTrack::SpectralSelectionLogDisplay);
|
||||||
theMenu->Enable(OnPitchID, display != WaveTrack::PitchDisplay);
|
theMenu->Enable(OnPitchID, display != WaveTrack::PitchDisplay);
|
||||||
|
theMenu->Enable(OnViewSettingsID, true);
|
||||||
|
|
||||||
WaveTrack * track = (WaveTrack *)t;
|
WaveTrack * track = (WaveTrack *)t;
|
||||||
SetMenuCheck(*mRateMenu, IdOfRate((int) track->GetRate()));
|
SetMenuCheck(*mRateMenu, IdOfRate((int) track->GetRate()));
|
||||||
@ -9030,6 +9035,37 @@ void TrackPanel::OnMergeStereo(wxCommandEvent & WXUNUSED(event))
|
|||||||
Refresh(false);
|
Refresh(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ViewSettingsDialog : public PrefsDialog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ViewSettingsDialog(wxWindow *parent, PrefsDialog::Factories &factories)
|
||||||
|
: PrefsDialog(parent, _("View Settings: "), factories)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual long GetPreferredPage()
|
||||||
|
{
|
||||||
|
// Future: choose Spectrum or Waveform page
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void SavePreferredPage()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void TrackPanel::OnViewSettings(wxCommandEvent &)
|
||||||
|
{
|
||||||
|
WaveTrack *const wt = static_cast<WaveTrack*>(mPopupMenuTarget);
|
||||||
|
SpectrumPrefsFactory spectrumFactory(wt);
|
||||||
|
PrefsDialog::Factories factories;
|
||||||
|
factories.push_back(&spectrumFactory);
|
||||||
|
ViewSettingsDialog dialog(this, factories);
|
||||||
|
if (0 != dialog.ShowModal())
|
||||||
|
// Redraw
|
||||||
|
Refresh(false);
|
||||||
|
}
|
||||||
|
|
||||||
/// Set the Display mode based on the menu choice in the Track Menu.
|
/// Set the Display mode based on the menu choice in the Track Menu.
|
||||||
/// Note that gModes MUST BE IN THE SAME ORDER AS THE MENU CHOICES!!
|
/// Note that gModes MUST BE IN THE SAME ORDER AS THE MENU CHOICES!!
|
||||||
/// const wxChar *gModes[] = { wxT("waveform"), wxT("waveformDB"),
|
/// const wxChar *gModes[] = { wxT("waveform"), wxT("waveformDB"),
|
||||||
|
@ -459,6 +459,7 @@ protected:
|
|||||||
virtual void MoveTrack(Track* target, int eventId);
|
virtual void MoveTrack(Track* target, int eventId);
|
||||||
virtual void OnChangeOctave (wxCommandEvent &event);
|
virtual void OnChangeOctave (wxCommandEvent &event);
|
||||||
virtual void OnChannelChange(wxCommandEvent &event);
|
virtual void OnChannelChange(wxCommandEvent &event);
|
||||||
|
virtual void OnViewSettings(wxCommandEvent &event);
|
||||||
virtual void OnSetDisplay (wxCommandEvent &event);
|
virtual void OnSetDisplay (wxCommandEvent &event);
|
||||||
virtual void OnSetTimeTrackRange (wxCommandEvent &event);
|
virtual void OnSetTimeTrackRange (wxCommandEvent &event);
|
||||||
virtual void OnTimeTrackLin(wxCommandEvent &event);
|
virtual void OnTimeTrackLin(wxCommandEvent &event);
|
||||||
|
@ -15,6 +15,10 @@ Paul Licameli
|
|||||||
|
|
||||||
#include "../Audacity.h"
|
#include "../Audacity.h"
|
||||||
#include "SpectrogramSettings.h"
|
#include "SpectrogramSettings.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <wx/msgdlg.h>
|
||||||
|
|
||||||
#include "../FFT.h"
|
#include "../FFT.h"
|
||||||
#include "../Prefs.h"
|
#include "../Prefs.h"
|
||||||
#include "../RealFFTf.h"
|
#include "../RealFFTf.h"
|
||||||
@ -26,7 +30,7 @@ SpectrogramSettings::SpectrogramSettings()
|
|||||||
: hFFT(0)
|
: hFFT(0)
|
||||||
, window(0)
|
, window(0)
|
||||||
{
|
{
|
||||||
UpdatePrefs();
|
LoadPrefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
SpectrogramSettings::SpectrogramSettings(const SpectrogramSettings &other)
|
SpectrogramSettings::SpectrogramSettings(const SpectrogramSettings &other)
|
||||||
@ -98,49 +102,82 @@ SpectrogramSettings& SpectrogramSettings::defaults()
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpectrogramSettings::UpdatePrefs()
|
bool SpectrogramSettings::Validate(bool quiet)
|
||||||
{
|
{
|
||||||
bool destroy = false;
|
if (!quiet &&
|
||||||
|
maxFreq < 100) {
|
||||||
|
wxMessageBox(_("Maximum frequency must be 100 Hz or above"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
maxFreq = std::max(100, maxFreq);
|
||||||
|
|
||||||
|
if (!quiet &&
|
||||||
|
minFreq < 0) {
|
||||||
|
wxMessageBox(_("Minimum frequency must be at least 0 Hz"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
minFreq = std::max(0, minFreq);
|
||||||
|
|
||||||
|
if (!quiet &&
|
||||||
|
maxFreq <= minFreq) {
|
||||||
|
wxMessageBox(_("Minimum frequency must be less than maximum frequency"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
maxFreq = std::max(1 + minFreq, maxFreq);
|
||||||
|
|
||||||
|
if (!quiet &&
|
||||||
|
range <= 0) {
|
||||||
|
wxMessageBox(_("The range must be at least 1 dB"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
range = std::max(1, range);
|
||||||
|
|
||||||
|
if (!quiet &&
|
||||||
|
frequencyGain < 0) {
|
||||||
|
wxMessageBox(_("The frequency gain cannot be negative"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (!quiet &&
|
||||||
|
frequencyGain > 60) {
|
||||||
|
wxMessageBox(_("The frequency gain must be no more than 60 dB/dec"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
frequencyGain =
|
||||||
|
std::max(0, std::min(60, frequencyGain));
|
||||||
|
|
||||||
|
// The rest are controlled by drop-down menus so they can't go wrong
|
||||||
|
// in the Preferences dialog, but we also come here after reading fom saved
|
||||||
|
// preference files, which could be or from future versions. Validate quietly.
|
||||||
|
windowType =
|
||||||
|
std::max(0, std::min(NumWindowFuncs() - 1, windowType));
|
||||||
|
ConvertToEnumeratedWindowSizes();
|
||||||
|
ConvertToActualWindowSizes();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpectrogramSettings::LoadPrefs()
|
||||||
|
{
|
||||||
|
minFreq = gPrefs->Read(wxT("/Spectrum/MinFreq"), 0L);
|
||||||
|
|
||||||
minFreq = gPrefs->Read(wxT("/Spectrum/MinFreq"), -1L);
|
|
||||||
maxFreq = gPrefs->Read(wxT("/Spectrum/MaxFreq"), 8000L);
|
maxFreq = gPrefs->Read(wxT("/Spectrum/MaxFreq"), 8000L);
|
||||||
|
|
||||||
// These preferences are not written anywhere in the program as of now,
|
|
||||||
// but I keep this legacy here. Who knows, someone might edit prefs files
|
|
||||||
// directly. PRL
|
|
||||||
logMaxFreq = gPrefs->Read(wxT("/SpectrumLog/MaxFreq"), -1);
|
|
||||||
if (logMaxFreq < 0)
|
|
||||||
logMaxFreq = maxFreq;
|
|
||||||
logMinFreq = gPrefs->Read(wxT("/SpectrumLog/MinFreq"), -1);
|
|
||||||
if (logMinFreq < 0)
|
|
||||||
logMinFreq = minFreq;
|
|
||||||
if (logMinFreq < 1)
|
|
||||||
logMinFreq = 1;
|
|
||||||
|
|
||||||
range = gPrefs->Read(wxT("/Spectrum/Range"), 80L);
|
range = gPrefs->Read(wxT("/Spectrum/Range"), 80L);
|
||||||
gain = gPrefs->Read(wxT("/Spectrum/Gain"), 20L);
|
gain = gPrefs->Read(wxT("/Spectrum/Gain"), 20L);
|
||||||
frequencyGain = gPrefs->Read(wxT("/Spectrum/FrequencyGain"), 0L);
|
frequencyGain = gPrefs->Read(wxT("/Spectrum/FrequencyGain"), 0L);
|
||||||
|
|
||||||
const int newWindowSize = gPrefs->Read(wxT("/Spectrum/FFTSize"), 256);
|
windowSize = gPrefs->Read(wxT("/Spectrum/FFTSize"), 256);
|
||||||
if (newWindowSize != windowSize) {
|
|
||||||
destroy = true;
|
|
||||||
windowSize = newWindowSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
|
#ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
|
||||||
const int newZeroPaddingFactor = gPrefs->Read(wxT("/Spectrum/ZeroPaddingFactor"), 1);
|
zeroPaddingFactor = gPrefs->Read(wxT("/Spectrum/ZeroPaddingFactor"), 1);
|
||||||
if (newZeroPaddingFactor != zeroPaddingFactor) {
|
|
||||||
destroy = true;
|
|
||||||
zeroPaddingFactor = newZeroPaddingFactor;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int newWindowType;
|
gPrefs->Read(wxT("/Spectrum/WindowType"), &windowType, eWinFuncHanning);
|
||||||
gPrefs->Read(wxT("/Spectrum/WindowType"), &newWindowType, 3);
|
|
||||||
if (newWindowType != windowType) {
|
|
||||||
destroy = true;
|
|
||||||
windowType = newWindowType;
|
|
||||||
}
|
|
||||||
|
|
||||||
isGrayscale = (gPrefs->Read(wxT("/Spectrum/Grayscale"), 0L) != 0);
|
isGrayscale = (gPrefs->Read(wxT("/Spectrum/Grayscale"), 0L) != 0);
|
||||||
|
|
||||||
@ -155,8 +192,64 @@ void SpectrogramSettings::UpdatePrefs()
|
|||||||
findNotesQuantize = (gPrefs->Read(wxT("/Spectrum/FindNotesQuantize"), 0L) != 0);
|
findNotesQuantize = (gPrefs->Read(wxT("/Spectrum/FindNotesQuantize"), 0L) != 0);
|
||||||
#endif //EXPERIMENTAL_FIND_NOTES
|
#endif //EXPERIMENTAL_FIND_NOTES
|
||||||
|
|
||||||
if (destroy)
|
// Enforce legal values
|
||||||
DestroyWindows();
|
Validate(true);
|
||||||
|
|
||||||
|
// These preferences are not written anywhere in the program as of now,
|
||||||
|
// but I keep this legacy here. Who knows, someone might edit prefs files
|
||||||
|
// directly. PRL
|
||||||
|
logMinFreq = gPrefs->Read(wxT("/SpectrumLog/MinFreq"), -1);
|
||||||
|
if (logMinFreq < 0)
|
||||||
|
logMinFreq = minFreq;
|
||||||
|
if (logMinFreq < 1)
|
||||||
|
logMinFreq = 1;
|
||||||
|
logMaxFreq = gPrefs->Read(wxT("/SpectrumLog/MaxFreq"), -1);
|
||||||
|
if (logMaxFreq < 0)
|
||||||
|
logMaxFreq = maxFreq;
|
||||||
|
logMaxFreq =
|
||||||
|
std::max(logMinFreq + 1, logMaxFreq);
|
||||||
|
|
||||||
|
InvalidateCaches();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpectrogramSettings::SavePrefs()
|
||||||
|
{
|
||||||
|
gPrefs->Write(wxT("/Spectrum/MinFreq"), minFreq);
|
||||||
|
gPrefs->Write(wxT("/Spectrum/MaxFreq"), maxFreq);
|
||||||
|
|
||||||
|
// Nothing wrote these. They only varied from the linear scale bounds in-session. -- PRL
|
||||||
|
// gPrefs->Write(wxT("/SpectrumLog/MaxFreq"), logMinFreq);
|
||||||
|
// gPrefs->Write(wxT("/SpectrumLog/MinFreq"), logMaxFreq);
|
||||||
|
|
||||||
|
gPrefs->Write(wxT("/Spectrum/Range"), range);
|
||||||
|
gPrefs->Write(wxT("/Spectrum/Gain"), gain);
|
||||||
|
gPrefs->Write(wxT("/Spectrum/FrequencyGain"), frequencyGain);
|
||||||
|
|
||||||
|
gPrefs->Write(wxT("/Spectrum/FFTSize"), windowSize);
|
||||||
|
|
||||||
|
#ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
|
||||||
|
gPrefs->Write(wxT("/Spectrum/ZeroPaddingFactor"), zeroPaddingFactor);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
gPrefs->Write(wxT("/Spectrum/WindowType"), windowType);
|
||||||
|
|
||||||
|
gPrefs->Write(wxT("/Spectrum/Grayscale"), isGrayscale);
|
||||||
|
|
||||||
|
#ifdef EXPERIMENTAL_FFT_Y_GRID
|
||||||
|
gPrefs->Write(wxT("/Spectrum/FFTYGrid"), fftYGrid);
|
||||||
|
#endif //EXPERIMENTAL_FFT_Y_GRID
|
||||||
|
|
||||||
|
#ifdef EXPERIMENTAL_FIND_NOTES
|
||||||
|
gPrefs->Write(wxT("/Spectrum/FFTFindNotes"), fftFindNotes);
|
||||||
|
gPrefs->Write(wxT("/Spectrum/FindNotesMinA"), findNotesMinA);
|
||||||
|
gPrefs->Write(wxT("/Spectrum/FindNotesN"), numberOfMaxima);
|
||||||
|
gPrefs->Write(wxT("/Spectrum/FindNotesQuantize"), findNotesQuantize);
|
||||||
|
#endif //EXPERIMENTAL_FIND_NOTES
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpectrogramSettings::InvalidateCaches()
|
||||||
|
{
|
||||||
|
DestroyWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
SpectrogramSettings::~SpectrogramSettings()
|
SpectrogramSettings::~SpectrogramSettings()
|
||||||
@ -257,6 +350,38 @@ void SpectrogramSettings::CacheWindows() const
|
|||||||
#endif // EXPERIMENTAL_USE_REALFFTF
|
#endif // EXPERIMENTAL_USE_REALFFTF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SpectrogramSettings::ConvertToEnumeratedWindowSizes()
|
||||||
|
{
|
||||||
|
unsigned size;
|
||||||
|
int logarithm;
|
||||||
|
|
||||||
|
logarithm = -LogMinWindowSize;
|
||||||
|
size = unsigned(windowSize);
|
||||||
|
while (size > 1)
|
||||||
|
size >>= 1, ++logarithm;
|
||||||
|
windowSize = std::max(0, std::min(NumWindowSizes - 1, logarithm));
|
||||||
|
|
||||||
|
#ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
|
||||||
|
// Choices for zero padding begin at 1
|
||||||
|
logarithm = 0;
|
||||||
|
size = unsigned(zeroPaddingFactor);
|
||||||
|
while (zeroPaddingFactor > 1)
|
||||||
|
zeroPaddingFactor >>= 1, ++logarithm;
|
||||||
|
zeroPaddingFactor = std::max(0,
|
||||||
|
std::min(LogMaxWindowSize - (windowSize + LogMinWindowSize),
|
||||||
|
logarithm
|
||||||
|
));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpectrogramSettings::ConvertToActualWindowSizes()
|
||||||
|
{
|
||||||
|
windowSize = 1 << (windowSize + LogMinWindowSize);
|
||||||
|
#ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
|
||||||
|
zeroPaddingFactor = 1 << zeroPaddingFactor;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
int SpectrogramSettings::GetMinFreq(double rate) const
|
int SpectrogramSettings::GetMinFreq(double rate) const
|
||||||
{
|
{
|
||||||
const int top = lrint(rate / 2.);
|
const int top = lrint(rate / 2.);
|
||||||
|
@ -14,19 +14,39 @@ Paul Licameli
|
|||||||
#include "../Experimental.h"
|
#include "../Experimental.h"
|
||||||
|
|
||||||
struct FFTParam;
|
struct FFTParam;
|
||||||
|
class SpectrumPrefs;
|
||||||
|
|
||||||
class SpectrogramSettings
|
class SpectrogramSettings
|
||||||
{
|
{
|
||||||
|
friend class SpectrumPrefs;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
enum {
|
||||||
|
LogMinWindowSize = 3,
|
||||||
|
LogMaxWindowSize = 15,
|
||||||
|
|
||||||
|
NumWindowSizes = LogMaxWindowSize - LogMinWindowSize + 1,
|
||||||
|
};
|
||||||
|
|
||||||
static SpectrogramSettings &defaults();
|
static SpectrogramSettings &defaults();
|
||||||
SpectrogramSettings();
|
SpectrogramSettings();
|
||||||
SpectrogramSettings(const SpectrogramSettings &other);
|
SpectrogramSettings(const SpectrogramSettings &other);
|
||||||
SpectrogramSettings& operator= (const SpectrogramSettings &other);
|
SpectrogramSettings& operator= (const SpectrogramSettings &other);
|
||||||
~SpectrogramSettings();
|
~SpectrogramSettings();
|
||||||
|
|
||||||
void UpdatePrefs();
|
bool IsDefault() const
|
||||||
|
{
|
||||||
|
return this == &defaults();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Validate(bool quiet);
|
||||||
|
void LoadPrefs();
|
||||||
|
void SavePrefs();
|
||||||
|
void InvalidateCaches();
|
||||||
void DestroyWindows();
|
void DestroyWindows();
|
||||||
void CacheWindows() const;
|
void CacheWindows() const;
|
||||||
|
void ConvertToEnumeratedWindowSizes();
|
||||||
|
void ConvertToActualWindowSizes();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int minFreq;
|
int minFreq;
|
||||||
@ -78,4 +98,5 @@ public:
|
|||||||
mutable float *window;
|
mutable float *window;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -20,18 +20,33 @@
|
|||||||
#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 "../Prefs.h"
|
#include "../FFT.h"
|
||||||
#include "../Project.h"
|
#include "../Project.h"
|
||||||
#include "../ShuttleGui.h"
|
#include "../ShuttleGui.h"
|
||||||
#include "../FFT.h"
|
#include "../WaveTrack.h"
|
||||||
|
#include "../TrackPanel.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
SpectrumPrefs::SpectrumPrefs(wxWindow * parent)
|
SpectrumPrefs::SpectrumPrefs(wxWindow * parent, WaveTrack *wt)
|
||||||
: PrefsPanel(parent, _("Spectrograms"))
|
: PrefsPanel(parent, _("Spectrograms"))
|
||||||
|
, mWt(wt)
|
||||||
|
, mPopulating(false)
|
||||||
{
|
{
|
||||||
int windowSize = gPrefs->Read(wxT("/Spectrum/FFTSize"), 256);
|
if (mWt) {
|
||||||
|
SpectrogramSettings &settings = wt->GetSpectrogramSettings();
|
||||||
|
mDefaulted = (&SpectrogramSettings::defaults() == &settings);
|
||||||
|
mTempSettings = settings;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mTempSettings = SpectrogramSettings::defaults();
|
||||||
|
mDefaulted = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int windowSize = mTempSettings.windowSize;
|
||||||
|
mTempSettings.ConvertToEnumeratedWindowSizes();
|
||||||
Populate(windowSize);
|
Populate(windowSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,13 +54,20 @@ SpectrumPrefs::~SpectrumPrefs()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
enum { maxWindowSize = 32768 };
|
|
||||||
|
|
||||||
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,
|
||||||
|
ID_APPLY,
|
||||||
};
|
};
|
||||||
|
|
||||||
void SpectrumPrefs::Populate(int windowSize)
|
void SpectrumPrefs::Populate(int windowSize)
|
||||||
@ -63,26 +85,18 @@ void SpectrumPrefs::Populate(int windowSize)
|
|||||||
mSizeChoices.Add(wxT("8192"));
|
mSizeChoices.Add(wxT("8192"));
|
||||||
mSizeChoices.Add(wxT("16384"));
|
mSizeChoices.Add(wxT("16384"));
|
||||||
mSizeChoices.Add(_("32768 - most narrowband"));
|
mSizeChoices.Add(_("32768 - most narrowband"));
|
||||||
|
wxASSERT(mSizeChoices.size() == SpectrogramSettings::NumWindowSizes);
|
||||||
int lastCode = 0;
|
|
||||||
for (size_t i = 0; i < mSizeChoices.GetCount(); i++) {
|
|
||||||
mSizeCodes.Add(lastCode = 1 << (i + 3));
|
|
||||||
}
|
|
||||||
wxASSERT(lastCode == maxWindowSize);
|
|
||||||
|
|
||||||
PopulatePaddingChoices(windowSize);
|
PopulatePaddingChoices(windowSize);
|
||||||
|
|
||||||
for (int i = 0; i < NumWindowFuncs(); i++) {
|
for (int i = 0; i < NumWindowFuncs(); i++) {
|
||||||
mTypeChoices.Add(WindowFuncName(i));
|
mTypeChoices.Add(WindowFuncName(i));
|
||||||
mTypeCodes.Add(i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//------------------------- Main section --------------------
|
//------------------------- Main section --------------------
|
||||||
// Now construct the GUI itself.
|
// Now construct the GUI itself.
|
||||||
// Use 'eIsCreatingFromPrefs' so that the GUI is
|
ShuttleGui S(this, eIsCreating);
|
||||||
// initialised with values from gPrefs.
|
|
||||||
ShuttleGui S(this, eIsCreatingFromPrefs);
|
|
||||||
PopulateOrExchange(S);
|
PopulateOrExchange(S);
|
||||||
// ----------------------- End of main section --------------
|
// ----------------------- End of main section --------------
|
||||||
}
|
}
|
||||||
@ -107,14 +121,12 @@ void SpectrumPrefs::PopulatePaddingChoices(int windowSize)
|
|||||||
pPaddingSizeControl->Clear();
|
pPaddingSizeControl->Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
mZeroPaddingCodes.Clear();
|
|
||||||
|
|
||||||
int padding = 1;
|
int padding = 1;
|
||||||
int numChoices = 0;
|
int numChoices = 0;
|
||||||
|
const int maxWindowSize = 1 << (SpectrogramSettings::LogMaxWindowSize);
|
||||||
while (windowSize <= maxWindowSize) {
|
while (windowSize <= maxWindowSize) {
|
||||||
const wxString numeral = wxString::Format(wxT("%d"), padding);
|
const wxString numeral = wxString::Format(wxT("%d"), padding);
|
||||||
mZeroPaddingChoices.Add(numeral);
|
mZeroPaddingChoices.Add(numeral);
|
||||||
mZeroPaddingCodes.Add(padding);
|
|
||||||
if (pPaddingSizeControl)
|
if (pPaddingSizeControl)
|
||||||
pPaddingSizeControl->Append(numeral);
|
pPaddingSizeControl->Append(numeral);
|
||||||
windowSize <<= 1;
|
windowSize <<= 1;
|
||||||
@ -131,174 +143,156 @@ 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(_("FFT Window"));
|
// S.StartStatic(_("Track Settings"));
|
||||||
{
|
{
|
||||||
S.StartMultiColumn(2);
|
mDefaultsCheckbox = 0;
|
||||||
|
if (mWt) {
|
||||||
|
mDefaultsCheckbox = S.Id(ID_DEFAULTS).TieCheckBox(_("Defaults"), mDefaulted);
|
||||||
|
}
|
||||||
|
S.StartStatic(_("FFT Window"));
|
||||||
{
|
{
|
||||||
S.Id(ID_WINDOW_SIZE).TieChoice(_("Window &size:"),
|
S.StartMultiColumn(2);
|
||||||
wxT("/Spectrum/FFTSize"),
|
{
|
||||||
256,
|
S.Id(ID_WINDOW_SIZE).TieChoice(_("Window &size:"),
|
||||||
mSizeChoices,
|
mTempSettings.windowSize,
|
||||||
mSizeCodes);
|
&mSizeChoices);
|
||||||
S.SetSizeHints(mSizeChoices);
|
S.SetSizeHints(mSizeChoices);
|
||||||
|
|
||||||
S.TieChoice(_("Window &type:"),
|
S.Id(ID_WINDOW_TYPE).TieChoice(_("Window &type:"),
|
||||||
wxT("/Spectrum/WindowType"),
|
mTempSettings.windowType,
|
||||||
3,
|
&mTypeChoices);
|
||||||
mTypeChoices,
|
S.SetSizeHints(mTypeChoices);
|
||||||
mTypeCodes);
|
|
||||||
S.SetSizeHints(mTypeChoices);
|
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
|
#ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
|
||||||
S.Id(ID_PADDING_SIZE).TieChoice(_("&Zero padding factor") + wxString(wxT(":")),
|
S.Id(ID_PADDING_SIZE).TieChoice(_("&Zero padding factor") + wxString(wxT(":")),
|
||||||
wxT("/Spectrum/ZeroPaddingFactor"),
|
mTempSettings.zeroPaddingFactor,
|
||||||
mZeroPaddingChoice,
|
&mZeroPaddingChoices);
|
||||||
mZeroPaddingChoices,
|
S.SetSizeHints(mZeroPaddingChoices);
|
||||||
mZeroPaddingCodes);
|
|
||||||
S.SetSizeHints(mZeroPaddingChoices);
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
S.EndMultiColumn();
|
||||||
}
|
}
|
||||||
S.EndMultiColumn();
|
S.EndStatic();
|
||||||
}
|
|
||||||
S.EndStatic();
|
|
||||||
|
|
||||||
S.StartStatic(_("Display"));
|
S.StartStatic(_("Display"));
|
||||||
{
|
|
||||||
S.StartTwoColumn();
|
|
||||||
{
|
{
|
||||||
mMinFreq =
|
S.StartTwoColumn();
|
||||||
S.TieNumericTextBox(_("Mi&nimum Frequency (Hz):"),
|
{
|
||||||
wxT("/Spectrum/MinFreq"),
|
mMinFreq =
|
||||||
0,
|
S.Id(ID_MINIMUM).TieNumericTextBox(_("Mi&nimum Frequency (Hz):"),
|
||||||
12);
|
mTempSettings.minFreq,
|
||||||
|
12);
|
||||||
|
|
||||||
mMaxFreq =
|
mMaxFreq =
|
||||||
S.TieNumericTextBox(_("Ma&ximum Frequency (Hz):"),
|
S.Id(ID_MAXIMUM).TieNumericTextBox(_("Ma&ximum Frequency (Hz):"),
|
||||||
wxT("/Spectrum/MaxFreq"),
|
mTempSettings.maxFreq,
|
||||||
8000,
|
12);
|
||||||
12);
|
|
||||||
|
|
||||||
mGain =
|
mGain =
|
||||||
S.TieNumericTextBox(_("&Gain (dB):"),
|
S.Id(ID_GAIN).TieNumericTextBox(_("&Gain (dB):"),
|
||||||
wxT("/Spectrum/Gain"),
|
mTempSettings.gain,
|
||||||
20,
|
8);
|
||||||
8);
|
|
||||||
|
|
||||||
mRange =
|
mRange =
|
||||||
S.TieNumericTextBox(_("&Range (dB):"),
|
S.Id(ID_RANGE).TieNumericTextBox(_("&Range (dB):"),
|
||||||
wxT("/Spectrum/Range"),
|
mTempSettings.range,
|
||||||
80,
|
8);
|
||||||
8);
|
|
||||||
|
|
||||||
mFrequencyGain =
|
mFrequencyGain =
|
||||||
S.TieNumericTextBox(_("Frequency g&ain (dB/dec):"),
|
S.Id(ID_FREQUENCY_GAIN).TieNumericTextBox(_("Frequency g&ain (dB/dec):"),
|
||||||
wxT("/Spectrum/FrequencyGain"),
|
mTempSettings.frequencyGain,
|
||||||
0,
|
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"),
|
||||||
wxT("/Spectrum/Grayscale"),
|
mTempSettings.isGrayscale);
|
||||||
false);
|
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_FFT_Y_GRID
|
#ifdef EXPERIMENTAL_FFT_Y_GRID
|
||||||
S.TieCheckBox(_("Show a grid along the &Y-axis"),
|
S.TieCheckBox(_("Show a grid along the &Y-axis"),
|
||||||
wxT("/Spectrum/FFTYGrid"),
|
mTempSettings.fftYGrid);
|
||||||
false);
|
|
||||||
#endif //EXPERIMENTAL_FFT_Y_GRID
|
#endif //EXPERIMENTAL_FFT_Y_GRID
|
||||||
}
|
}
|
||||||
S.EndStatic();
|
S.EndStatic();
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_FIND_NOTES
|
#ifdef EXPERIMENTAL_FIND_NOTES
|
||||||
/* i18n-hint: FFT stands for Fast Fourier Transform and probably shouldn't be translated*/
|
/* i18n-hint: FFT stands for Fast Fourier Transform and probably shouldn't be translated*/
|
||||||
S.StartStatic(_("FFT Find Notes"));
|
S.StartStatic(_("FFT Find Notes"));
|
||||||
{
|
|
||||||
S.StartTwoColumn();
|
|
||||||
{
|
{
|
||||||
mFindNotesMinA =
|
S.StartTwoColumn();
|
||||||
S.TieNumericTextBox(_("Minimum Amplitude (dB):"),
|
{
|
||||||
wxT("/Spectrum/FindNotesMinA"),
|
mFindNotesMinA =
|
||||||
-30L,
|
S.TieNumericTextBox(_("Minimum Amplitude (dB):"),
|
||||||
8);
|
mTempSettings.fftFindNotes,
|
||||||
|
8);
|
||||||
|
|
||||||
mFindNotesN =
|
mFindNotesN =
|
||||||
S.TieNumericTextBox(_("Max. Number of Notes (1..128):"),
|
S.TieNumericTextBox(_("Max. Number of Notes (1..128):"),
|
||||||
wxT("/Spectrum/FindNotesN"),
|
mTempSettings.findNotesMinA,
|
||||||
5L,
|
8);
|
||||||
8);
|
}
|
||||||
|
S.EndTwoColumn();
|
||||||
|
|
||||||
|
S.TieCheckBox(_("&Find Notes"),
|
||||||
|
mTempSettings.numberOfMaxima);
|
||||||
|
|
||||||
|
S.TieCheckBox(_("&Quantize Notes"),
|
||||||
|
mTempSettings.findNotesQuantize);
|
||||||
}
|
}
|
||||||
S.EndTwoColumn();
|
S.EndStatic();
|
||||||
|
|
||||||
S.TieCheckBox(_("&Find Notes"),
|
|
||||||
wxT("/Spectrum/FFTFindNotes"),
|
|
||||||
false);
|
|
||||||
|
|
||||||
S.TieCheckBox(_("&Quantize Notes"),
|
|
||||||
wxT("/Spectrum/FindNotesQuantize"),
|
|
||||||
false);
|
|
||||||
}
|
|
||||||
S.EndStatic();
|
|
||||||
#endif //EXPERIMENTAL_FIND_NOTES
|
#endif //EXPERIMENTAL_FIND_NOTES
|
||||||
|
}
|
||||||
|
// S.EndStatic();
|
||||||
|
|
||||||
|
S.StartMultiColumn(2, wxALIGN_RIGHT);
|
||||||
|
{
|
||||||
|
S.Id(ID_APPLY).AddButton(_("Appl&y"));
|
||||||
|
}
|
||||||
|
S.EndMultiColumn();
|
||||||
|
|
||||||
|
mPopulating = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpectrumPrefs::Validate()
|
bool SpectrumPrefs::Validate()
|
||||||
{
|
{
|
||||||
|
// Do checking for whole numbers
|
||||||
|
|
||||||
|
// ToDo: use wxIntegerValidator<unsigned> when available
|
||||||
|
|
||||||
long maxFreq;
|
long maxFreq;
|
||||||
if (!mMaxFreq->GetValue().ToLong(&maxFreq)) {
|
if (!mMaxFreq->GetValue().ToLong(&maxFreq)) {
|
||||||
wxMessageBox(_("The maximum frequency must be an integer"));
|
wxMessageBox(_("The maximum frequency must be an integer"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (maxFreq < 100) {
|
|
||||||
wxMessageBox(_("Maximum frequency must be 100 Hz or above"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
long minFreq;
|
long minFreq;
|
||||||
if (!mMinFreq->GetValue().ToLong(&minFreq)) {
|
if (!mMinFreq->GetValue().ToLong(&minFreq)) {
|
||||||
wxMessageBox(_("The minimum frequency must be an integer"));
|
wxMessageBox(_("The minimum frequency must be an integer"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (minFreq < 0) {
|
|
||||||
wxMessageBox(_("Minimum frequency must be at least 0 Hz"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (maxFreq < minFreq) {
|
|
||||||
wxMessageBox(_("Minimum frequency must be less than maximum frequency"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
long gain;
|
long gain;
|
||||||
if (!mGain->GetValue().ToLong(&gain)) {
|
if (!mGain->GetValue().ToLong(&gain)) {
|
||||||
wxMessageBox(_("The gain must be an integer"));
|
wxMessageBox(_("The gain must be an integer"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
long range;
|
long range;
|
||||||
if (!mRange->GetValue().ToLong(&range)) {
|
if (!mRange->GetValue().ToLong(&range)) {
|
||||||
wxMessageBox(_("The range must be a positive integer"));
|
wxMessageBox(_("The range must be a positive integer"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (range <= 0) {
|
|
||||||
wxMessageBox(_("The range must be at least 1 dB"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
long frequencygain;
|
long frequencygain;
|
||||||
if (!mFrequencyGain->GetValue().ToLong(&frequencygain)) {
|
if (!mFrequencyGain->GetValue().ToLong(&frequencygain)) {
|
||||||
wxMessageBox(_("The frequency gain must be an integer"));
|
wxMessageBox(_("The frequency gain must be an integer"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (frequencygain < 0) {
|
|
||||||
wxMessageBox(_("The frequency gain cannot be negative"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (frequencygain > 60) {
|
|
||||||
wxMessageBox(_("The frequency gain must be no more than 60 dB/dec"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#ifdef EXPERIMENTAL_FIND_NOTES
|
#ifdef EXPERIMENTAL_FIND_NOTES
|
||||||
long findNotesMinA;
|
long findNotesMinA;
|
||||||
if (!mFindNotesMinA->GetValue().ToLong(&findNotesMinA)) {
|
if (!mFindNotesMinA->GetValue().ToLong(&findNotesMinA)) {
|
||||||
@ -317,32 +311,132 @@ bool SpectrumPrefs::Validate()
|
|||||||
}
|
}
|
||||||
#endif //EXPERIMENTAL_FIND_NOTES
|
#endif //EXPERIMENTAL_FIND_NOTES
|
||||||
|
|
||||||
return true;
|
ShuttleGui S(this, eIsGettingFromDialog);
|
||||||
|
PopulateOrExchange(S);
|
||||||
|
|
||||||
|
// Delegate range checking to SpectrogramSettings class
|
||||||
|
mTempSettings.ConvertToActualWindowSizes();
|
||||||
|
const bool result = mTempSettings.Validate(false);
|
||||||
|
mTempSettings.ConvertToEnumeratedWindowSizes();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpectrumPrefs::Apply()
|
bool SpectrumPrefs::Apply()
|
||||||
{
|
{
|
||||||
ShuttleGui S(this, eIsSavingToPrefs);
|
const bool isOpenPage = this->IsShown();
|
||||||
|
|
||||||
|
WaveTrack *const partner =
|
||||||
|
mWt ? static_cast<WaveTrack*>(mWt->GetLink()) : 0;
|
||||||
|
|
||||||
|
ShuttleGui S(this, eIsGettingFromDialog);
|
||||||
PopulateOrExchange(S);
|
PopulateOrExchange(S);
|
||||||
|
|
||||||
SpectrogramSettings::defaults().UpdatePrefs();
|
mTempSettings.ConvertToActualWindowSizes();
|
||||||
|
if (mWt) {
|
||||||
|
if (mDefaulted) {
|
||||||
|
mWt->SetSpectrogramSettings(NULL);
|
||||||
|
if (partner)
|
||||||
|
partner->SetSpectrogramSettings(NULL);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SpectrogramSettings *pSettings =
|
||||||
|
&mWt->GetIndependentSpectrogramSettings();
|
||||||
|
*pSettings = mTempSettings;
|
||||||
|
if (partner) {
|
||||||
|
pSettings = &partner->GetIndependentSpectrogramSettings();
|
||||||
|
*pSettings = mTempSettings;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mWt || mDefaulted) {
|
||||||
|
SpectrogramSettings *const pSettings = &SpectrogramSettings::defaults();
|
||||||
|
*pSettings = mTempSettings;
|
||||||
|
pSettings->SavePrefs();
|
||||||
|
}
|
||||||
|
mTempSettings.ConvertToEnumeratedWindowSizes();
|
||||||
|
|
||||||
|
if (mWt && isOpenPage) {
|
||||||
|
// Future: open page will determine the track view type
|
||||||
|
/*
|
||||||
|
mWt->SetDisplay(WaveTrack::Spectrum);
|
||||||
|
if (partner)
|
||||||
|
partner->SetDisplay(WaveTrack::Spectrum);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
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 << (pWindowSizeControl->GetSelection() + 3);
|
int windowSize = 1 <<
|
||||||
|
(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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpectrumPrefs::OnApply(wxCommandEvent &)
|
||||||
|
{
|
||||||
|
if (Validate()) {
|
||||||
|
Apply();
|
||||||
|
::GetActiveProject()->GetTrackPanel()->Refresh(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
EVT_BUTTON(ID_APPLY, SpectrumPrefs::OnApply)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
SpectrumPrefsFactory::SpectrumPrefsFactory(WaveTrack *wt)
|
||||||
|
: mWt(wt)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
PrefsPanel *SpectrumPrefsFactory::Create(wxWindow *parent)
|
PrefsPanel *SpectrumPrefsFactory::Create(wxWindow *parent)
|
||||||
{
|
{
|
||||||
return new SpectrumPrefs(parent);
|
return new SpectrumPrefs(parent, mWt);
|
||||||
}
|
}
|
||||||
|
@ -30,14 +30,18 @@
|
|||||||
#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;
|
||||||
|
class SpectrogramSettings;
|
||||||
|
class WaveTrack;
|
||||||
|
|
||||||
class SpectrumPrefs:public PrefsPanel
|
class SpectrumPrefs:public PrefsPanel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SpectrumPrefs(wxWindow * parent);
|
SpectrumPrefs(wxWindow * parent, WaveTrack *wt);
|
||||||
virtual ~SpectrumPrefs();
|
virtual ~SpectrumPrefs();
|
||||||
virtual bool Apply();
|
virtual bool Apply();
|
||||||
virtual bool Validate();
|
virtual bool Validate();
|
||||||
@ -47,9 +51,15 @@ 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&);
|
||||||
|
void OnApply(wxCommandEvent &);
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
|
||||||
|
WaveTrack *const mWt;
|
||||||
|
bool mDefaulted;
|
||||||
|
|
||||||
wxTextCtrl *mMinFreq;
|
wxTextCtrl *mMinFreq;
|
||||||
wxTextCtrl *mMaxFreq;
|
wxTextCtrl *mMaxFreq;
|
||||||
wxTextCtrl *mGain;
|
wxTextCtrl *mGain;
|
||||||
@ -57,28 +67,35 @@ class SpectrumPrefs:public PrefsPanel
|
|||||||
wxTextCtrl *mFrequencyGain;
|
wxTextCtrl *mFrequencyGain;
|
||||||
|
|
||||||
wxArrayString mSizeChoices;
|
wxArrayString mSizeChoices;
|
||||||
wxArrayInt mSizeCodes;
|
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
|
#ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
|
||||||
int mZeroPaddingChoice;
|
int mZeroPaddingChoice;
|
||||||
wxArrayString mZeroPaddingChoices;
|
wxArrayString mZeroPaddingChoices;
|
||||||
wxArrayInt mZeroPaddingCodes;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxArrayString mTypeChoices;
|
wxArrayString mTypeChoices;
|
||||||
wxArrayInt mTypeCodes;
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_FIND_NOTES
|
#ifdef EXPERIMENTAL_FIND_NOTES
|
||||||
wxTextCtrl *mFindNotesMinA;
|
wxTextCtrl *mFindNotesMinA;
|
||||||
wxTextCtrl *mFindNotesN;
|
wxTextCtrl *mFindNotesN;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
wxCheckBox *mDefaultsCheckbox;
|
||||||
|
|
||||||
|
SpectrogramSettings mTempSettings;
|
||||||
|
|
||||||
|
bool mPopulating;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SpectrumPrefsFactory : public PrefsPanelFactory
|
class SpectrumPrefsFactory : public PrefsPanelFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
explicit SpectrumPrefsFactory(WaveTrack *wt = 0);
|
||||||
virtual PrefsPanel *Create(wxWindow *parent);
|
virtual PrefsPanel *Create(wxWindow *parent);
|
||||||
|
|
||||||
|
private:
|
||||||
|
WaveTrack *const mWt;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user