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
 
wxRadioButton * mResidue
 

Detailed Description

Dialog used with EffectNoiseReduction.

Definition at line 361 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 1405 of file NoiseReduction.cpp.

1409 : EffectDialog( parent, XO("Noise Reduction"), EffectTypeProcess,wxDEFAULT_DIALOG_STYLE, eHelpButton )
1410 , m_pEffect(effect)
1411 , mAccess{access}
1412 , m_pSettings(settings) // point to
1413 , mTempSettings(*settings) // copy
1414 , mbHasProfile(bHasProfile)
1415 , mbAllowTwiddleSettings(bAllowTwiddleSettings)
1416 // NULL out the control members until the controls are created.
1417 , mKeepSignal(NULL)
1418#ifdef ISOLATE_CHOICE
1419 , mKeepNoise(NULL)
1420#endif
1421#ifdef RESIDUE_CHOICE
1422 , mResidue(NULL)
1423#endif
1424{
1426
1427 wxButton *const pButtonPreview =
1428 (wxButton *)wxWindow::FindWindowById(ID_EFFECT_PREVIEW, this);
1429 wxButton *const pButtonReduceNoise =
1430 (wxButton *)wxWindow::FindWindowById(wxID_OK, this);
1431
1433 pButtonPreview->Enable(!mbAllowTwiddleSettings);
1434 pButtonReduceNoise->SetFocus();
1435 }
1436 else {
1437 pButtonPreview->Enable(false);
1438 pButtonReduceNoise->Enable(false);
1439 }
1440}
#define ID_EFFECT_PREVIEW
Definition: Effect.h:187
@ EffectTypeProcess
XO("Cut/Copy/Paste")
@ eHelpButton
Definition: ShuttleGui.h:613
static Settings & settings()
Definition: TrackInfo.cpp:69
EffectDialog(wxWindow *parent, const TranslatableString &title, int type=0, int flags=wxDEFAULT_DIALOG_STYLE, int additionalButtons=0)
Definition: EffectUI.cpp:1350
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 1442 of file NoiseReduction.cpp.

1443{
1444 // If Isolate is chosen, disable controls that define
1445 // "what to do with noise" rather than "what is noise."
1446 // Else, enable them.
1447 // This does NOT include sensitivity, NEW or old, nor
1448 // the choice of window functions, size, or step.
1449 // The method choice is not included, because it affects
1450 // which sensitivity slider is operative, and that is part
1451 // of what defines noise.
1452
1453 static const int toDisable[] = {
1456
1459
1460#ifdef ATTACK_AND_RELEASE
1461 ID_ATTACK_TIME_SLIDER,
1462 ID_ATTACK_TIME_TEXT,
1463
1464 ID_RELEASE_TIME_SLIDER,
1465 ID_RELEASE_TIME_TEXT,
1466#endif
1467 };
1468 static const auto nToDisable = sizeof(toDisable) / sizeof(toDisable[0]);
1469
1470 bool bIsolating =
1471#ifdef ISOLATE_CHOICE
1472 mKeepNoise->GetValue();
1473#else
1474 false;
1475#endif
1476 for (auto ii = nToDisable; ii--;)
1477 wxWindow::FindWindowById(toDisable[ii], this)->Enable(!bIsolating);
1478}
@ 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 374 of file NoiseReduction.cpp.

375 { return mTempSettings; }

References mTempSettings.

Referenced by EffectNoiseReduction::Settings::PromptUser().

Here is the caller graph for this function:

◆ OnCancel()

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

Definition at line 1553 of file NoiseReduction.cpp.

1554{
1555 EndModal(0);
1556}

◆ OnGetProfile()

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

Definition at line 1494 of file NoiseReduction.cpp.

1495{
1496 // Project has not be changed so skip pushing state
1498
1500 return;
1501
1502 // Return code distinguishes this first step from the actual effect
1503 EndModal(1);
1504}
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 1558 of file NoiseReduction.cpp.

