Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
SpectrumPrefs Class Referencefinal

A PrefsPanel for spectrum settings. More...

#include <SpectrumPrefs.h>

Inheritance diagram for SpectrumPrefs:
[legend]
Collaboration diagram for SpectrumPrefs:
[legend]

Public Member Functions

 SpectrumPrefs (wxWindow *parent, wxWindowID winid, AudacityProject *pProject, WaveTrack *wt)
 
virtual ~SpectrumPrefs ()
 
ComponentInterfaceSymbol GetSymbol () const override
 
TranslatableString GetDescription () const override
 
void Preview () override
 
bool Commit () override
 
void PopulateOrExchange (ShuttleGui &S) override
 
void Rollback ()
 
bool ShowsPreviewButton () override
 
bool Validate () override
 
ManualPageID HelpPageName () override
 If not empty string, the Help button is added below the panel. More...
 
- Public Member Functions inherited from PrefsPanel
 PrefsPanel (wxWindow *parent, wxWindowID winid, const TranslatableString &title)
 
virtual ~PrefsPanel ()
 
virtual void Preview ()
 
virtual bool Commit ()=0
 
virtual PluginPath GetPath () const override
 
virtual VendorSymbol GetVendor () const override
 
virtual wxString GetVersion () const override
 
virtual bool ShowsPreviewButton ()
 
virtual void PopulateOrExchange (ShuttleGui &WXUNUSED(S))
 
virtual ManualPageID HelpPageName ()
 If not empty string, the Help button is added below the panel. More...
 
virtual void Cancel ()
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
void SetLabel (const TranslatableString &label)
 
void SetName (const TranslatableString &name)
 
void SetToolTip (const TranslatableString &toolTip)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Private Member Functions

void Populate (size_t windowSize)
 
void PopulatePaddingChoices (size_t windowSize)
 
void OnControl (wxCommandEvent &event)
 
void OnWindowSize (wxCommandEvent &event)
 
void OnDefaults (wxCommandEvent &)
 
void OnAlgorithm (wxCommandEvent &)
 
void EnableDisableSTFTOnlyControls ()
 

Private Attributes

AudacityProjectmProject {}
 
WaveTrack *const mWt
 
bool mDefaulted
 
bool mOrigDefaulted
 
wxTextCtrl * mMinFreq
 
wxTextCtrl * mMaxFreq
 
wxTextCtrl * mGain
 
wxTextCtrl * mRange
 
wxTextCtrl * mFrequencyGain
 
int mZeroPaddingChoice
 
wxChoice * mZeroPaddingChoiceCtrl
 
TranslatableStrings mZeroPaddingChoices
 
TranslatableStrings mTypeChoices
 
wxChoice * mAlgorithmChoice
 
wxCheckBox * mDefaultsCheckbox
 
SpectrogramSettings mTempSettings
 
SpectrogramSettings mOrigSettings
 
std::vector< WaveChannelSubViewPlacementmOrigPlacements
 
float mOrigMin
 
float mOrigMax
 
bool mPopulating
 
bool mCommitted {}
 

Additional Inherited Members

- Public Types inherited from PrefsPanel
using Factories = std::vector< PrefsPanel::PrefsNode >
 
using Factory = std::function< PrefsPanel *(wxWindow *parent, wxWindowID winid, AudacityProject *) >
 
- Static Public Member Functions inherited from PrefsPanel
static FactoriesDefaultFactories ()
 

Detailed Description

A PrefsPanel for spectrum settings.

Definition at line 41 of file SpectrumPrefs.h.

Constructor & Destructor Documentation

◆ SpectrumPrefs()

SpectrumPrefs::SpectrumPrefs ( wxWindow *  parent,
wxWindowID  winid,
AudacityProject pProject,
WaveTrack wt 
)

Definition at line 37 of file SpectrumPrefs.cpp.

