Audacity  3.0.3
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 () override
 
TranslatableString GetDescription () 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 PluginPath GetPath ()
 
virtual VendorSymbol GetVendor ()
 
virtual wxString GetVersion ()
 
virtual void PopulateOrExchange (ShuttleGui &WXUNUSED(S))
 
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
 
TranslatableStrings mTypeChoices
 
wxChoice * mAlgorithmChoice
 
wxCheckBox * mDefaultsCheckbox
 
SpectrogramSettings mTempSettings
 
SpectrogramSettings mOrigSettings
 
std::vector< WaveTrackSubViewPlacementmOrigPlacements
 
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 38 of file SpectrumPrefs.cpp.

40 : PrefsPanel(parent, winid, wt ? XO("Spectrogram Settings") : XO("Spectrograms"))
41 , mProject{ pProject }
42 , mWt(wt)
43 , mPopulating(false)
44 {
45  if (mWt) {
53  }
54  else {
56  mOrigDefaulted = mDefaulted = false;
57  }
58 
59  const auto windowSize = mTempSettings.WindowSize();
61  Populate(windowSize);
62 }

◆ ~SpectrumPrefs()

SpectrumPrefs::~SpectrumPrefs ( )
virtual

Definition at line 64 of file SpectrumPrefs.cpp.

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

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 497 of file SpectrumPrefs.cpp.

498 {
499  if (!Validate())
500  return false;
501 
502  mCommitted = true;
505  if (!mWt || mDefaulted) {
506  pSettings->SavePrefs();
507  }
508  pSettings->LoadPrefs(); // always; in case Globals changed
509 
510  return true;
511 }

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 562 of file SpectrumPrefs.cpp.

563 {
564  // Enable or disable other controls that are applicable only to STFT.
565  const bool STFT =
567  mGain->Enable(STFT);
568  mRange->Enable(STFT);
569  mFrequencyGain->Enable(STFT);
570 #ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
571  mZeroPaddingChoiceCtrl->Enable(STFT);
572 #endif
573 }

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

Referenced by OnAlgorithm(), and PopulateOrExchange().

Here is the caller graph for this function:

◆ GetDescription()

TranslatableString SpectrumPrefs::GetDescription ( )
overridevirtual

Implements ComponentInterface.

Definition at line 75 of file SpectrumPrefs.cpp.

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

References XO.

◆ GetSymbol()

ComponentInterfaceSymbol SpectrumPrefs::GetSymbol ( )
overridevirtual

Implements ComponentInterface.

Definition at line 70 of file SpectrumPrefs.cpp.

71 {
73 }

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 80 of file SpectrumPrefs.cpp.

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

References mWt.

◆ OnAlgorithm()

void SpectrumPrefs::OnAlgorithm ( wxCommandEvent &  evt)
private

Definition at line 556 of file SpectrumPrefs.cpp.

557 {
559  OnControl(evt);
560 }

References EnableDisableSTFTOnlyControls(), and OnControl().

Here is the call graph for this function:

◆ OnControl()

void SpectrumPrefs::OnControl ( wxCommandEvent &  event)
private

Definition at line 518 of file SpectrumPrefs.cpp.

519 {
520  // Common routine for most controls
521  // If any per-track setting is changed, break the association with defaults
522  // Skip this, and View Settings... will be able to change defaults instead
523  // when the checkbox is on, as in the original design.
524 
525  if (mDefaultsCheckbox && !mPopulating) {
526  mDefaulted = false;
527  mDefaultsCheckbox->SetValue(false);
528  }
529 }

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 545 of file SpectrumPrefs.cpp.

546 {
547  if (mDefaultsCheckbox->IsChecked()) {
550  mDefaulted = true;
553  }
554 }

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

Here is the call graph for this function:

◆ OnWindowSize()

void SpectrumPrefs::OnWindowSize ( wxCommandEvent &  event)
private

Definition at line 531 of file SpectrumPrefs.cpp.

