Audacity 3.2.0
NoiseRemoval.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 NoiseRemoval.h
6
7 Dominic Mazzoni
8 Vaughan Johnson (Preview)
9
10**********************************************************************/
11
12#ifndef __AUDACITY_EFFECT_NOISE_REMOVAL__
13#define __AUDACITY_EFFECT_NOISE_REMOVAL__
14
15
16
17#if !defined(EXPERIMENTAL_NOISE_REDUCTION)
18
19#include "StatefulEffect.h"
20#include "EffectUI.h"
21
22class wxButton;
23class wxSizer;
24class wxSlider;
25
26class Envelope;
28class WaveTrack;
29
30class wxRadioButton;
31class wxTextCtrl;
32
33#include "RealFFTf.h"
34#include "SampleFormat.h"
35
37{
38public:
40
42 virtual ~EffectNoiseRemoval();
43
44 // ComponentInterface implementation
45
48
49 // EffectDefinitionInterface implementation
50
51 EffectType GetType() const override;
52 bool SupportsAutomation() const override;
53
54 // Effect implementation
55
56 int ShowHostInterface(EffectBase &plugin, wxWindow &parent,
58 std::shared_ptr<EffectInstance> &pInstance, EffectSettingsAccess &access,
59 bool forceModal = false) override;
60 bool Init() override;
61 bool CheckWhetherSkipEffect(const EffectSettings &settings) const override;
62 bool Process(EffectInstance &instance, EffectSettings &settings) override;
63 void End() override;
64
65private:
66
69 int mLevel;
70
71 // Parameters chosen before the first phase
75 float mMinSignalTime; // in secs
76
77 // The frequency-indexed noise threshold derived during the first
78 // phase of analysis
79 Floats mNoiseThreshold; // length is mSpectrumSize
80
81 // Parameters that affect the noise removal, regardless of how the
82 // noise profile was extracted
85 double mNoiseGain; // in dB, should be negative
86 double mAttackDecayTime; // in secs
88
89 bool ProcessOne(int count, WaveTrack * track,
90 sampleCount start, sampleCount len);
91
92 void Initialize();
93 void StartNewTrack();
94 void ProcessSamples(size_t len, float *buffer);
96 void ApplyFreqSmoothing(float *spec);
97 void GetProfile();
98 void RemoveNoise();
100 void FinishTrack();
101
102 // Variables that only exist during processing
103 std::shared_ptr<WaveTrack> mOutputTrack;
107
109 Floats mFFTBuffer; // mWindowSize
110 Floats mWindow; // mWindowSize
111
119 Floats mInWaveBuffer; // mWindowSize
120 Floats mOutOverlapBuffer; // mWindowSize
121 ArraysOf<float> mSpectrums; // mHistoryLen x mSpectrumSize
122 ArraysOf<float> mGains; // mHistoryLen x mSpectrumSize
123 ArraysOf<float> mRealFFTs; // mHistoryLen x mWindowSize
124 ArraysOf<float> mImagFFTs; // mHistoryLen x mWindowSize
125
126 friend class NoiseRemovalDialog;
127};
128
129// WDR: class declarations
130
131//----------------------------------------------------------------------------
132// NoiseRemovalDialog
133//----------------------------------------------------------------------------
134
135// Declare window functions
136
138{
139public:
140 // constructors and destructors
142 wxWindow *parent);
143
144 wxSizer *MakeNoiseRemovalDialog(bool call_fit = true,
145 bool set_sizer = true);
146
147 void PopulateOrExchange(ShuttleGui & S) override;
148 bool TransferDataToWindow() override;
149 bool TransferDataFromWindow() override;
150
151private:
152 // handlers
153 void OnGetProfile( wxCommandEvent &event );
154 void OnKeepNoise( wxCommandEvent &event );
155 void OnPreview(wxCommandEvent &event) override;
156 void OnRemoveNoise( wxCommandEvent &event );
157 void OnCancel( wxCommandEvent &event );
158
159 void OnSensitivityText(wxCommandEvent & event);
160 void OnGainText(wxCommandEvent & event);
161 void OnFreqText(wxCommandEvent & event);
162 void OnTimeText(wxCommandEvent & event);
163 void OnSensitivitySlider(wxCommandEvent & event);
164 void OnGainSlider(wxCommandEvent & event);
165 void OnFreqSlider(wxCommandEvent & event);
166 void OnTimeSlider(wxCommandEvent & event);
167
168 public:
169
172
176
177 wxRadioButton *mKeepSignal;
178 wxRadioButton *mKeepNoise;
179
180 wxSlider *mSensitivityS;
181 wxSlider *mGainS;
182 wxSlider *mFreqS;
183 wxSlider *mTimeS;
184
185 wxTextCtrl *mSensitivityT;
186 wxTextCtrl *mGainT;
187 wxTextCtrl *mFreqT;
188 wxTextCtrl *mTimeT;
189
191 double mGain;
192 double mFreq;
193 double mTime;
194
196
197private:
198 DECLARE_EVENT_TABLE()
199
200};
201
202#endif
203
204#endif
static RegisteredToolbarFactory factory
EffectType
std::function< DialogFactoryResults(wxWindow &parent, EffectBase &, EffectUIServices &, EffectSettingsAccess &) > EffectDialogFactory
Type of function that creates a dialog for an effect.
std::unique_ptr< FFTParam, FFTDeleter > HFFT
Definition: RealFFTf.h:22
#define S(N)
Definition: ToChars.cpp:64
static Settings & settings()
Definition: TrackInfo.cpp:69
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Base class for many of the effects in Audacity.
Definition: EffectBase.h:28
Performs effect computation.
A two-pass effect to remove background noise.
Definition: NoiseRemoval.h:37
static const ComponentInterfaceSymbol Symbol
Definition: NoiseRemoval.h:39
ComponentInterfaceSymbol GetSymbol() override
bool SupportsAutomation() const override
Whether the effect has any automatable controls.
bool Init() override
ArraysOf< float > mImagFFTs
Definition: NoiseRemoval.h:124
void ProcessSamples(size_t len, float *buffer)
std::shared_ptr< WaveTrack > mOutputTrack
Definition: NoiseRemoval.h:103
int ShowHostInterface(EffectBase &plugin, wxWindow &parent, const EffectDialogFactory &factory, std::shared_ptr< EffectInstance > &pInstance, EffectSettingsAccess &access, bool forceModal=false) override
ArraysOf< float > mRealFFTs
Definition: NoiseRemoval.h:123
void ApplyFreqSmoothing(float *spec)
EffectType GetType() const override
Type determines how it behaves.
bool ProcessOne(int count, WaveTrack *track, sampleCount start, sampleCount len)
sampleCount mOutSampleCount
Definition: NoiseRemoval.h:105
TranslatableString GetDescription() override
bool Process(EffectInstance &instance, EffectSettings &settings) override
ArraysOf< float > mSpectrums
Definition: NoiseRemoval.h:121
bool CheckWhetherSkipEffect(const EffectSettings &settings) const override
After Init(), tell whether Process() should be skipped.
virtual ~EffectNoiseRemoval()
ArraysOf< float > mGains
Definition: NoiseRemoval.h:122
void End() override
sampleCount mInSampleCount
Definition: NoiseRemoval.h:104
Piecewise linear or piecewise exponential function from double to double.
Definition: Envelope.h:72
Dialog used with EffectNoiseRemoval.
Definition: NoiseRemoval.h:138
void OnFreqText(wxCommandEvent &event)
wxButton * m_pButton_RemoveNoise
Definition: NoiseRemoval.h:175
void OnPreview(wxCommandEvent &event) override
NoiseRemovalDialog(EffectNoiseRemoval *effect, EffectSettingsAccess &access, wxWindow *parent)
void OnFreqSlider(wxCommandEvent &event)
void PopulateOrExchange(ShuttleGui &S) override
wxTextCtrl * mTimeT
Definition: NoiseRemoval.h:188
void OnCancel(wxCommandEvent &event)
EffectSettingsAccess & mAccess
Definition: NoiseRemoval.h:171
void OnRemoveNoise(wxCommandEvent &event)
wxTextCtrl * mSensitivityT
Definition: NoiseRemoval.h:185
wxButton * m_pButton_Preview
Definition: NoiseRemoval.h:174
wxRadioButton * mKeepNoise
Definition: NoiseRemoval.h:178
wxButton * m_pButton_GetProfile
Definition: NoiseRemoval.h:173
void OnGainText(wxCommandEvent &event)
bool TransferDataFromWindow() override
void OnTimeSlider(wxCommandEvent &event)
wxTextCtrl * mFreqT
Definition: NoiseRemoval.h:187
void OnGainSlider(wxCommandEvent &event)
EffectNoiseRemoval * m_pEffect
Definition: NoiseRemoval.h:170
wxSlider * mSensitivityS
Definition: NoiseRemoval.h:180
void OnGetProfile(wxCommandEvent &event)
void OnKeepNoise(wxCommandEvent &event)
void OnSensitivityText(wxCommandEvent &event)
wxSizer * MakeNoiseRemovalDialog(bool call_fit=true, bool set_sizer=true)
void OnSensitivitySlider(wxCommandEvent &event)
void OnTimeText(wxCommandEvent &event)
wxTextCtrl * mGainT
Definition: NoiseRemoval.h:186
wxRadioButton * mKeepSignal
Definition: NoiseRemoval.h:177
bool TransferDataToWindow() override
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
Holds a msgid for the translation catalog; may also bind format arguments.
A Track that contains audio waveform data.
Definition: WaveTrack.h:203
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19
Externalized state of a plug-in.