39: PrefsPanel(parent, winid, wt ? XO("Spectrogram Settings") : XO("Spectrograms"))
40, mProject{ pProject }
41, mWt(wt)
42, mPopulating(false)
43{
44 if (mWt) {
52 }
53 else {
55 mOrigDefaulted = mDefaulted = false;
56 }
57
58 const auto windowSize = mTempSettings.WindowSize();
60 Populate(windowSize);
61}
XO("Cut/Copy/Paste")
static Settings & settings()
Definition: TrackInfo.cpp:69
PrefsPanel(wxWindow *parent, wxWindowID winid, const TranslatableString &title)
Definition: PrefsPanel.h:94
void GetBounds(const WaveTrack &wt, float &min, float &max) const
static SpectrogramBounds & Get(WaveTrack &track)
Get either the global default settings, or the track's own if previously created.
static SpectrogramSettings & defaults()
static SpectrogramSettings & Get(const WaveTrack &track)
Mutative access to attachment even if the track argument is const.
AudacityProject * mProject
Definition: SpectrumPrefs.h:70
void Populate(size_t windowSize)
WaveTrack *const mWt
Definition: SpectrumPrefs.h:72
std::vector< WaveChannelSubViewPlacement > mOrigPlacements
SpectrogramSettings mOrigSettings
SpectrogramSettings mTempSettings
const WaveChannelSubViewPlacements & SavePlacements() const
static WaveChannelView & Get(WaveChannel &channel)

References SpectrogramSettings::ConvertToEnumeratedWindowSizes(), SpectrogramSettings::defaults(), SpectrogramSettings::Get(), WaveChannelView::Get(), SpectrogramBounds::Get(), SpectrogramBounds::GetBounds(), SpectrogramSettings::maxFreq, mDefaulted, SpectrogramSettings::minFreq, mOrigDefaulted, mOrigMax, mOrigMin, mOrigPlacements, mOrigSettings, mTempSettings, mWt, Populate(), WaveChannelView::SavePlacements(), settings(), and SpectrogramSettings::WindowSize().

Here is the call graph for this function:

◆ ~SpectrumPrefs()

SpectrumPrefs::~SpectrumPrefs ( )
virtual

Definition at line 63 of file SpectrumPrefs.cpp.

64{
65 if (!mCommitted)
66 Rollback();
67}

References mCommitted, and Rollback().

Here is the call graph for this function:

Member Function Documentation

◆ Commit()

bool SpectrumPrefs::Commit ( )
overridevirtual

Implements PrefsPanel.

Definition at line 481 of file SpectrumPrefs.cpp.

482{
483 if (!Validate())
484 return false;
485
486 mCommitted = true;
489 if (!mWt || mDefaulted) {
490 pSettings->SavePrefs();
491 }
492 pSettings->LoadPrefs(); // always; in case Globals changed
493
494 return true;
495}
Spectrogram settings, either for one track or as defaults.
bool Validate() override

References SpectrogramSettings::defaults(), SpectrogramSettings::Globals::Get(), SpectrogramSettings::LoadPrefs(), mCommitted, mDefaulted, mWt, SpectrogramSettings::Globals::SavePrefs(), SpectrogramSettings::SavePrefs(), and Validate().

Here is the call graph for this function:

◆ EnableDisableSTFTOnlyControls()

void SpectrumPrefs::EnableDisableSTFTOnlyControls ( )
private

Definition at line 546 of file SpectrumPrefs.cpp.

547{
548 // Enable or disable other controls that are applicable only to STFT.
549 const bool STFT =
551 mGain->Enable(STFT);
552 mRange->Enable(STFT);
553 mFrequencyGain->Enable(STFT);
554 mZeroPaddingChoiceCtrl->Enable(STFT);
555}
wxTextCtrl * mFrequencyGain
Definition: SpectrumPrefs.h:79
wxTextCtrl * mRange
Definition: SpectrumPrefs.h:78
wxTextCtrl * mGain
Definition: SpectrumPrefs.h:77
wxChoice * mZeroPaddingChoiceCtrl
Definition: SpectrumPrefs.h:85
wxChoice * mAlgorithmChoice
Definition: SpectrumPrefs.h:90

References SpectrogramSettings::algPitchEAC, mAlgorithmChoice, mFrequencyGain, mGain, mRange, and mZeroPaddingChoiceCtrl.

Referenced by OnAlgorithm(), and PopulateOrExchange().

Here is the caller graph for this function:

◆ GetDescription()

TranslatableString SpectrumPrefs::GetDescription ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 74 of file SpectrumPrefs.cpp.

75{
76 return XO("Preferences for Spectrum");
77}

References XO().

Here is the call graph for this function:

◆ GetSymbol()

ComponentInterfaceSymbol SpectrumPrefs::GetSymbol ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 69 of file SpectrumPrefs.cpp.