532 {
533  // Restrict choice of zero padding, so that product of window
534  // size and padding may not exceed the largest window size.
535  wxChoice *const pWindowSizeControl =
536  static_cast<wxChoice*>(wxWindow::FindWindowById(ID_WINDOW_SIZE, this));
537  size_t windowSize = 1 <<
538  (pWindowSizeControl->GetSelection() + SpectrogramSettings::LogMinWindowSize);
539  PopulatePaddingChoices(windowSize);
540 
541  // Do the common part
542  OnControl(evt);
543 }

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 110 of file SpectrumPrefs.cpp.

111 {
112  PopulatePaddingChoices(windowSize);
113 
114  for (int i = 0; i < NumWindowFuncs(); i++) {
115  mTypeChoices.push_back( WindowFuncName(i) );
116  }
117 
118  //------------------------- Main section --------------------
119  // Now construct the GUI itself.
122  // ----------------------- End of main section --------------
123 }

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

Here is the call graph for this function:

◆ PopulateOrExchange()

void SpectrumPrefs::PopulateOrExchange ( ShuttleGui S)
override

Definition at line 165 of file SpectrumPrefs.cpp.

166 {
167  mPopulating = true;
168  S.SetBorder(2);
169  S.StartScroller(); {
170 
171  // S.StartStatic(XO("Track Settings"));
172  // {
173 
174 
175  mDefaultsCheckbox = 0;
176  if (mWt) {
177  /* i18n-hint: use is a verb */
178  mDefaultsCheckbox = S.Id(ID_DEFAULTS).TieCheckBox(XXO("&Use Preferences"), mDefaulted);
179  }
180 
181  S.StartMultiColumn(2,wxEXPAND);
182  {
183  S.SetStretchyCol( 0 );
184  S.SetStretchyCol( 1 );
185  S.StartStatic(XO("Scale"),1);
186  {
187  S.StartMultiColumn(2,wxEXPAND);
188  {
189  S.SetStretchyCol( 0 );
190  S.SetStretchyCol( 1 );
191  S.Id(ID_SCALE).TieChoice(XXO("S&cale:"),
194  mMinFreq =
195  S.Id(ID_MINIMUM).TieNumericTextBox(XXO("Mi&n Frequency (Hz):"),
197  12);
198  mMaxFreq =
199  S.Id(ID_MAXIMUM).TieNumericTextBox(XXO("Ma&x Frequency (Hz):"),
201  12);
202  }
203  S.EndMultiColumn();
204  }
205  S.EndStatic();
206 
207  S.StartStatic(XO("Colors"),1);
208  {
209  S.StartMultiColumn(2,wxEXPAND);
210  {
211  S.SetStretchyCol( 0 );
212  S.SetStretchyCol( 1 );
213  mGain =
214  S.Id(ID_GAIN).TieNumericTextBox(XXO("&Gain (dB):"),
216  8);
217  mRange =
218  S.Id(ID_RANGE).TieNumericTextBox(XXO("&Range (dB):"),
220  8);
221 
223  S.Id(ID_FREQUENCY_GAIN).TieNumericTextBox(XXO("High &boost (dB/dec):"),
225  8);
226 
227  // i18n-hint Scheme refers to a color scheme for spectrogram colors
228  S.Id(ID_COLOR_SCHEME).TieChoice(XC("Sche&me", "spectrum prefs"),
231  }
232  S.EndMultiColumn();
233  }
234  S.EndStatic();
235  }
236  S.EndMultiColumn();
237 
238  S.StartStatic(XO("Algorithm"));
239  {
240  S.StartMultiColumn(2);
241  {
243  S.Id(ID_ALGORITHM).TieChoice(XXO("A&lgorithm:"),
246 
247  S.Id(ID_WINDOW_SIZE).TieChoice(XXO("Window &size:"),
249  {
250  XO("8 - most wideband"),
251  XO("16"),
252  XO("32"),
253  XO("64"),
254  XO("128"),
255  XO("256"),
256  XO("512"),
257  XO("1024 - default"),
258  XO("2048"),
259  XO("4096"),
260  XO("8192"),
261  XO("16384"),
262  XO("32768 - most narrowband"),
263  }
264  );
265 
266  S.Id(ID_WINDOW_TYPE).TieChoice(XXO("Window &type:"),
268  mTypeChoices);
269 
270 #ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
271  mZeroPaddingChoiceCtrl =
272  S.Id(ID_PADDING_SIZE).TieChoice(XXO("&Zero padding factor:"),
273  mTempSettings.zeroPaddingFactor,
274  mZeroPaddingChoices);
275 #endif
276  }
277  S.EndMultiColumn();
278  }
279  S.EndStatic();
280 
281 #ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
282  S.Id(ID_SPECTRAL_SELECTION).TieCheckBox(XXO("Ena&ble Spectral Selection"),
284 #endif
285 
286 #ifdef EXPERIMENTAL_FFT_Y_GRID
287  S.TieCheckBox(XO("Show a grid along the &Y-axis"),
288  mTempSettings.fftYGrid);
289 #endif //EXPERIMENTAL_FFT_Y_GRID
290 
291 #ifdef EXPERIMENTAL_FIND_NOTES
292  /* i18n-hint: FFT stands for Fast Fourier Transform and probably shouldn't be translated*/
293  S.StartStatic(XO("FFT Find Notes"));
294  {
295  S.StartTwoColumn();
296  {
297  mFindNotesMinA =
298  S.TieNumericTextBox(XXO("Minimum Amplitude (dB):"),
299  mTempSettings.findNotesMinA,
300  8);
301 
302  mFindNotesN =
303  S.TieNumericTextBox(XXO("Max. Number of Notes (1..128):"),
304  mTempSettings.numberOfMaxima,
305  8);
306  }
307  S.EndTwoColumn();
308 
309  S.TieCheckBox(XXO("&Find Notes"),
310  mTempSettings.fftFindNotes);
311 
312  S.TieCheckBox(XXO("&Quantize Notes"),
313  mTempSettings.findNotesQuantize);
314  }
315  S.EndStatic();
316 #endif //EXPERIMENTAL_FIND_NOTES
317  // S.EndStatic();
318 
319 #ifdef SPECTRAL_SELECTION_GLOBAL_SWITCH
320  S.StartStatic(XO("Global settings"));
321  {
322  S.TieCheckBox(XXO("Ena&ble spectral selection"),
323  SpectrogramSettings::Globals::Get().spectralSelection);
324  }
325  S.EndStatic();
326 #endif
327 
328  } S.EndScroller();
329 
330  // Enabling and disabling belongs outside this function.
331  if( S.GetMode() != eIsGettingMetadata )
333 
334  mPopulating = false;
335 }

References SpectrogramSettings::algorithm, SpectrogramSettings::colorScheme, eIsGettingMetadata, EnableDisableSTFTOnlyControls(), ShuttleGuiBase::EndMultiColumn(), ShuttleGuiBase::EndScroller(), ShuttleGuiBase::EndStatic(), ShuttleGuiBase::EndTwoColumn(), SpectrogramSettings::frequencyGain, SpectrogramSettings::gain, SpectrogramSettings::Globals::Get(), SpectrogramSettings::GetAlgorithmNames(), SpectrogramSettings::GetColorSchemeNames(), ShuttleGui::GetMode(), SpectrogramSettings::GetScaleNames(), ShuttleGui::Id(), ID_DEFAULTS, ID_RANGE, ID_SCALE, ID_WINDOW_SIZE, mAlgorithmChoice, SpectrogramSettings::maxFreq, mDefaulted, mDefaultsCheckbox, mFrequencyGain, mGain, SpectrogramSettings::minFreq, mMaxFreq, mMinFreq, mPopulating, mRange, Msgids(), mTempSettings, mTypeChoices, mWt, SpectrogramSettings::range, SpectrogramSettings::scaleType, ShuttleGuiBase::SetBorder(), ShuttleGuiBase::SetStretchyCol(), SpectrogramSettings::spectralSelection, ShuttleGuiBase::StartMultiColumn(), ShuttleGuiBase::StartScroller(), ShuttleGuiBase::StartStatic(), ShuttleGuiBase::StartTwoColumn(), ShuttleGuiBase::TieCheckBox(), ShuttleGuiBase::TieChoice(), ShuttleGuiBase::TieNumericTextBox(), SpectrogramSettings::windowSize, SpectrogramSettings::windowType, XC, XO, and XXO.

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 125 of file SpectrumPrefs.cpp.

126 {
127 #ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
128  mZeroPaddingChoice = 1;
129 
130  // The choice of window size restricts the choice of padding.
131  // So the padding menu might grow or shrink.
132 
133  // If pPaddingSizeControl is NULL, we have not yet tied the choice control.
134  // If it is not NULL, we rebuild the control by hand.
135  // I don't yet know an easier way to do this with ShuttleGUI functions.
136  // PRL
137  wxChoice *const pPaddingSizeControl =
138  static_cast<wxChoice*>(wxWindow::FindWindowById(ID_PADDING_SIZE, this));
139 
140  if (pPaddingSizeControl) {
141  mZeroPaddingChoice = pPaddingSizeControl->GetSelection();
142  pPaddingSizeControl->Clear();
143  }
144 
145  unsigned padding = 1;
146  int numChoices = 0;
147  const size_t maxWindowSize = 1 << (SpectrogramSettings::LogMaxWindowSize);
148  while (windowSize <= maxWindowSize) {
149  const auto numeral = wxString::Format(wxT("%d"), padding);
150  mZeroPaddingChoices.push_back( Verbatim( numeral ) );
151  if (pPaddingSizeControl)
152  pPaddingSizeControl->Append(numeral);
153  windowSize <<= 1;
154  padding <<= 1;
155  ++numChoices;
156  }
157 
158  mZeroPaddingChoice = std::min(mZeroPaddingChoice, numChoices - 1);
159 
160  if (pPaddingSizeControl)
161  pPaddingSizeControl->SetSelection(mZeroPaddingChoice);
162 #endif
163 }

References SpectrogramSettings::LogMaxWindowSize, min(), and Verbatim().

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 442 of file SpectrumPrefs.cpp.

443 {
444  if (!Validate())
445  return;
446 
447  const bool isOpenPage = this->IsShown();
448 
449  ShuttleGui S(this, eIsSavingToPrefs);
451 
452 
454 
455  if (mWt) {
456  for (auto channel : TrackList::Channels(mWt)) {
457  if (mDefaulted) {
458  channel->SetSpectrogramSettings({});
459  // ... and so that the vertical scale also defaults:
460  channel->SetSpectrumBounds(-1, -1);
461  }
462  else {
464  channel->GetIndependentSpectrogramSettings();
465  channel->SetSpectrumBounds(mTempSettings.minFreq, mTempSettings.maxFreq);
467  }
468  }
469  }
470 
471  if (!mWt || mDefaulted) {
473  *pSettings = mTempSettings;
474  }
476 
477  // Bug 2278
478  // This code destroys any Multi-view we had.
479  // Commenting it out as it seems not to be needed.
480  /*
481  if (mWt && isOpenPage) {
482  for (auto channel : TrackList::Channels(mWt))
483  WaveTrackView::Get( *channel )
484  .SetDisplay( WaveTrackViewConstants::Spectrum );
485  }
486  */
487 
488  if (isOpenPage) {
489  if ( mProject ) {
490  auto &tp = TrackPanel::Get( *mProject );
491  tp.UpdateVRulers();
492  tp.Refresh(false);
493  }
494  }
495 }

References TrackList::Channels(), SpectrogramSettings::ConvertToActualWindowSizes(), SpectrogramSettings::ConvertToEnumeratedWindowSizes(), SpectrogramSettings::defaults(), eIsSavingToPrefs, TrackPanel::Get(), SpectrogramSettings::maxFreq, mDefaulted, SpectrogramSettings::minFreq, mProject, mTempSettings, mWt, PopulateOrExchange(), settings(), and Validate().

Here is the call graph for this function:

◆ Rollback()

void SpectrumPrefs::Rollback ( )

Definition at line 402 of file SpectrumPrefs.cpp.

403 {
404  if (mWt) {
405  auto channels = TrackList::Channels(mWt);
406 
407  for (auto channel : channels) {
408  if (mOrigDefaulted) {
409  channel->SetSpectrogramSettings({});
410  channel->SetSpectrumBounds(-1, -1);
411  }
412  else {
413  auto &settings =
414  channel->GetIndependentSpectrogramSettings();
415  channel->SetSpectrumBounds(mOrigMin, mOrigMax);
417  }
418  }
419  }
420 
421  if (!mWt || mOrigDefaulted) {
423  *pSettings = mOrigSettings;
424  }
425 
426  const bool isOpenPage = this->IsShown();
427  if (mWt && isOpenPage) {
428  auto channels = TrackList::Channels(mWt);
429  for (auto channel : channels)
431  }
432 
433  if (isOpenPage) {
434  if ( mProject ) {
435  auto &tp = TrackPanel::Get ( *mProject );
436  tp.UpdateVRulers();
437  tp.Refresh(false);
438  }
439  }
440 }

References TrackList::Channels(), SpectrogramSettings::defaults(), TrackPanel::Get(), WaveTrackView::Get(), mOrigDefaulted, mOrigMax, mOrigMin, mOrigPlacements, mOrigSettings, mProject, mWt, WaveTrackView::RestorePlacements(), 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 513 of file SpectrumPrefs.cpp.

514 {
515  return mProject != nullptr;
516 }

References mProject.

◆ Validate()

bool SpectrumPrefs::Validate ( )
override

Definition at line 337 of file SpectrumPrefs.cpp.

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

References AudacityMessageBox(), SpectrogramSettings::ConvertToActualWindowSizes(), SpectrogramSettings::ConvertToEnumeratedWindowSizes(), eIsSavingToPrefs, mFrequencyGain, mGain, mMaxFreq, mMinFreq, mRange, mTempSettings, PopulateOrExchange(), 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 89 of file SpectrumPrefs.h.

Referenced by EnableDisableSTFTOnlyControls(), and PopulateOrExchange().

◆ mCommitted

bool SpectrumPrefs::mCommitted {}
private

Definition at line 105 of file SpectrumPrefs.h.

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

◆ mDefaulted

bool SpectrumPrefs::mDefaulted
private

Definition at line 73 of file SpectrumPrefs.h.

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

◆ mDefaultsCheckbox

wxCheckBox* SpectrumPrefs::mDefaultsCheckbox
private

Definition at line 97 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().

◆ mOrigMax

float SpectrumPrefs::mOrigMax
private

Definition at line 102 of file SpectrumPrefs.h.

Referenced by Rollback().

◆ mOrigMin

float SpectrumPrefs::mOrigMin
private

Definition at line 102 of file SpectrumPrefs.h.

Referenced by Rollback().

◆ mOrigPlacements

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

Definition at line 101 of file SpectrumPrefs.h.

Referenced by Rollback().

◆ mOrigSettings

SpectrogramSettings SpectrumPrefs::mOrigSettings
private

Definition at line 99 of file SpectrumPrefs.h.

Referenced by Rollback().

◆ mPopulating

bool SpectrumPrefs::mPopulating
private

Definition at line 104 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 99 of file SpectrumPrefs.h.

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

◆ mTypeChoices

TranslatableStrings SpectrumPrefs::mTypeChoices
private

Definition at line 87 of file SpectrumPrefs.h.

Referenced by Populate(), and PopulateOrExchange().

◆ mWt

WaveTrack* const SpectrumPrefs::mWt
private

Definition at line 72 of file SpectrumPrefs.h.

Referenced by Commit(), HelpPageName(), PopulateOrExchange(), Preview(), and Rollback().


The documentation for this class was generated from the following files:
SpectrumPrefs::mOrigSettings
SpectrogramSettings mOrigSettings
Definition: SpectrumPrefs.h:99
SpectrumPrefs::mOrigDefaulted
bool mOrigDefaulted
Definition: SpectrumPrefs.h:73
SpectrogramSettings::maxFreq
int maxFreq
Definition: SpectrogramSettings.h:104
SpectrogramSettings::GetAlgorithmNames
static const TranslatableStrings & GetAlgorithmNames()
Definition: SpectrogramSettings.cpp:200
SpectrogramSettings
Spectrogram settings, either for one track or as defaults.
Definition: SpectrogramSettings.h:27
SpectrumPrefs::EnableDisableSTFTOnlyControls
void EnableDisableSTFTOnlyControls()
Definition: SpectrumPrefs.cpp:562
SpectrogramSettings::windowType
int windowType
Definition: SpectrogramSettings.h:113
SpectrumPrefs::mDefaultsCheckbox
wxCheckBox * mDefaultsCheckbox
Definition: SpectrumPrefs.h:97
AudacityMessageBox
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
Definition: AudacityMessageBox.cpp:17
SpectrogramSettings::gain
int gain
Definition: SpectrogramSettings.h:110
SpectrumPrefs::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S) override
Definition: SpectrumPrefs.cpp:165
SpectrumPrefs::mGain
wxTextCtrl * mGain
Definition: SpectrumPrefs.h:77
SpectrogramSettings::LogMinWindowSize
@ LogMinWindowSize
Definition: SpectrogramSettings.h:48
ID_WINDOW_SIZE
@ ID_WINDOW_SIZE
Definition: SpectrumPrefs.cpp:93
SpectrumPrefs::mFrequencyGain
wxTextCtrl * mFrequencyGain
Definition: SpectrumPrefs.h:79
ShuttleGuiBase::TieCheckBox
wxCheckBox * TieCheckBox(const TranslatableString &Prompt, bool &Var)
Definition: ShuttleGui.cpp:1629
TrackList::Channels
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1484
SpectrogramSettings::Validate
bool Validate(bool quiet)
Definition: SpectrogramSettings.cpp:213
ID_RANGE
@ ID_RANGE
Definition: WaveformPrefs.cpp:78
NumWindowFuncs
int NumWindowFuncs()
Definition: FFT.cpp:329
TrackPanel::Get
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:227
XO
#define XO(s)
Definition: Internat.h:31
XC
#define XC(s, c)
Definition: Internat.h:37
SpectrumPrefs::mMaxFreq
wxTextCtrl * mMaxFreq
Definition: SpectrumPrefs.h:76
SPECTRUM_PREFS_PLUGIN_SYMBOL
#define SPECTRUM_PREFS_PLUGIN_SYMBOL
Definition: SpectrumPrefs.h:39
WaveTrackView::RestorePlacements
void RestorePlacements(const WaveTrackSubViewPlacements &placements)
Definition: WaveTrackView.h:124
SpectrogramSettings::GetScaleNames
static const EnumValueSymbols & GetScaleNames()
Definition: SpectrogramSettings.cpp:140
ShuttleGuiBase::EndMultiColumn
void EndMultiColumn()
Definition: ShuttleGui.cpp:1238
SpectrumPrefs::mOrigMax
float mOrigMax
Definition: SpectrumPrefs.h:102
SpectrogramSettings::GetColorSchemeNames
static const EnumValueSymbols & GetColorSchemeNames()
Definition: SpectrogramSettings.cpp:159
WaveTrack::GetSpectrogramSettings
const SpectrogramSettings & GetSpectrogramSettings() const
Definition: WaveTrack.cpp:762
SpectrogramSettings::range
int range
Definition: SpectrogramSettings.h:109
eIsSettingToDialog
@ eIsSettingToDialog
Definition: ShuttleGui.h:40
SpectrumPrefs::OnControl
void OnControl(wxCommandEvent &event)
Definition: SpectrumPrefs.cpp:518
SpectrogramSettings::algorithm
Algorithm algorithm
Definition: SpectrogramSettings.h:163
ShuttleGui::Id
ShuttleGui & Id(int id)
Definition: ShuttleGui.cpp:2274
SpectrumPrefs::mOrigPlacements
std::vector< WaveTrackSubViewPlacement > mOrigPlacements
Definition: SpectrumPrefs.h:101
SpectrumPrefs::mOrigMin
float mOrigMin
Definition: SpectrumPrefs.h:102
SpectrogramSettings::windowSize
int windowSize
Definition: SpectrogramSettings.h:116
ShuttleGuiBase::EndScroller
void EndScroller()
Definition: ShuttleGui.cpp:971
SpectrumPrefs::mTypeChoices
TranslatableStrings mTypeChoices
Definition: SpectrumPrefs.h:87
ID_SCALE
@ ID_SCALE
Definition: WaveformPrefs.cpp:77
XXO
#define XXO(s)
Definition: Internat.h:44
ShuttleGuiBase::StartScroller
wxScrolledWindow * StartScroller(int iStyle=0)
Definition: ShuttleGui.cpp:938
SpectrogramSettings::spectralSelection
bool spectralSelection
Definition: SpectrogramSettings.h:152
SpectrumPrefs::mCommitted
bool mCommitted
Definition: SpectrumPrefs.h:105
ShuttleGuiBase::StartMultiColumn
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:1229
SpectrumPrefs::mAlgorithmChoice
wxChoice * mAlgorithmChoice
Definition: SpectrumPrefs.h:89
SpectrumPrefs::Rollback
void Rollback()
Definition: SpectrumPrefs.cpp:402
WaveTrack::GetSpectrumBounds
void GetSpectrumBounds(float *min, float *max) const
Definition: WaveTrack.cpp:327
SpectrumPrefs::PopulatePaddingChoices
void PopulatePaddingChoices(size_t windowSize)
Definition: SpectrumPrefs.cpp:125
SpectrogramSettings::Globals::Get
static Globals & Get()
Definition: SpectrogramSettings.cpp:52
ShuttleGuiBase::StartTwoColumn
void StartTwoColumn()
Definition: ShuttleGui.h:366
SpectrumPrefs::mTempSettings
SpectrogramSettings mTempSettings
Definition: SpectrumPrefs.h:99
WaveTrackView::SavePlacements
const WaveTrackSubViewPlacements & SavePlacements() const
Definition: WaveTrackView.h:122
ShuttleGuiBase::TieNumericTextBox
wxTextCtrl * TieNumericTextBox(const TranslatableString &Prompt, int &Value, const int nChars=0)
Definition: ShuttleGui.cpp:1673
SpectrogramSettings::WindowSize
size_t WindowSize() const
Definition: SpectrogramSettings.h:118
SpectrogramSettings::SavePrefs
void SavePrefs()
Definition: SpectrogramSettings.cpp:329
SpectrogramSettings::scaleType
ScaleType scaleType
Definition: SpectrogramSettings.h:149
Msgids
TranslatableStrings Msgids(const EnumValueSymbol strings[], size_t nStrings)
Convenience function often useful when adding choice controls.
Definition: ShuttleGui.cpp:2522
WindowFuncName
const TranslatableString WindowFuncName(int whichFunction)
Definition: FFT.cpp:334
SpectrumPrefs::mDefaulted
bool mDefaulted
Definition: SpectrumPrefs.h:73
SpectrogramSettings::LoadPrefs
void LoadPrefs()
Definition: SpectrogramSettings.cpp:284
ShuttleGuiBase::StartStatic
wxStaticBox * StartStatic(const TranslatableString &Str, int iProp=0)
Definition: ShuttleGui.cpp:893
eIsSavingToPrefs
@ eIsSavingToPrefs
Definition: ShuttleGui.h:48
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
SpectrumPrefs::mPopulating
bool mPopulating
Definition: SpectrumPrefs.h:104
eIsGettingMetadata
@ eIsGettingMetadata
Definition: ShuttleGui.h:41
SpectrogramSettings::colorScheme
ColorScheme colorScheme
Definition: SpectrogramSettings.h:141
SpectrogramSettings::LogMaxWindowSize
@ LogMaxWindowSize
Definition: SpectrogramSettings.h:49
SpectrumPrefs::mRange
wxTextCtrl * mRange
Definition: SpectrumPrefs.h:78
SpectrogramSettings::algPitchEAC
@ algPitchEAC
Definition: SpectrogramSettings.h:159
WaveTrackView::Get
static WaveTrackView & Get(WaveTrack &track)
Definition: WaveTrackView.cpp:880
SpectrumPrefs::Validate
bool Validate() override
Definition: SpectrumPrefs.cpp:337
Verbatim
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
Definition: TranslatableString.h:321
SpectrogramSettings::ConvertToActualWindowSizes
void ConvertToActualWindowSizes()
Definition: SpectrogramSettings.cpp:584
ShuttleGui::GetMode
teShuttleMode GetMode()
Definition: ShuttleGui.h:752
SpectrumPrefs::Populate
void Populate(size_t windowSize)
Definition: SpectrumPrefs.cpp:110
ShuttleGuiBase::SetBorder
void SetBorder(int Border)
Definition: ShuttleGui.h:489
ShuttleGuiBase::EndTwoColumn
void EndTwoColumn()
Definition: ShuttleGui.h:367
eIsCreatingFromPrefs
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:47
SpectrogramSettings::ConvertToEnumeratedWindowSizes
void ConvertToEnumeratedWindowSizes()
Definition: SpectrogramSettings.cpp:560
ShuttleGuiBase::EndStatic
void EndStatic()
Definition: ShuttleGui.cpp:922
settings
static Settings & settings()
Definition: TrackInfo.cpp:86
ShuttleGuiBase::SetStretchyCol
void SetStretchyCol(int i)
Used to modify an already placed FlexGridSizer to make a column stretchy.
Definition: ShuttleGui.cpp:202
SpectrogramSettings::frequencyGain
int frequencyGain
Definition: SpectrogramSettings.h:111
ID_DEFAULTS
@ ID_DEFAULTS
Definition: SpectrumPrefs.cpp:107
SpectrumPrefs::mMinFreq
wxTextCtrl * mMinFreq
Definition: SpectrumPrefs.h:75
ShuttleGuiBase::TieChoice
wxChoice * TieChoice(const TranslatableString &Prompt, TranslatableString &Selected, const TranslatableStrings &choices)
Definition: ShuttleGui.cpp:1727
SpectrogramSettings::defaults
static SpectrogramSettings & defaults()
Definition: SpectrogramSettings.cpp:133
SpectrumPrefs::mWt
WaveTrack *const mWt
Definition: SpectrumPrefs.h:72
SpectrogramSettings::minFreq
int minFreq
Definition: SpectrogramSettings.h:103
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631
PrefsPanel::PrefsPanel
PrefsPanel(wxWindow *parent, wxWindowID winid, const TranslatableString &title)
Definition: PrefsPanel.h:90
SpectrogramSettings::Globals::SavePrefs
void SavePrefs()
Definition: SpectrogramSettings.cpp:36
SpectrumPrefs::mProject
AudacityProject * mProject
Definition: SpectrumPrefs.h:70