![]() |
Audacity 3.2.0
|
A two-pass effect to reduce background noise. More...
#include <NoiseReduction.h>
Classes | |
class | Dialog |
Dialog used with EffectNoiseReduction. More... | |
class | Settings |
class | Statistics |
class | Worker |
Public Member Functions | |
EffectNoiseReduction () | |
virtual | ~EffectNoiseReduction () |
ComponentInterfaceSymbol | GetSymbol () const override |
TranslatableString | GetDescription () const override |
EffectType | GetType () const override |
Type determines how it behaves. More... | |
int | ShowHostInterface (wxWindow &parent, const EffectDialogFactory &factory, std::shared_ptr< EffectInstance > &pInstance, EffectSettingsAccess &access, bool forceModal=false) override |
bool | Process (EffectInstance &instance, EffectSettings &settings) override |
Actually do the effect here. More... | |
bool | TrackProgress (int whichTrack, double frac, const TranslatableString &={}) const |
![]() | |
std::shared_ptr< EffectInstance > | MakeInstance () const override |
Make an object maintaining short-term state of an Effect. More... | |
![]() | |
virtual bool | Init () |
Call once to set up state for whole list of tracks to be processed. More... | |
virtual bool | Process (EffectInstance &instance, EffectSettings &settings)=0 |
Actually do the effect here. More... | |
virtual bool | RealtimeInitialize (EffectSettings &settings, double sampleRate) |
virtual bool | RealtimeAddProcessor (EffectSettings &settings, unsigned numChannels, float sampleRate) |
virtual bool | RealtimeSuspend () |
virtual bool | RealtimeResume () |
virtual bool | RealtimeProcessStart (EffectSettings &settings) |
settings are possibly changed, since last call, by an asynchronous dialog More... | |
virtual size_t | RealtimeProcess (size_t group, EffectSettings &settings, const float *const *inBuf, float *const *outBuf, size_t numSamples) |
virtual bool | RealtimeProcessEnd (EffectSettings &settings) noexcept |
settings can be updated to let a dialog change appearance at idle More... | |
virtual bool | RealtimeFinalize (EffectSettings &settings) noexcept |
virtual size_t | SetBlockSize (size_t maxBlockSize) |
virtual size_t | GetBlockSize () const |
![]() | |
Effect () | |
virtual | ~Effect () |
PluginPath | GetPath () const override |
bool | VisitSettings (SettingsVisitor &visitor, EffectSettings &settings) override |
bool | VisitSettings (ConstSettingsVisitor &visitor, const EffectSettings &settings) const override |
ComponentInterfaceSymbol | GetSymbol () const override |
VendorSymbol | GetVendor () const override |
wxString | GetVersion () const override |
TranslatableString | GetDescription () const override |
EffectType | GetType () const override |
Type determines how it behaves. More... | |
EffectFamilySymbol | GetFamily () const override |
Report identifier and user-visible name of the effect protocol. More... | |
bool | IsInteractive () const override |
Whether the effect needs a dialog for entry of settings. More... | |
bool | IsDefault () const override |
Whether the effect sorts "above the line" in the menus. More... | |
RealtimeSince | RealtimeSupport () const override |
Since which version of Audacity has the effect supported realtime? More... | |
bool | SupportsAutomation () const override |
Whether the effect has any automatable controls. More... | |
bool | SaveSettings (const EffectSettings &settings, CommandParameters &parms) const override |
Store settings as keys and values. More... | |
bool | LoadSettings (const CommandParameters &parms, EffectSettings &settings) const override |
Restore settings from keys and values. More... | |
bool | LoadUserPreset (const RegistryPath &name, EffectSettings &settings) const override |
Change settings to a user-named preset. More... | |
bool | SaveUserPreset (const RegistryPath &name, const EffectSettings &settings) const override |
Save settings in the configuration file as a user-named preset. More... | |
RegistryPaths | GetFactoryPresets () const override |
Report names of factory presets. More... | |
bool | LoadFactoryPreset (int id, EffectSettings &settings) const override |
Change settings to the preset whose name is GetFactoryPresets()[id] More... | |
bool | LoadFactoryDefaults (EffectSettings &settings) const override |
Change settings back to "factory default". More... | |
unsigned | GetAudioInCount () const override |
How many input buffers to allocate at once. More... | |
unsigned | GetAudioOutCount () const override |
How many output buffers to allocate at once. More... | |
virtual const EffectParameterMethods & | Parameters () const |
int | ShowClientInterface (wxWindow &parent, wxDialog &dialog, bool forceModal=false) override |
std::unique_ptr< EffectUIValidator > | PopulateUI (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access) override |
Adds controls to a panel that is given as the parent window of S More... | |
bool | IsGraphicalUI () override |
bool | ValidateUI (EffectSettings &) override |
bool | CloseUI () override |
bool | CanExportPresets () override |
void | ExportPresets (const EffectSettings &settings) const override |
void | ImportPresets (EffectSettings &settings) override |
bool | HasOptions () override |
void | ShowOptions () override |
const EffectSettingsManager & | GetDefinition () const override |
virtual NumericFormatSymbol | GetSelectionFormat () |
int | ShowHostInterface (wxWindow &parent, const EffectDialogFactory &factory, std::shared_ptr< EffectInstance > &pInstance, EffectSettingsAccess &access, bool forceModal=false) override |
Usually applies factory to self and given access. More... | |
bool | SaveSettingsAsString (const EffectSettings &settings, wxString &parms) const override |
bool | LoadSettingsFromString (const wxString &parms, EffectSettings &settings) const override |
bool | IsBatchProcessing () const override |
void | SetBatchProcessing () override |
void | UnsetBatchProcessing () override |
bool | TransferDataToWindow (const EffectSettings &settings) override |
Update controls for the settings. More... | |
bool | TransferDataFromWindow (EffectSettings &settings) override |
Update the given settings from controls. More... | |
unsigned | TestUIFlags (unsigned mask) |
bool | Delegate (Effect &delegate, EffectSettings &settings) |
Re-invoke DoEffect on another Effect object that implements the work. More... | |
int | MessageBox (const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={}) const |
bool | EnableApply (bool enable=true) |
wxWindow * | GetUIParent () |
![]() | |
EffectBase () | |
~EffectBase () override | |
![]() | |
virtual | ~EffectUIClientInterface () |
virtual int | ShowClientInterface (wxWindow &parent, wxDialog &dialog, bool forceModal=false)=0 |
virtual bool | IsGraphicalUI ()=0 |
virtual std::unique_ptr< EffectUIValidator > | PopulateUI (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access)=0 |
Adds controls to a panel that is given as the parent window of S More... | |
virtual bool | CanExportPresets ()=0 |
virtual void | ExportPresets (const EffectSettings &settings) const =0 |
virtual void | ImportPresets (EffectSettings &settings)=0 |
virtual bool | HasOptions ()=0 |
virtual void | ShowOptions ()=0 |
![]() | |
EffectPlugin & | operator= (EffectPlugin &)=delete |
virtual | ~EffectPlugin () |
virtual const EffectSettingsManager & | GetDefinition () const =0 |
virtual int | ShowHostInterface (wxWindow &parent, const EffectDialogFactory &factory, std::shared_ptr< EffectInstance > &pInstance, EffectSettingsAccess &access, bool forceModal=false)=0 |
Usually applies factory to self and given access. More... | |
virtual void | Preview (EffectSettingsAccess &access, bool dryOnly)=0 |
virtual bool | SaveSettingsAsString (const EffectSettings &settings, wxString &parms) const =0 |
virtual bool | LoadSettingsFromString (const wxString &parms, EffectSettings &settings) const =0 |
virtual bool | IsBatchProcessing () const =0 |
virtual void | SetBatchProcessing ()=0 |
virtual void | UnsetBatchProcessing ()=0 |
virtual bool | DoEffect (EffectSettings &settings, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, wxWindow *pParent=nullptr, const EffectDialogFactory &dialogFactory={}, const EffectSettingsAccessPtr &pAccess=nullptr)=0 |
Unfortunately complicated dual-use function. More... | |
virtual bool | TransferDataToWindow (const EffectSettings &settings)=0 |
Update controls for the settings. More... | |
virtual bool | TransferDataFromWindow (EffectSettings &settings)=0 |
Update the given settings from controls. More... | |
![]() | |
virtual | ~EffectInstanceFactory () |
virtual std::shared_ptr< EffectInstance > | MakeInstance () const =0 |
Make an object maintaining short-term state of an Effect. More... | |
virtual unsigned | GetAudioInCount () const =0 |
How many input buffers to allocate at once. More... | |
virtual unsigned | GetAudioOutCount () const =0 |
How many output buffers to allocate at once. More... | |
virtual int | GetMidiInCount () const |
Function that has not yet found a use. More... | |
virtual int | GetMidiOutCount () const |
Function that has not yet found a use. More... | |
![]() | |
virtual | ~EffectSettingsManager () |
virtual bool | VisitSettings (SettingsVisitor &visitor, EffectSettings &settings) |
virtual bool | VisitSettings (ConstSettingsVisitor &visitor, const EffectSettings &settings) const |
virtual EffectSettings | MakeSettings () const |
virtual bool | CopySettingsContents (const EffectSettings &src, EffectSettings &dst) const |
Update one settings object from another. More... | |
![]() | |
virtual | ~EffectDefinitionInterface () |
virtual EffectType | GetType () const =0 |
Type determines how it behaves. More... | |
virtual EffectType | GetClassification () const |
Determines which menu it appears in; default same as GetType(). More... | |
virtual EffectFamilySymbol | GetFamily () const =0 |
Report identifier and user-visible name of the effect protocol. More... | |
virtual bool | IsInteractive () const =0 |
Whether the effect needs a dialog for entry of settings. More... | |
virtual bool | IsDefault () const =0 |
Whether the effect sorts "above the line" in the menus. More... | |
virtual RealtimeSince | RealtimeSupport () const =0 |
Since which version of Audacity has the effect supported realtime? More... | |
bool | SupportsRealtime () const |
virtual bool | SupportsAutomation () const =0 |
Whether the effect has any automatable controls. More... | |
virtual bool | EnablesDebug () const |
Whether the effect dialog should have a Debug button; default, always false. More... | |
virtual ManualPageID | ManualPage () const |
Name of a page in the Audacity alpha manual, default is empty. More... | |
virtual FilePath | HelpPage () const |
Fully qualified local help file name, default is empty. More... | |
virtual bool | IsHiddenFromMenus () const |
Default is false. More... | |
![]() | |
virtual | ~ComponentInterface () |
virtual PluginPath | GetPath () const =0 |
virtual ComponentInterfaceSymbol | GetSymbol () const =0 |
virtual VendorSymbol | GetVendor () const =0 |
virtual wxString | GetVersion () const =0 |
virtual TranslatableString | GetDescription () const =0 |
TranslatableString | GetName () const |
Static Public Attributes | |
static const ComponentInterfaceSymbol | Symbol { XO("Noise Reduction") } |
![]() | |
static const wxString | kUserPresetIdent = wxT("User Preset:") |
static const wxString | kFactoryPresetIdent = wxT("Factory Preset:") |
static const wxString | kCurrentSettingsIdent = wxT("<Current Settings>") |
static const wxString | kFactoryDefaultsIdent = wxT("<Factory Defaults>") |
Private Attributes | |
std::unique_ptr< Settings > | mSettings |
std::unique_ptr< Statistics > | mStatistics |
Friends | |
class | Dialog |
Additional Inherited Members | |
![]() | |
enum | : long { DefaultMessageBoxStyle = wxOK | wxCENTRE } |
![]() | |
using | EffectSettingsAccessPtr = std::shared_ptr< EffectSettingsAccess > |
![]() | |
enum class | RealtimeSince : unsigned { Never , Since_3_2 , Always } |
In which versions of Audacity was an effect realtime capable? More... | |
![]() | |
static Effect * | FetchParameters (Effect &e, EffectSettings &) |
static void | IncEffectCounter () |
![]() | |
static Identifier | GetSquashedName (const Identifier &ident) |
A utility that strips spaces and CamelCases a name. More... | |
![]() | |
bool | EnablePreview (bool enable=true) |
bool | CheckWhetherSkipEffect (const EffectSettings &settings) const override |
Default implementation returns false. More... | |
double | CalcPreviewInputLength (const EffectSettings &settings, double previewLength) const override |
Default implementation returns previewLength More... | |
virtual std::unique_ptr< EffectUIValidator > | PopulateOrExchange (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access) |
Add controls to effect panel; always succeeds. More... | |
bool | TotalProgress (double frac, const TranslatableString &={}) const |
bool | TrackProgress (int whichTrack, double frac, const TranslatableString &={}) const |
bool | TrackGroupProgress (int whichGroup, double frac, const TranslatableString &={}) const |
int | GetNumWaveTracks () const |
int | GetNumWaveGroups () const |
void | GetBounds (const WaveTrack &track, const WaveTrack *pRight, sampleCount *start, sampleCount *len) |
void | CopyInputTracks (bool allSyncLockSelected=false) |
std::shared_ptr< AddedAnalysisTrack > | AddAnalysisTrack (const wxString &name=wxString()) |
ModifiedAnalysisTrack | ModifyAnalysisTrack (const LabelTrack *pOrigTrack, const wxString &name=wxString()) |
Track * | AddToOutputTracks (const std::shared_ptr< Track > &t) |
![]() | |
void | Preview (EffectSettingsAccess &access, bool dryOnly) override |
bool | DoEffect (EffectSettings &settings, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, wxWindow *pParent, const EffectDialogFactory &dialogFactory, const EffectSettingsAccessPtr &pAccess) override |
Unfortunately complicated dual-use function. More... | |
virtual bool | CheckWhetherSkipEffect (const EffectSettings &settings) const =0 |
After Init(), tell whether Process() should be skipped. More... | |
virtual double | CalcPreviewInputLength (const EffectSettings &settings, double previewLength) const =0 |
void | SetLinearEffectFlag (bool linearEffectFlag) |
void | SetPreviewFullSelectionFlag (bool previewDurationFlag) |
bool | IsPreviewing () const |
void | IncludeNotSelectedPreviewTracks (bool includeNotSelected) |
void | ReplaceProcessedTracks (const bool bGoodResult) |
const TrackList * | inputTracks () const |
const AudacityProject * | FindProject () const |
virtual bool | ValidateUI (EffectSettings &settings)=0 |
virtual bool | CloseUI ()=0 |
![]() | |
wxWeakRef< wxDialog > | mHostUIDialog |
This smart pointer tracks the lifetime of the dialog. More... | |
wxWindow * | mUIParent {} |
![]() | |
BasicUI::ProgressDialog * | mProgress {} |
double | mProjectRate {} |
WaveTrackFactory * | mFactory {} |
std::shared_ptr< TrackList > | mOutputTracks |
double | mT0 {} |
double | mT1 {} |
wxArrayString | mPresetNames |
unsigned | mUIFlags { 0 } |
![]() | |
friend | EffectUIValidator |
friend | DefaultEffectUIValidator |
![]() | |
static int | nEffectsDone = 0 |
A two-pass effect to reduce background noise.
The first pass is done over just noise. For each windowed sample of the sound, we take a FFT and then statistics are tabulated for each frequency band.
During the noise reduction phase, we start by setting a gain control for each frequency band such that if the sound has exceeded the previously-determined threshold, the gain is set to 0 dB, otherwise the gain is set lower (e.g. -18 dB), to suppress the noise. Then time-smoothing is applied so that the gain for each frequency band moves slowly, and then frequency-smoothing is applied so that a single frequency is never suppressed or boosted in isolation. Lookahead is employed; this effect is not designed for real-time but if it were, there would be a significant delay.
The gain controls are applied to the complex FFT of the signal, and then the inverse FFT is applied. A Hann window may be applied (depending on the advanced window types setting), and then the output signal is then pieced together using overlap/add.
Definition at line 18 of file NoiseReduction.h.
EffectNoiseReduction::EffectNoiseReduction | ( | ) |
Definition at line 411 of file NoiseReduction.cpp.
References StatefulEffectBase::Init().
|
virtual |
Definition at line 417 of file NoiseReduction.cpp.
|
overridevirtual |
Reimplemented from Effect.
Definition at line 428 of file NoiseReduction.cpp.
References XO.
|
overridevirtual |
Reimplemented from Effect.
Definition at line 423 of file NoiseReduction.cpp.
References Symbol.
|
overridevirtual |
Type determines how it behaves.
Reimplemented from Effect.
Definition at line 435 of file NoiseReduction.cpp.
References EffectTypeProcess.
|
overridevirtual |
Actually do the effect here.
Implements StatefulEffectBase.
Definition at line 623 of file NoiseReduction.cpp.
References Effect::CopyInputTracks(), eWinFuncBlackman, eWinFuncHamming, eWinFuncHann, eWinFuncRectangular, Effect::MessageBox(), EffectBase::mOutputTracks, mSettings, mStatistics, EffectBase::mT0, EffectBase::mT1, EffectBase::ReplaceProcessedTracks(), anonymous_namespace{NoiseReduction.cpp}::WT_BLACKMAN_HANN, anonymous_namespace{NoiseReduction.cpp}::WT_HAMMING_HANN, anonymous_namespace{NoiseReduction.cpp}::WT_HAMMING_RECTANGULAR, anonymous_namespace{NoiseReduction.cpp}::WT_HANN_HANN, anonymous_namespace{NoiseReduction.cpp}::WT_HANN_RECTANGULAR, anonymous_namespace{NoiseReduction.cpp}::WT_RECTANGULAR_HANN, and XO.
|
overridevirtual |
An override still here for historical reasons, ignoring the factory and the access
We would like to make this effect behave more like others, but it does have its unusual two-pass nature. First choose and analyze an example of noise, then apply noise reduction to another selection. That is difficult to fit into the framework for managing settings of other effects.
Reimplemented from Effect.
Definition at line 446 of file NoiseReduction.cpp.
References StatefulEffect::MakeInstance(), mSettings, and mStatistics.
bool Effect::TrackProgress | ( | int | whichTrack, |
double | frac, | ||
const TranslatableString & | msg = {} |
||
) | const |
Definition at line 179 of file Effect.cpp.
References factory, Effect::IsInteractive(), Effect::mHostUIDialog, and EffectUIClientInterface::ShowClientInterface().
|
friend |
Definition at line 53 of file NoiseReduction.h.
|
private |
Definition at line 55 of file NoiseReduction.h.
Referenced by Process(), and ShowHostInterface().
|
private |
Definition at line 56 of file NoiseReduction.h.
Referenced by EffectNoiseReduction::Worker::Classify(), EffectNoiseReduction::Worker::FinishTrackStatistics(), EffectNoiseReduction::Worker::GatherStatistics(), Process(), EffectNoiseReduction::Worker::Process(), and ShowHostInterface().
|
static |
Definition at line 20 of file NoiseReduction.h.
Referenced by GetSymbol().