70{
72}
#define SPECTRUM_PREFS_PLUGIN_SYMBOL
Definition: SpectrumPrefs.h:39

References SPECTRUM_PREFS_PLUGIN_SYMBOL.

◆ HelpPageName()

ManualPageID SpectrumPrefs::HelpPageName ( )
overridevirtual

If not empty string, the Help button is added below the panel.

Default returns empty string.

Reimplemented from PrefsPanel.

Definition at line 79 of file SpectrumPrefs.cpp.

80{
81 // Currently (May2017) Spectrum Settings is the only preferences
82 // we ever display in a dialog on its own without others.
83 // We do so when it is configuring spectrums for a track.
84 // Because this happens, we want to visit a different help page.
85 // So we change the page name in the case of a page on its own.
86 return mWt
87 ? "Spectrogram_Settings"
88 : "Spectrograms_Preferences";
89}

References mWt.

◆ OnAlgorithm()

void SpectrumPrefs::OnAlgorithm ( wxCommandEvent &  evt)
private

Definition at line 540 of file SpectrumPrefs.cpp.

541{
543 OnControl(evt);
544}
void EnableDisableSTFTOnlyControls()
void OnControl(wxCommandEvent &event)

References EnableDisableSTFTOnlyControls(), and OnControl().

Here is the call graph for this function:

◆ OnControl()

void SpectrumPrefs::OnControl ( wxCommandEvent &  event)
private

Definition at line 502 of file SpectrumPrefs.cpp.

503{
504 // Common routine for most controls
505 // If any per-track setting is changed, break the association with defaults
506 // Skip this, and View Settings... will be able to change defaults instead
507 // when the checkbox is on, as in the original design.
508
510 mDefaulted = false;
511 mDefaultsCheckbox->SetValue(false);
512 }
513}
wxCheckBox * mDefaultsCheckbox
Definition: SpectrumPrefs.h:98

References mDefaulted, mDefaultsCheckbox, and mPopulating.

Referenced by OnAlgorithm(), and OnWindowSize().

Here is the caller graph for this function:

◆ OnDefaults()

void SpectrumPrefs::OnDefaults ( wxCommandEvent &  )
private

Definition at line 529 of file SpectrumPrefs.cpp.

530{
531 if (mDefaultsCheckbox->IsChecked()) {
534 mDefaulted = true;
537 }
538}
@ eIsSettingToDialog
Definition: ShuttleGui.h:39
#define S(N)
Definition: ToChars.cpp:64
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
void PopulateOrExchange(ShuttleGui &S) override

References SpectrogramSettings::ConvertToEnumeratedWindowSizes(), SpectrogramSettings::defaults(), eIsSettingToDialog, mDefaulted, mDefaultsCheckbox, mTempSettings, PopulateOrExchange(), and S.

Here is the call graph for this function:

◆ OnWindowSize()

void SpectrumPrefs::OnWindowSize ( wxCommandEvent &  event)
private

Definition at line 515 of file SpectrumPrefs.cpp.

516{
517 // Restrict choice of zero padding, so that product of window
518 // size and padding may not exceed the largest window size.
519 wxChoice *const pWindowSizeControl =
520 static_cast<wxChoice*>(wxWindow::FindWindowById(ID_WINDOW_SIZE, this));
521 size_t windowSize = 1 <<
522 (pWindowSizeControl->GetSelection() + SpectrogramSettings::LogMinWindowSize);
523 PopulatePaddingChoices(windowSize);
524
525 // Do the common part
526 OnControl(evt);
527}
@ ID_WINDOW_SIZE
void PopulatePaddingChoices(size_t windowSize)

References ID_WINDOW_SIZE, SpectrogramSettings::LogMinWindowSize, OnControl(), and PopulatePaddingChoices().

Here is the call graph for this function:

◆ Populate()

void SpectrumPrefs::Populate ( size_t  windowSize)
private

Definition at line 107 of file SpectrumPrefs.cpp.

108{
109 PopulatePaddingChoices(windowSize);
110
111 for (int i = 0; i < NumWindowFuncs(); i++) {
112 mTypeChoices.push_back( WindowFuncName(i) );
113 }
114
115 //------------------------- Main section --------------------
116 // Now construct the GUI itself.
119 // ----------------------- End of main section --------------
120}
int NumWindowFuncs()
Definition: FFT.cpp:327
const TranslatableString WindowFuncName(int whichFunction)
Definition: FFT.cpp:332
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:46
TranslatableStrings mTypeChoices
Definition: SpectrumPrefs.h:88

