Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
EffectNoiseReduction::Dialog Class Referencefinal

Dialog used with EffectNoiseReduction. More...

Inheritance diagram for EffectNoiseReduction::Dialog:
[legend]
Collaboration diagram for EffectNoiseReduction::Dialog:
[legend]

Public Member Functions

 Dialog (EffectNoiseReduction *effect, EffectSettingsAccess &access, Settings *settings, wxWindow *parent, bool bHasProfile, bool bAllowTwiddleSettings)
 
void PopulateOrExchange (ShuttleGui &S) override
 
bool TransferDataToWindow () override
 
bool TransferDataFromWindow () override
 
const SettingsGetTempSettings () const
 
- Public Member Functions inherited from EffectDialog
 EffectDialog (wxWindow *parent, const TranslatableString &title, int type=0, int flags=wxDEFAULT_DIALOG_STYLE, int additionalButtons=0)
 
void Init ()
 
bool TransferDataToWindow () override
 
bool TransferDataFromWindow () override
 
bool Validate () override
 
virtual void PopulateOrExchange (ShuttleGui &S)
 
virtual void OnPreview (wxCommandEvent &evt)
 
virtual void OnOk (wxCommandEvent &evt)
 
- Public Member Functions inherited from wxDialogWrapper
 wxDialogWrapper ()
 
 wxDialogWrapper (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
bool Create (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
void SetTitle (const TranslatableString &title)
 
void SetLabel (const TranslatableString &title)
 
void SetName (const TranslatableString &title)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxDialog >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Private Member Functions

void DisableControlsIfIsolating ()
 
void OnGetProfile (wxCommandEvent &event)
 
void OnNoiseReductionChoice (wxCommandEvent &event)
 
void OnPreview (wxCommandEvent &event) override
 
void OnReduceNoise (wxCommandEvent &event)
 
void OnCancel (wxCommandEvent &event)
 
void OnHelp (wxCommandEvent &event)
 
void OnText (wxCommandEvent &event)
 
void OnSlider (wxCommandEvent &event)
 

Private Attributes

EffectNoiseReductionm_pEffect
 
EffectSettingsAccessmAccess
 This dialog is modal, so mAccess will live long enough for it. More...
 
EffectNoiseReduction::Settingsm_pSettings
 
EffectNoiseReduction::Settings mTempSettings
 
bool mbHasProfile
 
bool mbAllowTwiddleSettings
 
wxRadioButton * mKeepSignal
 

Detailed Description

Dialog used with EffectNoiseReduction.

Definition at line 51 of file NoiseReduction.cpp.

Constructor & Destructor Documentation

◆ Dialog()

EffectNoiseReduction::Dialog::Dialog ( EffectNoiseReduction effect,
EffectSettingsAccess access,
EffectNoiseReduction::Settings settings,
wxWindow *  parent,
bool  bHasProfile,
bool  bAllowTwiddleSettings 
)

Definition at line 356 of file NoiseReduction.cpp.

360 : EffectDialog( parent, XO("Noise Reduction"), EffectTypeProcess,wxDEFAULT_DIALOG_STYLE, eHelpButton )
361 , m_pEffect(effect)
362 , mAccess{access}
363 , m_pSettings(settings) // point to
364 , mTempSettings(*settings) // copy
365 , mbHasProfile(bHasProfile)
366 , mbAllowTwiddleSettings(bAllowTwiddleSettings)
367 // NULL out the control members until the controls are created.
368 , mKeepSignal(NULL)
369#ifdef ISOLATE_CHOICE
370 , mKeepNoise(NULL)
371#endif
372#ifdef RESIDUE_CHOICE
373 , mResidue(NULL)
374#endif
375{
377
378 wxButton *const pButtonPreview =
379 (wxButton *)wxWindow::FindWindowById(ID_EFFECT_PREVIEW, this);
380 wxButton *const pButtonReduceNoise =
381 (wxButton *)wxWindow::FindWindowById(wxID_OK, this);
382
384 pButtonPreview->Enable(!mbAllowTwiddleSettings);
385 pButtonReduceNoise->SetFocus();
386 }
387 else {
388 pButtonPreview->Enable(false);
389 pButtonReduceNoise->Enable(false);
390 }
391}
#define ID_EFFECT_PREVIEW
Definition: Effect.h:187
@ EffectTypeProcess
XO("Cut/Copy/Paste")
@ eHelpButton
Definition: ShuttleGui.h:613
static Settings & settings()
Definition: TrackInfo.cpp:51
EffectDialog(wxWindow *parent, const TranslatableString &title, int type=0, int flags=wxDEFAULT_DIALOG_STYLE, int additionalButtons=0)
Definition: EffectUI.cpp:1148
EffectNoiseReduction::Settings mTempSettings
EffectSettingsAccess & mAccess
This dialog is modal, so mAccess will live long enough for it.
EffectNoiseReduction * m_pEffect
EffectNoiseReduction::Settings * m_pSettings

Member Function Documentation

◆ DisableControlsIfIsolating()

void EffectNoiseReduction::Dialog::DisableControlsIfIsolating ( )
private

Definition at line 393 of file NoiseReduction.cpp.

394{
395 // If Isolate is chosen, disable controls that define
396 // "what to do with noise" rather than "what is noise."
397 // Else, enable them.
398 // This does NOT include sensitivity, NEW or old, nor
399 // the choice of window functions, size, or step.
400 // The method choice is not included, because it affects
401 // which sensitivity slider is operative, and that is part
402 // of what defines noise.
403
404 static const int toDisable[] = {
407
410
411#ifdef ATTACK_AND_RELEASE
412 ID_ATTACK_TIME_SLIDER,
413 ID_ATTACK_TIME_TEXT,
414
415 ID_RELEASE_TIME_SLIDER,
416 ID_RELEASE_TIME_TEXT,
417#endif
418 };
419 static const auto nToDisable = sizeof(toDisable) / sizeof(toDisable[0]);
420
421 bool bIsolating =
422#ifdef ISOLATE_CHOICE
423 mKeepNoise->GetValue();
424#else
425 false;
426#endif
427 for (auto ii = nToDisable; ii--;)
428 wxWindow::FindWindowById(toDisable[ii], this)->Enable(!bIsolating);
429}
@ ID_GAIN_TEXT
@ ID_GAIN_SLIDER
@ ID_FREQ_SLIDER
@ ID_FREQ_TEXT

References ID_FREQ_SLIDER, ID_FREQ_TEXT, ID_GAIN_SLIDER, and ID_GAIN_TEXT.

◆ GetTempSettings()

const Settings & EffectNoiseReduction::Dialog::GetTempSettings ( ) const
inline

Definition at line 64 of file NoiseReduction.cpp.

65 { return mTempSettings; }

References mTempSettings.

Referenced by anonymous_namespace{NoiseReduction.cpp}::PromptUser().

Here is the caller graph for this function:

◆ OnCancel()

void EffectNoiseReduction::Dialog::OnCancel ( wxCommandEvent &  event)
private

Definition at line 504 of file NoiseReduction.cpp.

505{
506 EndModal(0);
507}

◆ OnGetProfile()

void EffectNoiseReduction::Dialog::OnGetProfile ( wxCommandEvent &  event)
private

Definition at line 445 of file NoiseReduction.cpp.

446{
447 // Project has not be changed so skip pushing state
449
451 return;
452
453 // Return code distinguishes this first step from the actual effect
454 EndModal(1);
455}
void SetSkipStateFlag(bool flag)
static EffectManager & Get()
bool TransferDataFromWindow() override

References EffectManager::Get(), EffectManager::SetSkipStateFlag(), and StatefulEffectUIServices::TransferDataFromWindow().

Here is the call graph for this function:

◆ OnHelp()

void EffectNoiseReduction::Dialog::OnHelp ( wxCommandEvent &  event)
private

Definition at line 509 of file NoiseReduction.cpp.

510{
511 HelpSystem::ShowHelp(this, "Noise_Reduction", true);
512}
static void ShowHelp(wxWindow *parent, const FilePath &localFileName, const URLString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
Definition: HelpSystem.cpp:231

References HelpSystem::ShowHelp().

Here is the call graph for this function:

◆ OnNoiseReductionChoice()

void EffectNoiseReduction::Dialog::OnNoiseReductionChoice ( wxCommandEvent &  event)
private

Definition at line 458 of file NoiseReduction.cpp.

459{
460 if (mKeepSignal->GetValue())
462#ifdef ISOLATE_CHOICE
463 else if (mKeepNoise->GetValue())
465#endif
466#ifdef RESIDUE_CHOICE
467 else
469#endif
471}
@ NRC_REDUCE_NOISE
@ NRC_LEAVE_RESIDUE
@ NRC_ISOLATE_NOISE

References NRC_ISOLATE_NOISE, NRC_LEAVE_RESIDUE, and NRC_REDUCE_NOISE.

◆ OnPreview()

void EffectNoiseReduction::Dialog::OnPreview ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from EffectDialog.

Definition at line 480 of file NoiseReduction.cpp.

481{
483 return;
484
485 // Save & restore parameters around Preview, because we didn't do OK.
486 auto cleanup = valueRestorer( *m_pSettings );
488 m_pSettings->mDoProfile = false;
489
491 // Don't need any UI updates for preview
492 {},
493 false);
494}
void EffectPreview(EffectBase &effect, EffectSettingsAccess &access, std::function< void()> updateUI, bool dryOnly)
Calculate temporary tracks of limited length with effect applied and play.
ValueRestorer< T > valueRestorer(T &var)
inline functions provide convenient parameter type deduction
Definition: MemoryX.h:253

References EffectPreview(), StatefulEffectUIServices::TransferDataFromWindow(), and valueRestorer().

Here is the call graph for this function:

◆ OnReduceNoise()

void EffectNoiseReduction::Dialog::OnReduceNoise ( wxCommandEvent &  event)
private

Definition at line 496 of file NoiseReduction.cpp.

497{
499 return;
500
501 EndModal(2);
502}

References StatefulEffectUIServices::TransferDataFromWindow().

Here is the call graph for this function:

◆ OnSlider()

void EffectNoiseReduction::Dialog::OnSlider ( wxCommandEvent &  event)
private

Definition at line 708 of file NoiseReduction.cpp.

709{
710 int id = event.GetId();
711 int idx = (id - FIRST_SLIDER) / 2;
712 const ControlInfo &info = controlInfo()[idx];
713 wxSlider* slider =
714 static_cast<wxSlider*>(wxWindow::FindWindowById(id, this));
715 wxTextCtrl* text =
716 static_cast<wxTextCtrl*>(wxWindow::FindWindowById(id + 1, this));
717 double &field = mTempSettings.*(info.field);
718
719 field = info.Value(slider->GetValue());
720 text->SetValue(info.Text(field));
721}
#define field(n, t)
Definition: ImportAUP.cpp:165
@ FIRST_SLIDER

References anonymous_namespace{NoiseReduction.cpp}::controlInfo(), field, and FIRST_SLIDER.

Here is the call graph for this function:

◆ OnText()

void EffectNoiseReduction::Dialog::OnText ( wxCommandEvent &  event)
private

Definition at line 693 of file NoiseReduction.cpp.

694{
695 int id = event.GetId();
696 int idx = (id - FIRST_SLIDER - 1) / 2;
697 const ControlInfo &info = controlInfo()[idx];
698 wxTextCtrl* text =
699 static_cast<wxTextCtrl*>(wxWindow::FindWindowById(id, this));
700 wxSlider* slider =
701 static_cast<wxSlider*>(wxWindow::FindWindowById(id - 1, this));
702 double &field = mTempSettings.*(info.field);
703
704 text->GetValue().ToDouble(&field);
705 slider->SetValue(info.SliderSetting(field));
706}

References anonymous_namespace{NoiseReduction.cpp}::controlInfo(), field, and FIRST_SLIDER.

Here is the call graph for this function:

◆ PopulateOrExchange()

void EffectNoiseReduction::Dialog::PopulateOrExchange ( ShuttleGui S)
overridevirtual

This is a virtual function which will be overridden to provide the actual parameters that we want for each kind of dialog.

Reimplemented from EffectDialog.

Definition at line 514 of file NoiseReduction.cpp.

515{
516 S.StartStatic(XO("Step 1"));
517 {
518 S.AddVariableText(XO(
519"Select a few seconds of just noise so Audacity knows what to filter out,\nthen click Get Noise Profile:"));
520 //m_pButton_GetProfile =
521 S.Id(ID_BUTTON_GETPROFILE).AddButton(XXO("&Get Noise Profile"));
522 }
523 S.EndStatic();
524
525 S.StartStatic(XO("Step 2"));
526 {
527 S.AddVariableText(XO(
528"Select all of the audio you want filtered, choose how much noise you want\nfiltered out, and then click 'OK' to reduce noise.\n"));
529
530 S.StartMultiColumn(3, wxEXPAND);
531 S.SetStretchyCol(2);
532 {
533 for (int id = FIRST_SLIDER; id < END_OF_BASIC_SLIDERS; id += 2) {
534 const ControlInfo &info = controlInfo()[(id - FIRST_SLIDER) / 2];
535 info.CreateControls(id, S);
536 }
537 }
538 S.EndMultiColumn();
539
540 S.StartMultiColumn(
541 2
542#ifdef RESIDUE_CHOICE
543 +1
544#endif
545#ifdef ISOLATE_CHOICE
546 +1
547#endif
548 ,
549 wxALIGN_CENTER_HORIZONTAL);
550 {
551 S.AddPrompt(XXO("Noise:"));
553 /* i18n-hint: Translate differently from "Residue" ! */
554 .AddRadioButton(XXO("Re&duce"));
555#ifdef ISOLATE_CHOICE
556 mKeepNoise = S.Id(ID_RADIOBUTTON_KEEPNOISE)
557 .AddRadioButtonToGroup(XXO("&Isolate"));
558#endif
559#ifdef RESIDUE_CHOICE
560 mResidue = S.Id(ID_RADIOBUTTON_RESIDUE)
561 /* i18n-hint: Means the difference between effect and original sound. Translate differently from "Reduce" ! */
562 .AddRadioButtonToGroup(XXO("Resid&ue"));
563#endif
564 }
565 S.EndMultiColumn();
566 }
567 S.EndStatic();
568
569
570#ifdef ADVANCED_SETTINGS
571 S.StartStatic(XO("Advanced Settings"));
572 {
573 S.StartMultiColumn(2);
574 {
575 S.TieChoice(XXO("&Window types:"),
577 []{
578 TranslatableStrings windowTypeChoices;
579 for (size_t ii = 0; ii < WT_N_WINDOW_TYPES; ++ii)
580 windowTypeChoices.push_back(windowTypesInfo[ii].name);
581 return windowTypeChoices;
582 }()
583 );
584
585 S.TieChoice(XXO("Window si&ze:"),
587 {
588 XO("8") ,
589 XO("16") ,
590 XO("32") ,
591 XO("64") ,
592 XO("128") ,
593 XO("256") ,
594 XO("512") ,
595 XO("1024") ,
596 XO("2048 (default)") ,
597 XO("4096") ,
598 XO("8192") ,
599 XO("16384") ,
600 }
601 );
602
603 S.TieChoice(XXO("S&teps per window:"),
605 {
606 XO("2") ,
607 XO("4 (default)") ,
608 XO("8") ,
609 XO("16") ,
610 XO("32") ,
611 XO("64") ,
612 }
613 );
614
615 S.Id(ID_CHOICE_METHOD)
616 .TieChoice(XXO("Discrimination &method:"),
618 []{
619 TranslatableStrings methodChoices;
620 auto nn = DM_N_METHODS;
621#ifndef OLD_METHOD_AVAILABLE
622 --nn;
623#endif
624 for (auto ii = 0; ii < nn; ++ii)
625 methodChoices.push_back(discriminationMethodInfo[ii].name);
626 return methodChoices;
627 }());
628 }
629 S.EndMultiColumn();
630
631 S.StartMultiColumn(3, wxEXPAND);
632 S.SetStretchyCol(2);
633 {
634 for (int id = END_OF_BASIC_SLIDERS; id < END_OF_ADVANCED_SLIDERS; id += 2) {
635 const ControlInfo &info = controlInfo()[(id - FIRST_SLIDER) / 2];
636 info.CreateControls(id, S);
637 }
638 }
639 S.EndMultiColumn();
640 }
641 S.EndStatic();
642#endif
643}
XXO("&Cut/Copy/Paste Toolbar")
@ ID_BUTTON_GETPROFILE
@ END_OF_BASIC_SLIDERS
@ ID_RADIOBUTTON_KEEPSIGNAL
#define RESIDUE_CHOICE
#define S(N)
Definition: ToChars.cpp:64
std::vector< TranslatableString > TranslatableStrings
const struct anonymous_namespace{NoiseReductionBase.cpp}::WindowTypesInfo windowTypesInfo[WT_N_WINDOW_TYPES]
const struct anonymous_namespace{NoiseReductionBase.cpp}::DiscriminationMethodInfo discriminationMethodInfo[DM_N_METHODS]
void CreateControls(int id, ShuttleGui &S) const

References anonymous_namespace{NoiseReduction.cpp}::controlInfo(), anonymous_namespace{NoiseReduction.cpp}::ControlInfo::CreateControls(), anonymous_namespace{NoiseReductionBase.cpp}::discriminationMethodInfo, anonymous_namespace{NoiseReductionBase.cpp}::DM_N_METHODS, END_OF_BASIC_SLIDERS, FIRST_SLIDER, ID_BUTTON_GETPROFILE, ID_RADIOBUTTON_KEEPSIGNAL, RESIDUE_CHOICE, S, anonymous_namespace{NoiseReductionBase.cpp}::windowTypesInfo, anonymous_namespace{NoiseReductionBase.cpp}::WT_N_WINDOW_TYPES, XO(), and XXO().

Here is the call graph for this function:

◆ TransferDataFromWindow()

bool EffectNoiseReduction::Dialog::TransferDataFromWindow ( )
override

Definition at line 679 of file NoiseReduction.cpp.

680{
681 if( !wxWindow::Validate() )
682 return false;
683 // Do the choice controls:
685 return false;
686
687 wxCommandEvent dummy;
689
691}
bool TransferDataFromWindow() override
Definition: EffectUI.cpp:1203
void OnNoiseReductionChoice(wxCommandEvent &event)
bool Validate(NoiseReductionBase *effect) const

References EffectDialog::TransferDataFromWindow().

Here is the call graph for this function:

◆ TransferDataToWindow()

bool EffectNoiseReduction::Dialog::TransferDataToWindow ( )
override

Definition at line 645 of file NoiseReduction.cpp.

646{
647 // Do the choice controls:
649 return false;
650
651 for (int id = FIRST_SLIDER; id < END_OF_SLIDERS; id += 2) {
652 wxSlider* slider =
653 static_cast<wxSlider*>(wxWindow::FindWindowById(id, this));
654 wxTextCtrl* text =
655 static_cast<wxTextCtrl*>(wxWindow::FindWindowById(id + 1, this));
656 const ControlInfo &info = controlInfo()[(id - FIRST_SLIDER) / 2];
657 const double field = mTempSettings.*(info.field);
658 text->SetValue(info.Text(field));
659 slider->SetValue(info.SliderSetting(field));
660 }
661
663#ifdef ISOLATE_CHOICE
665#endif
666#ifdef RESIDUE_CHOICE
668#endif
669
670 // Set the enabled states of controls
672#ifdef ADVANCED_SETTINGS
673 EnableDisableSensitivityControls();
674#endif
675
676 return true;
677}
@ END_OF_SLIDERS
bool TransferDataToWindow() override
Definition: EffectUI.cpp:1195

References anonymous_namespace{NoiseReduction.cpp}::controlInfo(), END_OF_SLIDERS, field, FIRST_SLIDER, NRC_ISOLATE_NOISE, NRC_LEAVE_RESIDUE, NRC_REDUCE_NOISE, and EffectDialog::TransferDataToWindow().

Here is the call graph for this function:

Member Data Documentation

◆ m_pEffect

EffectNoiseReduction* EffectNoiseReduction::Dialog::m_pEffect
private

Definition at line 90 of file NoiseReduction.cpp.

◆ m_pSettings

EffectNoiseReduction::Settings* EffectNoiseReduction::Dialog::m_pSettings
private

Definition at line 93 of file NoiseReduction.cpp.

◆ mAccess

EffectSettingsAccess& EffectNoiseReduction::Dialog::mAccess
private

This dialog is modal, so mAccess will live long enough for it.

Definition at line 92 of file NoiseReduction.cpp.

◆ mbAllowTwiddleSettings

bool EffectNoiseReduction::Dialog::mbAllowTwiddleSettings
private

Definition at line 97 of file NoiseReduction.cpp.

◆ mbHasProfile

bool EffectNoiseReduction::Dialog::mbHasProfile
private

Definition at line 96 of file NoiseReduction.cpp.

◆ mKeepSignal

wxRadioButton* EffectNoiseReduction::Dialog::mKeepSignal
private

Definition at line 100 of file NoiseReduction.cpp.

◆ mTempSettings

EffectNoiseReduction::Settings EffectNoiseReduction::Dialog::mTempSettings
private

Definition at line 94 of file NoiseReduction.cpp.

Referenced by GetTempSettings().


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