1559{
1560 HelpSystem::ShowHelp(this, "Noise_Reduction", true);
1561}
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

◆ OnPreview()

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

Reimplemented from EffectDialog.

Definition at line 1529 of file NoiseReduction.cpp.

1530{
1532 return;
1533
1534 // Save & restore parameters around Preview, because we didn't do OK.
1535 auto cleanup = valueRestorer( *m_pSettings );
1537 m_pSettings->mDoProfile = false;
1538
1540 // Don't need any UI updates for preview
1541 {},
1542 false);
1543}
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:252

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 1545 of file NoiseReduction.cpp.

1546{
1548 return;
1549
1550 EndModal(2);
1551}

References StatefulEffectUIServices::TransferDataFromWindow().

Here is the call graph for this function:

◆ OnSlider()

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

Definition at line 1757 of file NoiseReduction.cpp.

1758{
1759 int id = event.GetId();
1760 int idx = (id - FIRST_SLIDER) / 2;
1761 const ControlInfo &info = controlInfo()[idx];
1762 wxSlider* slider =
1763 static_cast<wxSlider*>(wxWindow::FindWindowById(id, this));
1764 wxTextCtrl* text =
1765 static_cast<wxTextCtrl*>(wxWindow::FindWindowById(id + 1, this));
1766 double &field = mTempSettings.*(info.field);
1767
1768 field = info.Value(slider->GetValue());
1769 text->SetValue(info.Text(field));
1770}
#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 1742 of file NoiseReduction.cpp.

1743{
1744 int id = event.GetId();
1745 int idx = (id - FIRST_SLIDER - 1) / 2;
1746 const ControlInfo &info = controlInfo()[idx];
1747 wxTextCtrl* text =
1748 static_cast<wxTextCtrl*>(wxWindow::FindWindowById(id, this));
1749 wxSlider* slider =
1750 static_cast<wxSlider*>(wxWindow::FindWindowById(id - 1, this));
1751 double &field = mTempSettings.*(info.field);
1752
1753 text->GetValue().ToDouble(&field);
1754 slider->SetValue(info.SliderSetting(field));
1755}

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 1563 of file NoiseReduction.cpp.