References eIsCreatingFromPrefs, mTypeChoices, NumWindowFuncs(), PopulateOrExchange(), PopulatePaddingChoices(), S, and WindowFuncName().

Referenced by SpectrumPrefs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PopulateOrExchange()

void SpectrumPrefs::PopulateOrExchange ( ShuttleGui S)
override

Definition at line 160 of file SpectrumPrefs.cpp.

161{
162 mPopulating = true;
163 S.SetBorder(2);
164 S.StartScroller(); {
165
166 // S.StartStatic(XO("Track Settings"));
167 // {
168
169
171 if (mWt) {
172 /* i18n-hint: use is a verb */
173 mDefaultsCheckbox = S.Id(ID_DEFAULTS).TieCheckBox(XXO("&Use Preferences"), mDefaulted);
174 }
175
176 S.StartMultiColumn(2,wxEXPAND);
177 {
178 S.SetStretchyCol( 0 );
179 S.SetStretchyCol( 1 );
180 S.StartStatic(XO("Scale"),1);
181 {
182 S.StartMultiColumn(2,wxEXPAND);
183 {
184 S.SetStretchyCol( 0 );
185 S.SetStretchyCol( 1 );
186 S.Id(ID_SCALE).TieChoice(XXO("S&cale:"),
189 mMinFreq =
190 S.Id(ID_MINIMUM).TieNumericTextBox(XXO("Mi&n Frequency (Hz):"),
192 12);
193 mMaxFreq =
194 S.Id(ID_MAXIMUM).TieNumericTextBox(XXO("Ma&x Frequency (Hz):"),
196 12);
197 }
198 S.EndMultiColumn();
199 }
200 S.EndStatic();
201
202 S.StartStatic(XO("Colors"),1);
203 {
204 S.StartMultiColumn(2,wxEXPAND);
205 {
206 S.SetStretchyCol( 0 );
207 S.SetStretchyCol( 1 );
208 mGain =
209 S.Id(ID_GAIN).TieNumericTextBox(XXO("&Gain (dB):"),
211 8);
212 mRange =
213 S.Id(ID_RANGE).TieNumericTextBox(XXO("&Range (dB):"),
215 8);
216
218 S.Id(ID_FREQUENCY_GAIN).TieNumericTextBox(XXO("High &boost (dB/dec):"),
220 8);
221
222 // i18n-hint Scheme refers to a color scheme for spectrogram colors
223 S.Id(ID_COLOR_SCHEME).TieChoice(XC("Sche&me:", "spectrum prefs"),
226 }
227 S.EndMultiColumn();
228 }
229 S.EndStatic();
230 }
231 S.EndMultiColumn();
232
233 S.StartStatic(XO("Algorithm"));
234 {
235 S.StartMultiColumn(2);
236 {
238 S.Id(ID_ALGORITHM).TieChoice(XXO("A&lgorithm:"),
241
242 S.Id(ID_WINDOW_SIZE).TieChoice(XXO("Window &size:"),
244 {
245 XO("8 - most wideband"),
246 XO("16"),
247 XO("32"),
248 XO("64"),
249 XO("128"),
250 XO("256"),
251 XO("512"),
252 XO("1024"),
253 XO("2048"),
254 XO("4096"),
255 XO("8192"),
256 XO("16384"),
257 XO("32768 - most narrowband"),
258 }
259 );
260
261 S.Id(ID_WINDOW_TYPE).TieChoice(XXO("Window &type:"),
264
266 S.Id(ID_PADDING_SIZE).TieChoice(XXO("&Zero padding factor:"),
269 }
270 S.EndMultiColumn();
271 }
272 S.EndStatic();
273
274#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
275 S.Id(ID_SPECTRAL_SELECTION).TieCheckBox(XXO("Ena&ble Spectral Selection"),
277#endif
278
279#ifdef EXPERIMENTAL_FFT_Y_GRID
280 S.TieCheckBox(XO("Show a grid along the &Y-axis"),
281 mTempSettings.fftYGrid);
282#endif //EXPERIMENTAL_FFT_Y_GRID
283
284#ifdef EXPERIMENTAL_FIND_NOTES
285 /* i18n-hint: FFT stands for Fast Fourier Transform and probably shouldn't be translated*/
286 S.StartStatic(XO("FFT Find Notes"));
287 {
288 S.StartTwoColumn();
289 {
290 mFindNotesMinA =
291 S.TieNumericTextBox(XXO("Minimum Amplitude (dB):"),
292 mTempSettings.findNotesMinA,
293 8);
294
295 mFindNotesN =
296 S.TieNumericTextBox(XXO("Max. Number of Notes (1..128):"),
297 mTempSettings.numberOfMaxima,
298 8);
299 }
300 S.EndTwoColumn();
301
302 S.TieCheckBox(XXO("&Find Notes"),
303 mTempSettings.fftFindNotes);
304
305 S.TieCheckBox(XXO("&Quantize Notes"),
306 mTempSettings.findNotesQuantize);
307 }
308 S.EndStatic();
309#endif //EXPERIMENTAL_FIND_NOTES
310 // S.EndStatic();
311
312#ifdef SPECTRAL_SELECTION_GLOBAL_SWITCH
313 S.StartStatic(XO("Global settings"));
314 {
315 S.TieCheckBox(XXO("Ena&ble spectral selection"),
316 SpectrogramSettings::Globals::Get().spectralSelection);
317 }
318 S.EndStatic();
319#endif
320
321 } S.EndScroller();
322
323 // Enabling and disabling belongs outside this function.
324 if( S.GetMode() != eIsGettingMetadata )
326
327 mPopulating = false;
328}
XXO("&Cut/Copy/Paste Toolbar")
#define XC(s, c)
Definition: Internat.h:37
TranslatableStrings Msgids(const EnumValueSymbol strings[], size_t nStrings)
Convenience function often useful when adding choice controls.
@ eIsGettingMetadata
Definition: ShuttleGui.h:40
@ ID_FREQUENCY_GAIN
@ ID_SCALE
@ ID_COLOR_SCHEME
@ ID_PADDING_SIZE
@ ID_WINDOW_TYPE
@ ID_DEFAULTS
@ ID_RANGE
@ ID_GAIN
@ ID_ALGORITHM
@ ID_MAXIMUM
@ ID_SPECTRAL_SELECTION
@ ID_MINIMUM
static const TranslatableStrings & GetAlgorithmNames()
static const EnumValueSymbols & GetScaleNames()
static const EnumValueSymbols & GetColorSchemeNames()
TranslatableStrings mZeroPaddingChoices
Definition: SpectrumPrefs.h:86
wxTextCtrl * mMaxFreq
Definition: SpectrumPrefs.h:76
wxTextCtrl * mMinFreq
Definition: SpectrumPrefs.h:75

References SpectrogramSettings::algorithm, SpectrogramSettings::colorScheme, eIsGettingMetadata, EnableDisableSTFTOnlyControls(), SpectrogramSettings::frequencyGain, SpectrogramSettings::gain, SpectrogramSettings::Globals::Get(), SpectrogramSettings::GetAlgorithmNames(), SpectrogramSettings::GetColorSchemeNames(), SpectrogramSettings::GetScaleNames(), ID_ALGORITHM, ID_COLOR_SCHEME, ID_DEFAULTS, ID_FREQUENCY_GAIN, ID_GAIN, ID_MAXIMUM, ID_MINIMUM, ID_PADDING_SIZE, ID_RANGE, ID_SCALE, ID_SPECTRAL_SELECTION, ID_WINDOW_SIZE, ID_WINDOW_TYPE, mAlgorithmChoice, SpectrogramSettings::maxFreq, mDefaulted, mDefaultsCheckbox, mFrequencyGain, mGain, SpectrogramSettings::minFreq, mMaxFreq, mMinFreq, mPopulating, mRange, Msgids(), mTempSettings, mTypeChoices, mWt, mZeroPaddingChoiceCtrl, mZeroPaddingChoices, SpectrogramSettings::range, S, SpectrogramSettings::scaleType, SpectrogramSettings::spectralSelection, SpectrogramSettings::windowSize, SpectrogramSettings::windowType, XC, XO(), XXO(), and SpectrogramSettings::zeroPaddingFactor.

Referenced by OnDefaults(), Populate(), Preview(), and Validate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PopulatePaddingChoices()

void SpectrumPrefs::PopulatePaddingChoices ( size_t  windowSize)
private

Definition at line 122 of file SpectrumPrefs.cpp.

123{
125
126 // The choice of window size restricts the choice of padding.
127 // So the padding menu might grow or shrink.
128
129 // If pPaddingSizeControl is NULL, we have not yet tied the choice control.
130 // If it is not NULL, we rebuild the control by hand.
131 // I don't yet know an easier way to do this with ShuttleGUI functions.
132 // PRL
133 wxChoice *const pPaddingSizeControl =
134 static_cast<wxChoice*>(wxWindow::FindWindowById(ID_PADDING_SIZE, this));
135
136 if (pPaddingSizeControl) {
137 mZeroPaddingChoice = pPaddingSizeControl->GetSelection();
138 pPaddingSizeControl->Clear();
139 }
140
141 unsigned padding = 1;
142 int numChoices = 0;
143 const size_t maxWindowSize = 1 << (SpectrogramSettings::LogMaxWindowSize);
144 while (windowSize <= maxWindowSize) {
145 const auto numeral = wxString::Format(wxT("%d"), padding);
146 mZeroPaddingChoices.push_back( Verbatim( numeral ) );
147 if (pPaddingSizeControl)
148 pPaddingSizeControl->Append(numeral);
149 windowSize <<= 1;
150 padding <<= 1;
151 ++numChoices;
152 }
153
155
156 if (pPaddingSizeControl)
157 pPaddingSizeControl->SetSelection(mZeroPaddingChoice);
158}
wxT("CloseDown"))
int min(int a, int b)
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
int mZeroPaddingChoice
Definition: SpectrumPrefs.h:84

References ID_PADDING_SIZE, SpectrogramSettings::LogMaxWindowSize, min(), mZeroPaddingChoice, mZeroPaddingChoices, Verbatim(), and wxT().

Referenced by OnWindowSize(), and Populate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Preview()

void SpectrumPrefs::Preview ( )
overridevirtual

Reimplemented from PrefsPanel.

Definition at line 428 of file SpectrumPrefs.cpp.

429{
430 if (!Validate())
431 return;
432
433 const bool isOpenPage = this->IsShown();
434
437
438
440
441 if (mWt) {
442 if (mDefaulted) {
444 // ... and so that the vertical scale also defaults:
445 SpectrogramBounds::Get(*mWt).SetBounds(-1, -1);
446 }
447 else {
452 }
453 }
454
455 if (!mWt || mDefaulted) {
457 *pSettings = mTempSettings;
458 }
460
461 // Bug 2278
462 // This code destroys any Multi-view we had.
463 // Commenting it out as it seems not to be needed.
464 /*
465 if (mWt && isOpenPage) {
466 for (auto channel : TrackList::Channels(mWt))
467 WaveChannelView::Get(*channel)
468 .SetDisplay(WaveChannelViewConstants::Spectrum);
469 }
470 */
471
472 if (isOpenPage) {
473 if ( mProject ) {
474 auto &tp = TrackPanel::Get( *mProject );
475 tp.UpdateVRulers();
476 tp.Refresh(false);
477 }
478 }
479}
@ eIsSavingToPrefs
Definition: ShuttleGui.h:47
void SetBounds(float min, float max)
static void Reset(WaveTrack &track)
Make track lose indpendent settings and use defaults.
static SpectrogramSettings & Own(WaveTrack &track)
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:233

References SpectrogramSettings::ConvertToActualWindowSizes(), SpectrogramSettings::ConvertToEnumeratedWindowSizes(), SpectrogramSettings::defaults(), eIsSavingToPrefs, TrackPanel::Get(), SpectrogramBounds::Get(), SpectrogramSettings::maxFreq, mDefaulted, SpectrogramSettings::minFreq, mProject, mTempSettings, mWt, SpectrogramSettings::Own(), PopulateOrExchange(), SpectrogramSettings::Reset(), S, SpectrogramBounds::SetBounds(), settings(), and Validate().

Here is the call graph for this function:

◆ Rollback()

void SpectrumPrefs::Rollback ( )

Definition at line 395 of file SpectrumPrefs.cpp.

396{
397 if (mWt) {
398 if (mOrigDefaulted) {
400 SpectrogramBounds::Get(*mWt).SetBounds(-1, -1);
401 }
402 else {
406 }
407 }
408
409 if (!mWt || mOrigDefaulted) {
411 *pSettings = mOrigSettings;
412 }
413
414 const bool isOpenPage = this->IsShown();
415 if (mWt && isOpenPage) {
417 }
418
419 if (isOpenPage) {
420 if ( mProject ) {
421 auto &tp = TrackPanel::Get ( *mProject );
422 tp.UpdateVRulers();
423 tp.Refresh(false);
424 }
425 }
426}
void RestorePlacements(const WaveChannelSubViewPlacements &placements)

References SpectrogramSettings::defaults(), TrackPanel::Get(), WaveChannelView::Get(), SpectrogramBounds::Get(), mOrigDefaulted, mOrigMax, mOrigMin, mOrigPlacements, mOrigSettings, mProject, mWt, SpectrogramSettings::Own(), SpectrogramSettings::Reset(), WaveChannelView::RestorePlacements(), SpectrogramBounds::SetBounds(), and settings().

Referenced by ~SpectrumPrefs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ShowsPreviewButton()

bool SpectrumPrefs::ShowsPreviewButton ( )
overridevirtual

Reimplemented from PrefsPanel.

Definition at line 497 of file SpectrumPrefs.cpp.

498{
499 return mProject != nullptr;
500}

References mProject.

◆ Validate()

bool SpectrumPrefs::Validate ( )
override

Definition at line 330 of file SpectrumPrefs.cpp.

331{
332 // Do checking for whole numbers
333
334 // ToDo: use wxIntegerValidator<unsigned> when available
335
336 long maxFreq;
337 if (!mMaxFreq->GetValue().ToLong(&maxFreq)) {
338 AudacityMessageBox( XO("The maximum frequency must be an integer") );
339 return false;
340 }
341
342 long minFreq;
343 if (!mMinFreq->GetValue().ToLong(&minFreq)) {
344 AudacityMessageBox( XO("The minimum frequency must be an integer") );
345 return false;
346 }
347
348 long gain;
349 if (!mGain->GetValue().ToLong(&gain)) {
350 AudacityMessageBox( XO("The gain must be an integer") );
351 return false;
352 }
353
354 long range;
355 if (!mRange->GetValue().ToLong(&range)) {
356 AudacityMessageBox( XO("The range must be a positive integer") );
357 return false;
358 }
359
360 long frequencygain;
361 if (!mFrequencyGain->GetValue().ToLong(&frequencygain)) {
362 AudacityMessageBox( XO("The frequency gain must be an integer") );
363 return false;
364 }
365
366#ifdef EXPERIMENTAL_FIND_NOTES
367 long findNotesMinA;
368 if (!mFindNotesMinA->GetValue().ToLong(&findNotesMinA)) {
369 AudacityMessageBox( XO("The minimum amplitude (dB) must be an integer") );
370 return false;
371 }
372
373 long findNotesN;
374 if (!mFindNotesN->GetValue().ToLong(&findNotesN)) {
375 AudacityMessageBox( XO("The maximum number of notes must be an integer") );
376 return false;
377 }
378 if (findNotesN < 1 || findNotesN > 128) {
380"The maximum number of notes must be in the range 1..128") );
381 return false;
382 }
383#endif //EXPERIMENTAL_FIND_NOTES
384
387
388 // Delegate range checking to SpectrogramSettings class
390 const bool result = mTempSettings.Validate(false);
392 return result;
393}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)

References AudacityMessageBox(), SpectrogramSettings::ConvertToActualWindowSizes(), SpectrogramSettings::ConvertToEnumeratedWindowSizes(), eIsSavingToPrefs, mFrequencyGain, mGain, mMaxFreq, mMinFreq, mRange, mTempSettings, PopulateOrExchange(), S, SpectrogramSettings::Validate(), and XO().

Referenced by Commit(), and Preview().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mAlgorithmChoice

wxChoice* SpectrumPrefs::mAlgorithmChoice
private

Definition at line 90 of file SpectrumPrefs.h.

Referenced by EnableDisableSTFTOnlyControls(), and PopulateOrExchange().

◆ mCommitted

bool SpectrumPrefs::mCommitted {}
private

Definition at line 106 of file SpectrumPrefs.h.

Referenced by Commit(), and ~SpectrumPrefs().

◆ mDefaulted

bool SpectrumPrefs::mDefaulted
private

◆ mDefaultsCheckbox

wxCheckBox* SpectrumPrefs::mDefaultsCheckbox
private

Definition at line 98 of file SpectrumPrefs.h.

Referenced by OnControl(), OnDefaults(), and PopulateOrExchange().

◆ mFrequencyGain

wxTextCtrl* SpectrumPrefs::mFrequencyGain
private

Definition at line 79 of file SpectrumPrefs.h.

Referenced by EnableDisableSTFTOnlyControls(), PopulateOrExchange(), and Validate().

◆ mGain

wxTextCtrl* SpectrumPrefs::mGain
private

Definition at line 77 of file SpectrumPrefs.h.

Referenced by EnableDisableSTFTOnlyControls(), PopulateOrExchange(), and Validate().

◆ mMaxFreq

wxTextCtrl* SpectrumPrefs::mMaxFreq
private

Definition at line 76 of file SpectrumPrefs.h.

Referenced by PopulateOrExchange(), and Validate().

◆ mMinFreq

wxTextCtrl* SpectrumPrefs::mMinFreq
private

Definition at line 75 of file SpectrumPrefs.h.

Referenced by PopulateOrExchange(), and Validate().

◆ mOrigDefaulted

bool SpectrumPrefs::mOrigDefaulted
private

Definition at line 73 of file SpectrumPrefs.h.

Referenced by Rollback(), and SpectrumPrefs().

◆ mOrigMax

float SpectrumPrefs::mOrigMax
private

Definition at line 103 of file SpectrumPrefs.h.

Referenced by Rollback(), and SpectrumPrefs().

◆ mOrigMin

float SpectrumPrefs::mOrigMin
private

Definition at line 103 of file SpectrumPrefs.h.

Referenced by Rollback(), and SpectrumPrefs().

◆ mOrigPlacements

std::vector<WaveChannelSubViewPlacement> SpectrumPrefs::mOrigPlacements
private

Definition at line 102 of file SpectrumPrefs.h.

Referenced by Rollback(), and SpectrumPrefs().

◆ mOrigSettings

SpectrogramSettings SpectrumPrefs::mOrigSettings
private

Definition at line 100 of file SpectrumPrefs.h.

Referenced by Rollback(), and SpectrumPrefs().

◆ mPopulating

bool SpectrumPrefs::mPopulating
private

Definition at line 105 of file SpectrumPrefs.h.

Referenced by OnControl(), and PopulateOrExchange().

◆ mProject

AudacityProject* SpectrumPrefs::mProject {}
private

Definition at line 70 of file SpectrumPrefs.h.

Referenced by Preview(), Rollback(), and ShowsPreviewButton().

◆ mRange

wxTextCtrl* SpectrumPrefs::mRange
private

Definition at line 78 of file SpectrumPrefs.h.

Referenced by EnableDisableSTFTOnlyControls(), PopulateOrExchange(), and Validate().

◆ mTempSettings

SpectrogramSettings SpectrumPrefs::mTempSettings
private

Definition at line 100 of file SpectrumPrefs.h.

Referenced by OnDefaults(), PopulateOrExchange(), Preview(), SpectrumPrefs(), and Validate().

◆ mTypeChoices

TranslatableStrings SpectrumPrefs::mTypeChoices
private

Definition at line 88 of file SpectrumPrefs.h.

Referenced by Populate(), and PopulateOrExchange().

◆ mWt

WaveTrack* const SpectrumPrefs::mWt
private

◆ mZeroPaddingChoice

int SpectrumPrefs::mZeroPaddingChoice
private

Definition at line 84 of file SpectrumPrefs.h.

Referenced by PopulatePaddingChoices().

◆ mZeroPaddingChoiceCtrl

wxChoice* SpectrumPrefs::mZeroPaddingChoiceCtrl
private

Definition at line 85 of file SpectrumPrefs.h.

Referenced by EnableDisableSTFTOnlyControls(), and PopulateOrExchange().

◆ mZeroPaddingChoices

TranslatableStrings SpectrumPrefs::mZeroPaddingChoices
private

Definition at line 86 of file SpectrumPrefs.h.

Referenced by PopulateOrExchange(), and PopulatePaddingChoices().


The documentation for this class was generated from the following files: