Audacity  2.2.2
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:
EffectDialog wxDialogWrapper wxTabTraversalWrapper< wxDialog >

Public Member Functions

 Dialog (EffectNoiseReduction *effect, 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 wxString &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 OnOk (wxCommandEvent &evt)
 
- Public Member Functions inherited from wxDialogWrapper
 wxDialogWrapper ()
 
 wxDialogWrapper (wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const wxString &name=_("Dialog"))
 
bool Create (wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const wxString &name=_("Dialog"))
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxDialog >
 wxTabTraversalWrapper (Args &&...args)
 

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
 
EffectNoiseReduction::Settingsm_pSettings
 
EffectNoiseReduction::Settings mTempSettings
 
bool mbHasProfile
 
bool mbAllowTwiddleSettings
 
wxRadioButton * mKeepSignal
 
wxRadioButton * mResidue
 

Detailed Description

Dialog used with EffectNoiseReduction.

Definition at line 360 of file NoiseReduction.cpp.

Constructor & Destructor Documentation

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

Definition at line 1541 of file NoiseReduction.cpp.

References EffectDialog::Init().

1544  : EffectDialog( parent, _("Noise Reduction"), EffectTypeProcess,wxDEFAULT_DIALOG_STYLE, eHelpButton )
1545  , m_pEffect(effect)
1546  , m_pSettings(settings) // point to
1547  , mTempSettings(*settings) // copy
1548  , mbHasProfile(bHasProfile)
1549  , mbAllowTwiddleSettings(bAllowTwiddleSettings)
1550  // NULL out the control members until the controls are created.
1551  , mKeepSignal(NULL)
1552 #ifdef ISOLATE_CHOICE
1553  , mKeepNoise(NULL)
1554 #endif
1555 #ifdef RESIDUE_CHOICE
1556  , mResidue(NULL)
1557 #endif
1558 {
1560 
1561  wxButton *const pButtonPreview =
1562  (wxButton *)wxWindow::FindWindowById(ID_EFFECT_PREVIEW, this);
1563  wxButton *const pButtonReduceNoise =
1564  (wxButton *)wxWindow::FindWindowById(wxID_OK, this);
1565 
1567  pButtonPreview->Enable(!mbAllowTwiddleSettings);
1568  pButtonReduceNoise->SetFocus();
1569  }
1570  else {
1571  pButtonPreview->Enable(false);
1572  pButtonReduceNoise->Enable(false);
1573  }
1574 }
void Init()
Definition: Effect.cpp:2671
EffectNoiseReduction::Settings mTempSettings
#define ID_EFFECT_PREVIEW
Definition: Effect.h:557
EffectNoiseReduction * m_pEffect
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
EffectDialog(wxWindow *parent, const wxString &title, int type=0, int flags=wxDEFAULT_DIALOG_STYLE, int additionalButtons=0)
Definition: Effect.cpp:2660
EffectNoiseReduction::Settings * m_pSettings

Member Function Documentation

void EffectNoiseReduction::Dialog::DisableControlsIfIsolating ( )
private

Definition at line 1576 of file NoiseReduction.cpp.

References ID_FREQ_SLIDER, ID_FREQ_TEXT, ID_GAIN_SLIDER, and ID_GAIN_TEXT.

1577 {
1578  // If Isolate is chosen, disable controls that define
1579  // "what to do with noise" rather than "what is noise."
1580  // Else, enable them.
1581  // This does NOT include sensitivity, NEW or old, nor
1582  // the choice of window functions, size, or step.
1583  // The method choice is not included, because it affects
1584  // which sensitivity slider is operative, and that is part
1585  // of what defines noise.
1586 
1587  static const int toDisable[] = {
1589  ID_GAIN_TEXT,
1590 
1592  ID_FREQ_TEXT,
1593 
1594 #ifdef ATTACK_AND_RELEASE
1595  ID_ATTACK_TIME_SLIDER,
1596  ID_ATTACK_TIME_TEXT,
1597 
1598  ID_RELEASE_TIME_SLIDER,
1599  ID_RELEASE_TIME_TEXT,
1600 #endif
1601  };
1602  static const int nToDisable = sizeof(toDisable) / sizeof(toDisable[0]);
1603 
1604  bool bIsolating =
1605 #ifdef ISOLATE_CHOICE
1606  mKeepNoise->GetValue();
1607 #else
1608  false;
1609 #endif
1610  for (int ii = nToDisable; ii--;)
1611  wxWindow::FindWindowById(toDisable[ii], this)->Enable(!bIsolating);
1612 }
const Settings& EffectNoiseReduction::Dialog::GetTempSettings ( ) const
inline

Definition at line 374 of file NoiseReduction.cpp.

References mTempSettings.

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

375  { return mTempSettings; }
EffectNoiseReduction::Settings mTempSettings
void EffectNoiseReduction::Dialog::OnCancel ( wxCommandEvent &  event)
private

Definition at line 1684 of file NoiseReduction.cpp.

1685 {
1686  EndModal(0);
1687 }
void EffectNoiseReduction::Dialog::OnGetProfile ( wxCommandEvent &  event)
private

Definition at line 1628 of file NoiseReduction.cpp.

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

1629 {
1630  // Project has not be changed so skip pushing state
1632 
1633  if (!TransferDataFromWindow())
1634  return;
1635 
1636  // Return code distinguishes this first step from the actual effect
1637  EndModal(1);
1638 }
static EffectManager & Get()
void SetSkipStateFlag(bool flag)
bool TransferDataFromWindow() override
void EffectNoiseReduction::Dialog::OnHelp ( wxCommandEvent &  event)
private

Definition at line 1689 of file NoiseReduction.cpp.

References HelpSystem::ShowHelp().

1690 {
1691  HelpSystem::ShowHelp(this, "Noise_Reduction", true);
1692 }
static void ShowHelp(wxWindow *parent, const wxString &localFileName, const wxString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
Definition: HelpSystem.cpp:194
void EffectNoiseReduction::Dialog::OnNoiseReductionChoice ( wxCommandEvent &  event)
private

Definition at line 1641 of file NoiseReduction.cpp.

References if(), and RESIDUE_CHOICE.

1642 {
1643  if (mKeepSignal->GetValue())
1644  mTempSettings.mNoiseReductionChoice = NRC_REDUCE_NOISE;
1645 #ifdef ISOLATE_CHOICE
1646  else if (mKeepNoise->GetValue())
1647  mTempSettings.mNoiseReductionChoice = NRC_ISOLATE_NOISE;
1648 #endif
1649 #ifdef RESIDUE_CHOICE
1650  else
1651  mTempSettings.mNoiseReductionChoice = NRC_LEAVE_RESIDUE;
1652 #endif
1654 }
EffectNoiseReduction::Settings mTempSettings
if(pTrack &&pTrack->GetDisplay()!=WaveTrack::Spectrum)
#define RESIDUE_CHOICE
void EffectNoiseReduction::Dialog::OnPreview ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from EffectDialog.

Definition at line 1663 of file NoiseReduction.cpp.

References Effect::TransferDataFromWindow(), and valueRestorer().

1664 {
1665  if (!TransferDataFromWindow())
1666  return;
1667 
1668  // Save & restore parameters around Preview, because we didn't do OK.
1669  auto cleanup = valueRestorer( *m_pSettings );
1671  m_pSettings->mDoProfile = false;
1672 
1673  m_pEffect->Preview();
1674 }
EffectNoiseReduction::Settings mTempSettings
void Preview() override
Definition: Effect.cpp:771
EffectNoiseReduction * m_pEffect
ValueRestorer< T > valueRestorer(T &var)
Definition: MemoryX.h:494
bool TransferDataFromWindow() override
EffectNoiseReduction::Settings * m_pSettings
void EffectNoiseReduction::Dialog::OnReduceNoise ( wxCommandEvent &  event)
private

Definition at line 1676 of file NoiseReduction.cpp.

References Effect::TransferDataFromWindow().

1677 {
1678  if (!TransferDataFromWindow())
1679  return;
1680 
1681  EndModal(2);
1682 }
bool TransferDataFromWindow() override
void EffectNoiseReduction::Dialog::OnSlider ( wxCommandEvent &  event)
private

Definition at line 1887 of file NoiseReduction.cpp.

References FIRST_SLIDER.

1888 {
1889  int id = event.GetId();
1890  int idx = (id - FIRST_SLIDER) / 2;
1891  const ControlInfo &info = controlInfo()[idx];
1892  wxSlider* slider =
1893  static_cast<wxSlider*>(wxWindow::FindWindowById(id, this));
1894  wxTextCtrl* text =
1895  static_cast<wxTextCtrl*>(wxWindow::FindWindowById(id + 1, this));
1896  double &field = mTempSettings.*(info.field);
1897 
1898  field = info.Value(slider->GetValue());
1899  text->SetValue(info.Text(field));
1900 }
EffectNoiseReduction::Settings mTempSettings
void EffectNoiseReduction::Dialog::OnText ( wxCommandEvent &  event)
private

Definition at line 1872 of file NoiseReduction.cpp.

References FIRST_SLIDER.

1873 {
1874  int id = event.GetId();
1875  int idx = (id - FIRST_SLIDER - 1) / 2;
1876  const ControlInfo &info = controlInfo()[idx];
1877  wxTextCtrl* text =
1878  static_cast<wxTextCtrl*>(wxWindow::FindWindowById(id, this));
1879  wxSlider* slider =
1880  static_cast<wxSlider*>(wxWindow::FindWindowById(id - 1, this));
1881  double &field = mTempSettings.*(info.field);
1882 
1883  text->GetValue().ToDouble(&field);
1884  slider->SetValue(info.SliderSetting(field));
1885 }
EffectNoiseReduction::Settings mTempSettings
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 1694 of file NoiseReduction.cpp.

References _(), ShuttleGuiBase::AddButton(), ShuttleGuiBase::AddPrompt(), ShuttleGuiBase::AddRadioButton(), ShuttleGuiBase::AddRadioButtonToGroup(), ShuttleGuiBase::AddVariableText(), END_OF_BASIC_SLIDERS, ShuttleGuiBase::EndMultiColumn(), ShuttleGuiBase::EndStatic(), FIRST_SLIDER, ShuttleGui::Id(), ID_RADIOBUTTON_RESIDUE, RESIDUE_CHOICE, ShuttleGuiBase::SetStretchyCol(), ShuttleGuiBase::StartMultiColumn(), ShuttleGuiBase::StartStatic(), and ShuttleGuiBase::TieChoice().

1695 {
1696  S.StartStatic(_("Step 1"));
1697  {
1698  S.AddVariableText(_(
1699  "Select a few seconds of just noise so Audacity knows what to filter out,\nthen click Get Noise Profile:"));
1700  //m_pButton_GetProfile =
1701  S.Id(ID_BUTTON_GETPROFILE).AddButton(_("&Get Noise Profile"));
1702  }
1703  S.EndStatic();
1704 
1705  S.StartStatic(_("Step 2"));
1706  {
1707  S.AddVariableText(_(
1708  "Select all of the audio you want filtered, choose how much noise you want\nfiltered out, and then click 'OK' to reduce noise.\n"));
1709 
1710  S.StartMultiColumn(3, wxEXPAND);
1711  S.SetStretchyCol(2);
1712  {
1713  for (int id = FIRST_SLIDER; id < END_OF_BASIC_SLIDERS; id += 2) {
1714  const ControlInfo &info = controlInfo()[(id - FIRST_SLIDER) / 2];
1715  info.CreateControls(id, S);
1716  }
1717  }
1718  S.EndMultiColumn();
1719 
1720  S.StartMultiColumn(
1721  2
1722 #ifdef RESIDUE_CHOICE
1723  +1
1724 #endif
1725 #ifdef ISOLATE_CHOICE
1726  +1
1727 #endif
1728  ,
1729  wxALIGN_CENTER_HORIZONTAL);
1730  {
1731  S.AddPrompt(_("Noise:"));
1733  .AddRadioButton(_("Re&duce")); /* i18n-hint: Translate differently from "Residue" ! */
1734 #ifdef ISOLATE_CHOICE
1735  mKeepNoise = S.Id(ID_RADIOBUTTON_KEEPNOISE)
1736  .AddRadioButtonToGroup(_("&Isolate"));
1737 #endif
1738 #ifdef RESIDUE_CHOICE
1740  .AddRadioButtonToGroup(_("Resid&ue")); /* i18n-hint: Means the difference between effect and original sound. Translate differently from "Reduce" ! */
1741 #endif
1742  }
1743  S.EndMultiColumn();
1744  }
1745  S.EndStatic();
1746 
1747 
1748 #ifdef ADVANCED_SETTINGS
1749  S.StartStatic(_("Advanced Settings"));
1750  {
1751  S.StartMultiColumn(2);
1752  {
1753  {
1754  wxArrayString windowTypeChoices;
1755  for (int ii = 0; ii < WT_N_WINDOW_TYPES; ++ii)
1756  windowTypeChoices.Add(windowTypesInfo[ii].name);
1757  S.TieChoice(_("&Window types") + wxString(wxT(":")),
1759  &windowTypeChoices);
1760  }
1761 
1762  {
1763  wxArrayString windowSizeChoices;
1764  windowSizeChoices.Add(_("8"));
1765  windowSizeChoices.Add(_("16"));
1766  windowSizeChoices.Add(_("32"));
1767  windowSizeChoices.Add(_("64"));
1768  windowSizeChoices.Add(_("128"));
1769  windowSizeChoices.Add(_("256"));
1770  windowSizeChoices.Add(_("512"));
1771  windowSizeChoices.Add(_("1024"));
1772  windowSizeChoices.Add(_("2048 (default)"));
1773  windowSizeChoices.Add(_("4096"));
1774  windowSizeChoices.Add(_("8192"));
1775  windowSizeChoices.Add(_("16384"));
1776  S.TieChoice(_("Window si&ze") + wxString(wxT(":")),
1778  &windowSizeChoices);
1779  }
1780 
1781  {
1782  wxArrayString stepsPerWindowChoices;
1783  stepsPerWindowChoices.Add(_("2"));
1784  stepsPerWindowChoices.Add(_("4 (default)"));
1785  stepsPerWindowChoices.Add(_("8"));
1786  stepsPerWindowChoices.Add(_("16"));
1787  stepsPerWindowChoices.Add(_("32"));
1788  stepsPerWindowChoices.Add(_("64"));
1789  S.TieChoice(_("S&teps per window") + wxString(wxT(":")),
1791  &stepsPerWindowChoices);
1792  }
1793 
1794  S.Id(ID_CHOICE_METHOD);
1795  {
1796  wxArrayString methodChoices;
1797  int nn = DM_N_METHODS;
1798 #ifndef OLD_METHOD_AVAILABLE
1799  --nn;
1800 #endif
1801  for (int ii = 0; ii < nn; ++ii)
1802  methodChoices.Add(discriminationMethodInfo[ii].name);
1803  S.TieChoice(_("Discrimination &method") + wxString(wxT(":")),
1805  &methodChoices);
1806  }
1807  }
1808  S.EndMultiColumn();
1809 
1810  S.StartMultiColumn(3, wxEXPAND);
1811  S.SetStretchyCol(2);
1812  {
1813  for (int id = END_OF_BASIC_SLIDERS; id < END_OF_ADVANCED_SLIDERS; id += 2) {
1814  const ControlInfo &info = controlInfo[(id - FIRST_SLIDER) / 2];
1815  info.CreateControls(id, S);
1816  }
1817  }
1818  S.EndMultiColumn();
1819  }
1820  S.EndStatic();
1821 #endif
1822 }
wxChoice * TieChoice(const wxString &Prompt, WrappedType &WrappedRef, const wxArrayString *pChoices)
void EndMultiColumn()
EffectNoiseReduction::Settings mTempSettings
void AddPrompt(const wxString &Prompt)
Right aligned text string.
Definition: ShuttleGui.cpp:239
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
ShuttleGui & Id(int id)
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
wxStaticText * AddVariableText(const wxString &Str, bool bCenter=false, int PositionFlags=0)
Definition: ShuttleGui.cpp:414
wxStaticBox * StartStatic(const wxString &Str, int iProp=0)
Definition: ShuttleGui.cpp:763
wxRadioButton * AddRadioButtonToGroup(const wxString &Prompt)
Definition: ShuttleGui.cpp:484
#define RESIDUE_CHOICE
wxButton * AddButton(const wxString &Text, int PositionFlags=wxALIGN_CENTRE)
Definition: ShuttleGui.cpp:341
void SetStretchyCol(int i)
Used to modify an already placed FlexGridSizer to make a column stretchy.
Definition: ShuttleGui.cpp:203
wxRadioButton * AddRadioButton(const wxString &Prompt)
Definition: ShuttleGui.cpp:468
bool EffectNoiseReduction::Dialog::TransferDataFromWindow ( )
override

Definition at line 1858 of file NoiseReduction.cpp.

References EffectDialog::TransferDataFromWindow().

1859 {
1860  if( !wxWindow::Validate() )
1861  return false;
1862  // Do the choice controls:
1864  return false;
1865 
1866  wxCommandEvent dummy;
1867  OnNoiseReductionChoice(dummy);
1868 
1870 }
bool Validate(EffectNoiseReduction *effect) const
EffectNoiseReduction::Settings mTempSettings
bool TransferDataFromWindow() override
Definition: Effect.cpp:2715
void OnNoiseReductionChoice(wxCommandEvent &event)
EffectNoiseReduction * m_pEffect
bool EffectNoiseReduction::Dialog::TransferDataToWindow ( )
override

Definition at line 1824 of file NoiseReduction.cpp.

References END_OF_SLIDERS, FIRST_SLIDER, and EffectDialog::TransferDataToWindow().

1825 {
1826  // Do the choice controls:
1828  return false;
1829 
1830  for (int id = FIRST_SLIDER; id < END_OF_SLIDERS; id += 2) {
1831  wxSlider* slider =
1832  static_cast<wxSlider*>(wxWindow::FindWindowById(id, this));
1833  wxTextCtrl* text =
1834  static_cast<wxTextCtrl*>(wxWindow::FindWindowById(id + 1, this));
1835  const ControlInfo &info = controlInfo()[(id - FIRST_SLIDER) / 2];
1836  const double field = mTempSettings.*(info.field);
1837  text->SetValue(info.Text(field));
1838  slider->SetValue(info.SliderSetting(field));
1839  }
1840 
1841  mKeepSignal->SetValue(mTempSettings.mNoiseReductionChoice == NRC_REDUCE_NOISE);
1842 #ifdef ISOLATE_CHOICE
1843  mKeepNoise->SetValue(mTempSettings.mNoiseReductionChoice == NRC_ISOLATE_NOISE);
1844 #endif
1845 #ifdef RESIDUE_CHOICE
1846  mResidue->SetValue(mTempSettings.mNoiseReductionChoice == NRC_LEAVE_RESIDUE);
1847 #endif
1848 
1849  // Set the enabled states of controls
1851 #ifdef ADVANCED_SETTINGS
1852  EnableDisableSensitivityControls();
1853 #endif
1854 
1855  return true;
1856 }
EffectNoiseReduction::Settings mTempSettings
bool TransferDataToWindow() override
Definition: Effect.cpp:2707

Member Data Documentation

EffectNoiseReduction* EffectNoiseReduction::Dialog::m_pEffect
private

Definition at line 400 of file NoiseReduction.cpp.

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

Definition at line 401 of file NoiseReduction.cpp.

bool EffectNoiseReduction::Dialog::mbAllowTwiddleSettings
private

Definition at line 405 of file NoiseReduction.cpp.

bool EffectNoiseReduction::Dialog::mbHasProfile
private

Definition at line 404 of file NoiseReduction.cpp.

wxRadioButton* EffectNoiseReduction::Dialog::mKeepSignal
private

Definition at line 408 of file NoiseReduction.cpp.

wxRadioButton* EffectNoiseReduction::Dialog::mResidue
private

Definition at line 413 of file NoiseReduction.cpp.

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

Definition at line 402 of file NoiseReduction.cpp.

Referenced by GetTempSettings().


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