1564{
1565 S.StartStatic(XO("Step 1"));
1566 {
1567 S.AddVariableText(XO(
1568"Select a few seconds of just noise so Audacity knows what to filter out,\nthen click Get Noise Profile:"));
1569 //m_pButton_GetProfile =
1570 S.Id(ID_BUTTON_GETPROFILE).AddButton(XXO("&Get Noise Profile"));
1571 }
1572 S.EndStatic();
1573
1574 S.StartStatic(XO("Step 2"));
1575 {
1576 S.AddVariableText(XO(
1577"Select all of the audio you want filtered, choose how much noise you want\nfiltered out, and then click 'OK' to reduce noise.\n"));
1578
1579 S.StartMultiColumn(3, wxEXPAND);
1580 S.SetStretchyCol(2);
1581 {
1582 for (int id = FIRST_SLIDER; id < END_OF_BASIC_SLIDERS; id += 2) {
1583 const ControlInfo &info = controlInfo()[(id - FIRST_SLIDER) / 2];
1584 info.CreateControls(id, S);
1585 }
1586 }
1587 S.EndMultiColumn();
1588
1589 S.StartMultiColumn(
1590 2
1591#ifdef RESIDUE_CHOICE
1592 +1
1593#endif
1594#ifdef ISOLATE_CHOICE
1595 +1
1596#endif
1597 ,
1598 wxALIGN_CENTER_HORIZONTAL);
1599 {
1600 S.AddPrompt(XXO("Noise:"));
1602 /* i18n-hint: Translate differently from "Residue" ! */
1603 .AddRadioButton(XXO("Re&duce"));
1604#ifdef ISOLATE_CHOICE
1605 mKeepNoise = S.Id(ID_RADIOBUTTON_KEEPNOISE)
1606 .AddRadioButtonToGroup(XXO("&Isolate"));
1607#endif
1608#ifdef RESIDUE_CHOICE
1610 /* i18n-hint: Means the difference between effect and original sound. Translate differently from "Reduce" ! */
1611 .AddRadioButtonToGroup(XXO("Resid&ue"));
1612#endif
1613 }
1614 S.EndMultiColumn();
1615 }
1616 S.EndStatic();
1617
1618
1619#ifdef ADVANCED_SETTINGS
1620 S.StartStatic(XO("Advanced Settings"));
1621 {
1622 S.StartMultiColumn(2);
1623 {
1624 S.TieChoice(XXO("&Window types:"),
1626 []{
1627 TranslatableStrings windowTypeChoices;
1628 for (size_t ii = 0; ii < WT_N_WINDOW_TYPES; ++ii)
1629 windowTypeChoices.push_back(windowTypesInfo[ii].name);
1630 return windowTypeChoices;
1631 }()
1632 );
1633
1634 S.TieChoice(XXO("Window si&ze:"),
1636 {
1637 XO("8") ,
1638 XO("16") ,
1639 XO("32") ,
1640 XO("64") ,
1641 XO("128") ,
1642 XO("256") ,
1643 XO("512") ,
1644 XO("1024") ,
1645 XO("2048 (default)") ,
1646 XO("4096") ,
1647 XO("8192") ,
1648 XO("16384") ,
1649 }
1650 );
1651
1652 S.TieChoice(XXO("S&teps per window:"),
1654 {
1655 XO("2") ,
1656 XO("4 (default)") ,
1657 XO("8") ,
1658 XO("16") ,
1659 XO("32") ,
1660 XO("64") ,
1661 }
1662 );
1663
1664 S.Id(ID_CHOICE_METHOD)
1665 .TieChoice(XXO("Discrimination &method:"),
1667 []{
1668 TranslatableStrings methodChoices;
1669 auto nn = DM_N_METHODS;
1670#ifndef OLD_METHOD_AVAILABLE
1671 --nn;
1672#endif
1673 for (auto ii = 0; ii < nn; ++ii)
1674 methodChoices.push_back(discriminationMethodInfo[ii].name);
1675 return methodChoices;
1676 }());
1677 }
1678 S.EndMultiColumn();
1679
1680 S.StartMultiColumn(3, wxEXPAND);
1681 S.SetStretchyCol(2);
1682 {
1683 for (int id = END_OF_BASIC_SLIDERS; id < END_OF_ADVANCED_SLIDERS; id += 2) {
1684 const ControlInfo &info = controlInfo()[(id - FIRST_SLIDER) / 2];
1685 info.CreateControls(id, S);
1686 }
1687 }
1688 S.EndMultiColumn();
1689 }
1690 S.EndStatic();
1691#endif
1692}
XXO("&Cut/Copy/Paste Toolbar")
#define RESIDUE_CHOICE
@ ID_BUTTON_GETPROFILE
@ END_OF_BASIC_SLIDERS
@ ID_RADIOBUTTON_RESIDUE
@ ID_RADIOBUTTON_KEEPSIGNAL
#define S(N)
Definition: ToChars.cpp:64
std::vector< TranslatableString > TranslatableStrings
const struct anonymous_namespace{NoiseReduction.cpp}::DiscriminationMethodInfo discriminationMethodInfo[DM_N_METHODS]
const struct anonymous_namespace{NoiseReduction.cpp}::WindowTypesInfo windowTypesInfo[WT_N_WINDOW_TYPES]

References anonymous_namespace{NoiseReduction.cpp}::controlInfo(), anonymous_namespace{NoiseReduction.cpp}::ControlInfo::CreateControls(), anonymous_namespace{NoiseReduction.cpp}::discriminationMethodInfo, anonymous_namespace{NoiseReduction.cpp}::DM_N_METHODS, END_OF_BASIC_SLIDERS, FIRST_SLIDER, ID_BUTTON_GETPROFILE, ID_RADIOBUTTON_KEEPSIGNAL, ID_RADIOBUTTON_RESIDUE, anonymous_namespace{NoiseReduction.cpp}::DiscriminationMethodInfo::name, anonymous_namespace{NoiseReduction.cpp}::WindowTypesInfo::name, RESIDUE_CHOICE, S, anonymous_namespace{NoiseReduction.cpp}::windowTypesInfo, anonymous_namespace{NoiseReduction.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 1728 of file NoiseReduction.cpp.

1729{
1730 if( !wxWindow::Validate() )
1731 return false;
1732 // Do the choice controls:
1734 return false;
1735
1736 wxCommandEvent dummy;
1738
1740}
bool TransferDataFromWindow() override
Definition: EffectUI.cpp:1405
void OnNoiseReductionChoice(wxCommandEvent &event)
bool Validate(EffectNoiseReduction *effect) const

References EffectDialog::TransferDataFromWindow().

Here is the call graph for this function:

◆ TransferDataToWindow()

bool EffectNoiseReduction::Dialog::TransferDataToWindow ( )
override

Definition at line 1694 of file NoiseReduction.cpp.

1695{
1696 // Do the choice controls:
1698 return false;
1699
1700 for (int id = FIRST_SLIDER; id < END_OF_SLIDERS; id += 2) {
1701 wxSlider* slider =
1702 static_cast<wxSlider*>(wxWindow::FindWindowById(id, this));
1703 wxTextCtrl* text =
1704 static_cast<wxTextCtrl*>(wxWindow::FindWindowById(id + 1, this));
1705 const ControlInfo &info = controlInfo()[(id - FIRST_SLIDER) / 2];
1706 const double field = mTempSettings.*(info.field);
1707 text->SetValue(info.Text(field));
1708 slider->SetValue(info.SliderSetting(field));
1709 }
1710
1712#ifdef ISOLATE_CHOICE
1713 mKeepNoise->SetValue(mTempSettings.mNoiseReductionChoice == NRC_ISOLATE_NOISE);
1714#endif
1715#ifdef RESIDUE_CHOICE
1717#endif
1718
1719 // Set the enabled states of controls
1721#ifdef ADVANCED_SETTINGS
1722 EnableDisableSensitivityControls();
1723#endif
1724
1725 return true;
1726}
@ END_OF_SLIDERS
bool TransferDataToWindow() override
Definition: EffectUI.cpp:1397

References anonymous_namespace{NoiseReduction.cpp}::controlInfo(), END_OF_SLIDERS, field, FIRST_SLIDER, anonymous_namespace{NoiseReduction.cpp}::NRC_ISOLATE_NOISE, anonymous_namespace{NoiseReduction.cpp}::NRC_LEAVE_RESIDUE, anonymous_namespace{NoiseReduction.cpp}::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 400 of file NoiseReduction.cpp.

◆ m_pSettings

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

Definition at line 403 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 402 of file NoiseReduction.cpp.

◆ mbAllowTwiddleSettings

bool EffectNoiseReduction::Dialog::mbAllowTwiddleSettings
private

Definition at line 407 of file NoiseReduction.cpp.

◆ mbHasProfile

bool EffectNoiseReduction::Dialog::mbHasProfile
private

Definition at line 406 of file NoiseReduction.cpp.

◆ mKeepSignal

wxRadioButton* EffectNoiseReduction::Dialog::mKeepSignal
private

Definition at line 410 of file NoiseReduction.cpp.

◆ mResidue

wxRadioButton* EffectNoiseReduction::Dialog::mResidue
private

Definition at line 415 of file NoiseReduction.cpp.

◆ mTempSettings

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

Definition at line 404 of file NoiseReduction.cpp.

Referenced by GetTempSettings().


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