53#include "../SpectrumTransformer.h"
57#include "../widgets/valnum.h"
63#if defined(__WXMSW__) && !defined(__CYGWIN__)
65#define finite(x) _finite(x)
70#include <wx/radiobut.h>
72#include <wx/valtext.h>
73#include <wx/textctrl.h>
77#undef SPECTRAL_EDIT_NOISE_REDUCTION
110 {
XO(
"Second greatest") },
137 {
Verbatim(
"none, Hann (2.0.6 behavior)"), 2 },
141 {
Verbatim(
"Hann, Hann (default)"), 4 },
172 Statistics(
size_t spectrumSize,
double rate,
int windowTypes)
178 ,
mSums( spectrumSize )
180#ifdef OLD_METHOD_AVAILABLE
181 , mNoiseThreshold( spectrumSize )
196#ifdef OLD_METHOD_AVAILABLE
215 wxWindow &parent,
bool bHasProfile,
bool bAllowTwiddleSettings);
259 unsigned stepsPerWindow,
bool leadingPadding,
bool trailingPadding
261 needsOutput, inWindowType, outWindowType,
262 windowSize, stepsPerWindow, leadingPadding, trailingPadding
270 : Window{ windowSize }
271 , mSpectrums(windowSize / 2 + 1)
272 , mGains(windowSize / 2 + 1)
281 std::unique_ptr<Window> NewWindow(
size_t windowSize)
override;
282 bool DoStart()
override;
283 bool DoFinish()
override;
301#ifdef SPECTRAL_EDIT_NOISE_REDUCTION
302 ,
double f0,
double f1
367 wxWindow *parent,
bool bHasProfile,
368 bool bAllowTwiddleSettings);
380#ifdef ADVANCED_SETTINGS
381 void EnableDisableSensitivityControls();
387#ifdef ADVANCED_SETTINGS
388 void OnMethodChoice(wxCommandEvent &);
390 void OnPreview(wxCommandEvent &event)
override;
392 void OnCancel( wxCommandEvent &event );
393 void OnHelp( wxCommandEvent &event );
395 void OnText(wxCommandEvent &event);
396 void OnSlider(wxCommandEvent &event);
412 wxRadioButton *mKeepNoise;
419 DECLARE_EVENT_TABLE()
423{
XO(
"Noise Reduction") };
445 return XO(
"Removes background noise such as fans, tape noise, or hums");
475 return mSettings->PromptUser(
this, access, parent,
481 bool bHasProfile,
bool bAllowTwiddleSettings)
484 this, &parent, bHasProfile, bAllowTwiddleSettings);
486 dlog.CentreOnParent();
489 const auto returnCode = dlog.GetReturnCode();
502 template <
typename StructureType,
typename FieldType>
511 template <
typename StructureType,
typename FieldType>
513 StructureType *structure,
const wxString &prefix,
516 for (
size_t ii = 0; ii < numFields; ++ii) {
523 template <
typename StructureType,
typename FieldType>
525 const StructureType *structure,
const wxString &prefix,
528 for (
size_t ii = 0; ii < numFields; ++ii) {
537 static const double DEFAULT_OLD_SENSITIVITY = 0.0;
539 static const PrefsTableEntry<Settings, double> doubleTable[] = {
549 static auto doubleTableSize =
sizeof(doubleTable) /
sizeof(doubleTable[0]);
551 static const PrefsTableEntry<Settings, int> intTable[] = {
560 static auto intTableSize =
sizeof(intTable) /
sizeof(intTable[0]);
562 static const wxString prefix(
wxT(
"/Effects/NoiseReduction/"));
565 readPrefs(
this, prefix, doubleTable, doubleTableSize);
566 readPrefs(
this, prefix, intTable, intTableSize);
569#if !(defined(RESIDUE_CHOICE) || defined (ISOLATE_CHOICE))
571#elif !(defined(RESIDUE_CHOICE))
574#elif !(defined(ISOLATE_CHOICE))
579#ifndef ADVANCED_SETTINGS
585 mOldSensitivity = DEFAULT_OLD_SENSITIVITY;
588#ifndef OLD_METHOD_AVAILABLE
596 writePrefs(
this, prefix, doubleTable, doubleTableSize);
597 writePrefs(
this, prefix, intTable, intTableSize);
606 XO(
"Steps per block are too few for the window types.") );
610 if (StepsPerWindow() > WindowSize()) {
612 XO(
"Steps per block cannot exceed the window size.") );
616 if (mMethod ==
DM_MEDIAN && StepsPerWindow() > 4) {
619"Median method is not implemented for more than four steps per window.") );
627 -> std::unique_ptr<Window>
629 return std::make_unique<MyWindow>(windowSize);
642 auto track = *(outputs.Get().Selected<
const WaveTrack>()).begin();
646 const auto stepsPerWindow =
mSettings->StepsPerWindow();
647 const auto stepSize =
mSettings->WindowSize() / stepsPerWindow;
652 const auto spectrumSize =
mSettings->SpectrumSize();
654 (spectrumSize, track->GetRate(),
mSettings->mWindowTypes);
659 XO(
"You must specify the same window size for steps 1 and 2.") );
665 XO(
"Warning: window types are not the same as for profiling.") );
698#ifdef SPECTRAL_EDIT_NOISE_REDUCTION
702 bool bGoodResult = worker.Process(inWindowType, outWindowType,
704 const auto wasProfile =
mSettings->mDoProfile;
711 if (bGoodResult && !wasProfile)
725 mProgressTrackCount = 0;
727 mProgressWindowCount = 0;
731 XO(
"All noise profile data must have the same sample rate.") );
735"The sample rate of the noise profile must match that of the sound to be processed.") );
739 double trackStart = track->GetStartTime();
740 double trackEnd = track->GetEndTime();
741 double t0 = std::max(trackStart, inT0);
742 double t1 =
std::min(trackEnd, inT1);
745 auto start = track->TimeToLongSamples(t0);
746 auto end = track->TimeToLongSamples(t1);
747 const auto len =
end - start;
759 auto t0 = track->LongSamplesToTime(start);
760 auto tLen = track->LongSamplesToTime(len);
761 std::optional<WaveTrack::Holder> ppTempTrack;
762 std::optional<ChannelGroup::ChannelIterator<WaveChannel>> pIter;
765 ppTempTrack.emplace(track->EmptyCopy());
766 pFirstTrack = ppTempTrack->get();
767 pIter.emplace(pFirstTrack->Channels().begin());
769 for (
const auto pChannel : track->Channels()) {
770 auto pOutputTrack = pIter ? *(*pIter)++ :
nullptr;
772 !
mSettings.mDoProfile, inWindowType, outWindowType,
777 .
Process(Processor, *pChannel, mHistoryLen, start, len))
779 ++mProgressTrackCount;
783 constexpr auto preserveSplits =
true;
784 constexpr auto merge =
true;
785 track->ClearAndPaste(
786 t0, t0 + tLen, **ppTempTrack, preserveSplits, merge);
794 XO(
"Selected noise profile is too short."));
808 if (mFreqSmoothingBins == 0)
811 const auto spectrumSize =
mSettings.SpectrumSize();
814 auto pScratch = mFreqSmoothingScratch.data();
815 std::fill(pScratch, pScratch + spectrumSize, 0.0f);
818 for (
size_t ii = 0; ii < spectrumSize; ++ii)
819 gains[ii] = log(gains[ii]);
822 for (
int ii = 0; ii < (int)spectrumSize; ++ii) {
823 const int j0 = std::max(0, ii - (
int)mFreqSmoothingBins);
824 const int j1 =
std::min(spectrumSize - 1, ii + mFreqSmoothingBins);
825 for(
int jj = j0; jj <= j1; ++jj) {
826 mFreqSmoothingScratch[ii] += gains[jj];
828 mFreqSmoothingScratch[ii] /= (j1 - j0 + 1);
831 for (
size_t ii = 0; ii < spectrumSize; ++ii)
832 gains[ii] = exp(mFreqSmoothingScratch[ii]);
837#ifdef SPECTRAL_EDIT_NOISE_REDUCTION
838 ,
double f0,
double f1
847, mFreqSmoothingScratch(
mSettings.SpectrumSize())
848, mFreqSmoothingBins{ size_t(
std::max(0.0,
settings.mFreqSmoothingBands)) }
852, mNoiseReductionChoice{
settings.mNoiseReductionChoice }
856, mNewSensitivity{
settings.mNewSensitivity * log(10.0) }
860#ifdef SPECTRAL_EDIT_NOISE_REDUCTION
874 const unsigned nAttackBlocks =
876 const unsigned nReleaseBlocks =
894#ifdef OLD_METHOD_AVAILABLE
909 for (
size_t ii = 0, nn = TotalQueueSize(); ii < nn; ++ii) {
913 mWorker.mNoiseAttenFactor);
921 auto &worker = transformer.
mWorker;
924 auto &record = transformer.NthWindow(0);
925 float *pSpectrum = &record.mSpectrums[0];
926 const double dc = record.mRealFFTs[0];
927 *pSpectrum++ = dc * dc;
928 float *pReal = &record.mRealFFTs[1], *pImag = &record.mImagFFTs[1];
929 for (
size_t nn = worker.mSettings.SpectrumSize() - 2; nn--;) {
930 const double re = *pReal++, im = *pImag++;
931 *pSpectrum++ = re * re + im * im;
933 const double nyquist = record.mImagFFTs[0];
934 *pSpectrum = nyquist * nyquist;
937 if (worker.mDoProfile)
940 worker.ReduceNoise(transformer);
943 return !worker.mEffect.TrackProgress(worker.mProgressTrackCount,
945 ((++worker.mProgressWindowCount).as_double() *
946 worker.mSettings.StepSize()) / worker.mLen.as_double()));
956 const auto denom = windows + multiplier;
957 for (
size_t ii = 0, nn =
mStatistics.mMeans.size(); ii < nn; ++ii) {
960 mean = (mean * multiplier + sum) / denom;
978 for (
size_t jj = 0; jj <
mSettings.SpectrumSize(); ++jj) {
979 *pSum++ += *pPower++;
983#ifdef OLD_METHOD_AVAILABLE
988 auto finish = mHistoryLen;
992 auto pPower = NthWindow(0).mSpectrums.data();
993 auto pThreshold =
mStatistics.mNoiseThreshold.data();
994 for (
size_t jj = 0; jj < mSpectrumSize; ++jj) {
995 float min = *pPower++;
996 for (
unsigned ii = 1; ii < finish; ++ii)
998 *pThreshold = std::max(*pThreshold,
min);
1012#ifdef OLD_METHOD_AVAILABLE
1015 float min = NthWindow(0).mSpectrums[band];
1016 for (
unsigned ii = 1; ii < nWindows; ++ii)
1019 min <= mOldSensitivityFactor *
mStatistics.mNoiseThreshold[band];
1038 goto secondGreatest;
1039 else if (nWindows <= 5)
1041 float greatest = 0.0, second = 0.0, third = 0.0;
1042 for (
unsigned ii = 0; ii < nWindows; ++ii) {
1044 if (
power >= greatest)
1045 third = second, second = greatest, greatest =
power;
1046 else if (
power >= second)
1047 third = second, second =
power;
1048 else if (
power >= third)
1051 return third <= mNewSensitivity *
mStatistics.mMeans[band];
1064 float greatest = 0.0, second = 0.0;
1065 for (
unsigned ii = 0; ii < nWindows; ++ii) {
1067 if (
power >= greatest)
1068 second = greatest, greatest =
power;
1069 else if (
power >= second)
1072 return second <= mNewSensitivity *
mStatistics.mMeans[band];
1083 auto nWindows = std::min<unsigned>(mNWindowsToExamine, historyLen);
1085 const auto spectrumSize =
mSettings.SpectrumSize();
1089 auto &record = transformer.
NthWindow(0);
1092 float *pGain = &record.
mGains[0];
1093 std::fill(pGain, pGain + spectrumSize, mNoiseAttenFactor);
1098 if (nWindows > mCenter)
1103 std::fill(pGain, pGain + mBinLow, 0.0f);
1104 std::fill(pGain + mBinHigh, pGain + spectrumSize, 0.0f);
1106 for (
size_t jj = mBinLow; jj < mBinHigh; ++jj) {
1107 const bool isNoise = Classify(transformer, nWindows, jj);
1108 *pGain++ = isNoise ? 1.0 : 0.0;
1113 std::fill(pGain, pGain + mBinLow, 1.0f);
1114 std::fill(pGain + mBinHigh, pGain + spectrumSize, 1.0f);
1116 for (
size_t jj = mBinLow; jj < mBinHigh; ++jj) {
1117 const bool isNoise = Classify(transformer, nWindows, jj);
1133 for (
size_t jj = 0; jj < spectrumSize; ++jj) {
1134 for (
unsigned ii = mCenter + 1; ii < historyLen; ++ii) {
1135 const float minimum =
1136 std::max(mNoiseAttenFactor,
1154 for (
auto nn =
mSettings.SpectrumSize(); nn--;) {
1156 std::max(*pNextGain,
1157 std::max(mNoiseAttenFactor,
1158 *pThisGain++ * mOneBlockRelease));
1166 auto &record = transformer.
NthWindow(historyLen - 1);
1167 const auto last =
mSettings.SpectrumSize() - 1;
1172 ApplyFreqSmoothing(record.mGains);
1176 const float *pGain = &record.mGains[1];
1177 float *pReal = &record.mRealFFTs[1];
1178 float *pImag = &record.mImagFFTs[1];
1184 const double gain = *pGain++ - 1.0;
1188 record.mRealFFTs[0] *= (record.mGains[0] - 1.0);
1190 record.mImagFFTs[0] *= (record.mGains[last] - 1.0);
1194 const double gain = *pGain++;
1198 record.mRealFFTs[0] *= record.mGains[0];
1200 record.mImagFFTs[0] *= record.mGains[last];
1208 if (mWorker.mDoProfile)
1209 mWorker.FinishTrackStatistics();
1220#ifdef ISOLATE_CHOICE
1221 ID_RADIOBUTTON_KEEPNOISE,
1223#ifdef RESIDUE_CHOICE
1227#ifdef ADVANCED_SETTINGS
1238#ifdef ATTACK_AND_RELEASE
1239 ID_ATTACK_TIME_SLIDER,
1240 ID_ATTACK_TIME_TEXT,
1242 ID_RELEASE_TIME_SLIDER,
1243 ID_RELEASE_TIME_TEXT,
1251#ifdef ADVANCED_SETTINGS
1253 ID_OLD_SENSITIVITY_TEXT,
1255 END_OF_ADVANCED_SLIDERS,
1273 (double(sliderSetting) / sliderMax) * (valueMax - valueMin);
1278 return std::clamp<long>(
1279 0.5 + sliderMax * (value - valueMin) / (valueMax - valueMin),
1286 return wxString::Format(
format, (
int)(value));
1288 return wxString::Format(
format, value);
1293 wxTextCtrl *
const text =
S.Id(
id + 1)
1294 .Validator<FloatingPointValidator<double>>(
1295 formatAsInt ? 0 : 2,
1297 NumValidatorStyle::DEFAULT,
1300 .AddTextBox(textBoxCaption,
wxT(
""), 0);
1302 wxSlider *
const slider =
1305 .Style(wxSL_HORIZONTAL)
1306 .MinSize( { 150, -1 } )
1307 .AddSlider( {}, 0, sliderMax);
1322 :
field(f), valueMin(vMin), valueMax(vMax), sliderMax(sMax),
format(fmt), formatAsInt(fAsInt)
1323 , textBoxCaption(caption), sliderName(
name)
1331 0.0, 48.0, 48,
wxT(
"%d"),
true,
1332 XXO(
"&Noise reduction (dB):"),
XO(
"Noise reduction")),
1334 0.01, 24.0, 48,
wxT(
"%.2f"),
false,
1335 XXO(
"&Sensitivity:"),
XO(
"Sensitivity")),
1336#ifdef ATTACK_AND_RELEASE
1338 0, 1.0, 100,
wxT(
"%.2f"),
false,
1339 XXO(
"Attac&k time (secs):"),
XO(
"Attack time")),
1341 0, 1.0, 100,
wxT(
"%.2f"),
false,
1342 XXO(
"R&elease time (secs):"),
XO(
"Release time")),
1345 0, 12, 12,
wxT(
"%d"),
true,
1346 XXO(
"&Frequency smoothing (bands):"),
XO(
"Frequency smoothing")),
1348#ifdef ADVANCED_SETTINGS
1350 -20.0, 20.0, 4000,
wxT(
"%.2f"),
false,
1351 XXO(
"Sensiti&vity (dB):"),
XO(
"Old Sensitivity")),
1370#ifdef ISOLATE_CHOICE
1373#ifdef RESIDUE_CHOICE
1377#ifdef ADVANCED_SETTINGS
1378 EVT_CHOICE(ID_CHOICE_METHOD, EffectNoiseReduction::Dialog::OnMethodChoice)
1390#ifdef ATTACK_AND_RELEASE
1399#ifdef ADVANCED_SETTINGS
1408 wxWindow *parent,
bool bHasProfile,
bool bAllowTwiddleSettings)
1414 , mbHasProfile(bHasProfile)
1415 , mbAllowTwiddleSettings(bAllowTwiddleSettings)
1418#ifdef ISOLATE_CHOICE
1421#ifdef RESIDUE_CHOICE
1427 wxButton *
const pButtonPreview =
1429 wxButton *
const pButtonReduceNoise =
1430 (wxButton *)wxWindow::FindWindowById(wxID_OK,
this);
1432 if (mbHasProfile || mbAllowTwiddleSettings) {
1433 pButtonPreview->Enable(!mbAllowTwiddleSettings);
1434 pButtonReduceNoise->SetFocus();
1437 pButtonPreview->Enable(
false);
1438 pButtonReduceNoise->Enable(
false);
1453 static const int toDisable[] = {
1460#ifdef ATTACK_AND_RELEASE
1461 ID_ATTACK_TIME_SLIDER,
1462 ID_ATTACK_TIME_TEXT,
1464 ID_RELEASE_TIME_SLIDER,
1465 ID_RELEASE_TIME_TEXT,
1468 static const auto nToDisable =
sizeof(toDisable) /
sizeof(toDisable[0]);
1471#ifdef ISOLATE_CHOICE
1472 mKeepNoise->GetValue();
1476 for (
auto ii = nToDisable; ii--;)
1477 wxWindow::FindWindowById(toDisable[ii],
this)->Enable(!bIsolating);
1480#ifdef ADVANCED_SETTINGS
1481void EffectNoiseReduction::Dialog::EnableDisableSensitivityControls()
1483 wxChoice *
const pChoice =
1484 static_cast<wxChoice*
>(wxWindow::FindWindowById(ID_CHOICE_METHOD,
this));
1485 const bool bOldMethod =
1487 wxWindow::FindWindowById(ID_OLD_SENSITIVITY_SLIDER,
this)->Enable(bOldMethod);
1488 wxWindow::FindWindowById(ID_OLD_SENSITIVITY_TEXT,
this)->Enable(bOldMethod);
1509 if (mKeepSignal->GetValue())
1511#ifdef ISOLATE_CHOICE
1512 else if (mKeepNoise->GetValue())
1515#ifdef RESIDUE_CHOICE
1519 DisableControlsIfIsolating();
1522#ifdef ADVANCED_SETTINGS
1523void EffectNoiseReduction::Dialog::OnMethodChoice(wxCommandEvent &)
1525 EnableDisableSensitivityControls();
1536 *m_pSettings = mTempSettings;
1537 m_pSettings->mDoProfile =
false;
1565 S.StartStatic(
XO(
"Step 1"));
1567 S.AddVariableText(
XO(
1568"Select a few seconds of just noise so Audacity knows what to filter out,\nthen click Get Noise Profile:"));
1574 S.StartStatic(
XO(
"Step 2"));
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"));
1579 S.StartMultiColumn(3, wxEXPAND);
1580 S.SetStretchyCol(2);
1594#ifdef ISOLATE_CHOICE
1598 wxALIGN_CENTER_HORIZONTAL);
1600 S.AddPrompt(
XXO(
"Noise:"));
1603 .AddRadioButton(
XXO(
"Re&duce"));
1604#ifdef ISOLATE_CHOICE
1605 mKeepNoise =
S.Id(ID_RADIOBUTTON_KEEPNOISE)
1606 .AddRadioButtonToGroup(
XXO(
"&Isolate"));
1608#ifdef RESIDUE_CHOICE
1611 .AddRadioButtonToGroup(
XXO(
"Resid&ue"));
1619#ifdef ADVANCED_SETTINGS
1620 S.StartStatic(
XO(
"Advanced Settings"));
1622 S.StartMultiColumn(2);
1624 S.TieChoice(
XXO(
"&Window types:"),
1625 mTempSettings.mWindowTypes,
1630 return windowTypeChoices;
1634 S.TieChoice(
XXO(
"Window si&ze:"),
1635 mTempSettings.mWindowSizeChoice,
1645 XO(
"2048 (default)") ,
1652 S.TieChoice(
XXO(
"S&teps per window:"),
1653 mTempSettings.mStepsPerWindowChoice,
1664 S.Id(ID_CHOICE_METHOD)
1665 .TieChoice(
XXO(
"Discrimination &method:"),
1666 mTempSettings.mMethod,
1670#ifndef OLD_METHOD_AVAILABLE
1673 for (
auto ii = 0; ii < nn; ++ii)
1675 return methodChoices;
1680 S.StartMultiColumn(3, wxEXPAND);
1681 S.SetStretchyCol(2);
1702 static_cast<wxSlider*
>(wxWindow::FindWindowById(
id,
this));
1704 static_cast<wxTextCtrl*
>(wxWindow::FindWindowById(
id + 1,
this));
1706 const double field = mTempSettings.*(info.field);
1707 text->SetValue(info.Text(
field));
1708 slider->SetValue(info.SliderSetting(
field));
1711 mKeepSignal->SetValue(mTempSettings.mNoiseReductionChoice ==
NRC_REDUCE_NOISE);
1712#ifdef ISOLATE_CHOICE
1715#ifdef RESIDUE_CHOICE
1720 DisableControlsIfIsolating();
1721#ifdef ADVANCED_SETTINGS
1722 EnableDisableSensitivityControls();
1730 if( !wxWindow::Validate() )
1736 wxCommandEvent dummy;
1737 OnNoiseReductionChoice(dummy);
1739 return mTempSettings.Validate(m_pEffect);
1744 int id =
event.GetId();
1748 static_cast<wxTextCtrl*
>(wxWindow::FindWindowById(
id,
this));
1750 static_cast<wxSlider*
>(wxWindow::FindWindowById(
id - 1,
this));
1751 double &
field = mTempSettings.*(info.field);
1753 text->GetValue().ToDouble(&
field);
1754 slider->SetValue(info.SliderSetting(
field));
1759 int id =
event.GetId();
1763 static_cast<wxSlider*
>(wxWindow::FindWindowById(
id,
this));
1765 static_cast<wxTextCtrl*
>(wxWindow::FindWindowById(
id + 1,
this));
1766 double &
field = mTempSettings.*(info.field);
1768 field = info.Value(slider->GetValue());
1769 text->SetValue(info.Text(
field));
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
const TranslatableString name
#define ID_EFFECT_PREVIEW
void EffectPreview(EffectBase &effect, EffectSettingsAccess &access, std::function< void()> updateUI, bool dryOnly)
Calculate temporary tracks of limited length with effect applied and play.
std::function< DialogFactoryResults(wxWindow &parent, EffectBase &, EffectUIServices &, EffectSettingsAccess &) > EffectDialogFactory
Type of function that creates a dialog for an effect.
XXO("&Cut/Copy/Paste Toolbar")
static ProjectFileIORegistry::AttributeWriterEntry entry
ValueRestorer< T > valueRestorer(T &var)
inline functions provide convenient parameter type deduction
std::vector< float > FloatVector
@ ID_NEW_SENSITIVITY_SLIDER
@ ID_NEW_SENSITIVITY_TEXT
@ ID_RADIOBUTTON_KEEPSIGNAL
audacity::BasicSettings * gPrefs
static Settings & settings()
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
std::vector< TranslatableString > TranslatableStrings
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Base class for many of the effects in Audacity.
std::shared_ptr< TrackList > mTracks
bool TransferDataToWindow() override
bool TransferDataFromWindow() override
bool IsBatchProcessing() const override
Performs effect computation.
void SetSkipStateFlag(bool flag)
static EffectManager & Get()
Dialog used with EffectNoiseReduction.
const Settings & GetTempSettings() const
void OnNoiseReductionChoice(wxCommandEvent &event)
void DisableControlsIfIsolating()
void OnSlider(wxCommandEvent &event)
void OnHelp(wxCommandEvent &event)
bool TransferDataToWindow() override
EffectNoiseReduction::Settings mTempSettings
EffectSettingsAccess & mAccess
This dialog is modal, so mAccess will live long enough for it.
void PopulateOrExchange(ShuttleGui &S) override
void OnText(wxCommandEvent &event)
Dialog(EffectNoiseReduction *effect, EffectSettingsAccess &access, Settings *settings, wxWindow *parent, bool bHasProfile, bool bAllowTwiddleSettings)
wxRadioButton * mKeepSignal
void OnReduceNoise(wxCommandEvent &event)
void OnPreview(wxCommandEvent &event) override
EffectNoiseReduction * m_pEffect
bool mbAllowTwiddleSettings
void OnGetProfile(wxCommandEvent &event)
void OnCancel(wxCommandEvent &event)
EffectNoiseReduction::Settings * m_pSettings
bool TransferDataFromWindow() override
size_t WindowSize() const
double mFreqSmoothingBands
int PromptUser(EffectNoiseReduction *effect, EffectSettingsAccess &access, wxWindow &parent, bool bHasProfile, bool bAllowTwiddleSettings)
int mStepsPerWindowChoice
int mNoiseReductionChoice
unsigned StepsPerWindow() const
bool Validate(EffectNoiseReduction *effect) const
size_t SpectrumSize() const
Statistics(size_t spectrumSize, double rate, int windowTypes)
unsigned mProgressTrackCount
EffectNoiseReduction::Settings Settings
void ReduceNoise(MyTransformer &transformer)
const Settings & mSettings
void FinishTrackStatistics()
bool Process(eWindowFunctions inWindowType, eWindowFunctions outWindowType, TrackList &tracks, double mT0, double mT1)
FloatVector mFreqSmoothingScratch
const size_t mFreqSmoothingBins
static bool Processor(SpectrumTransformer &transformer)
void ApplyFreqSmoothing(FloatVector &gains)
unsigned mNWindowsToExamine
EffectNoiseReduction & mEffect
EffectNoiseReduction::Statistics Statistics
void GatherStatistics(MyTransformer &transformer)
sampleCount mProgressWindowCount
const int mNoiseReductionChoice
const double mNewSensitivity
float mOldSensitivityFactor
bool Classify(MyTransformer &transformer, unsigned nWindows, int band)
Worker(EffectNoiseReduction &effect, const Settings &settings, Statistics &statistics)
A two-pass effect to reduce background noise.
static const ComponentInterfaceSymbol Symbol
TranslatableString GetDescription() const override
ComponentInterfaceSymbol GetSymbol() const override
std::unique_ptr< Settings > mSettings
bool Process(EffectInstance &instance, EffectSettings &settings) override
virtual ~EffectNoiseReduction()
EffectType GetType() const override
Type determines how it behaves.
int ShowHostInterface(EffectBase &plugin, wxWindow &parent, const EffectDialogFactory &factory, std::shared_ptr< EffectInstance > &pInstance, EffectSettingsAccess &access, bool forceModal=false) override
std::unique_ptr< Statistics > mStatistics
Use this object to copy the input tracks to tentative outputTracks.
static int DoMessageBox(const EffectPlugin &plugin, const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
static void ShowHelp(wxWindow *parent, const FilePath &localFileName, const URLString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
std::shared_ptr< EffectInstance > MakeInstance() const override
Make an object maintaining short-term state of an Effect.
virtual bool TransferDataFromWindow(EffectSettings &settings)
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Holds a msgid for the translation catalog; may also bind format arguments.
A Track that contains audio waveform data.
virtual bool Flush() noexcept=0
virtual bool Write(const wxString &key, bool value)=0
virtual bool Read(const wxString &key, bool *value) const =0
Positions or offsets within audio files need a wide type.
constexpr auto sampleRate
@ DEFAULT_STEPS_PER_WINDOW_CHOICE
@ DEFAULT_WINDOW_SIZE_CHOICE
void writePrefs(const StructureType *structure, const wxString &prefix, const PrefsTableEntry< StructureType, FieldType > *fields, size_t numFields)
void readPrefs(StructureType *structure, const wxString &prefix, const PrefsTableEntry< StructureType, FieldType > *fields, size_t numFields)
const ControlInfo * controlInfo()
BuiltinEffectsModule::Registration< EffectNoiseReduction > reg
const struct anonymous_namespace{NoiseReduction.cpp}::DiscriminationMethodInfo discriminationMethodInfo[DM_N_METHODS]
@ WT_DEFAULT_WINDOW_TYPES
const float minSignalTime
const struct anonymous_namespace{NoiseReduction.cpp}::WindowTypesInfo windowTypesInfo[WT_N_WINDOW_TYPES]
const char * end(const char *str) noexcept
constexpr fastfloat_really_inline int32_t power(int32_t q) noexcept
Externalized state of a plug-in.
long SliderSetting(double value) const
wxString Text(double value) const
void CreateControls(int id, ShuttleGui &S) const
const TranslatableString textBoxCaption
doubleEffectNoiseReduction::Settings::* MemberPointer
ControlInfo(MemberPointer f, double vMin, double vMax, long sMax, const wxChar *fmt, bool fAsInt, const TranslatableString &caption, const TranslatableString &name)
double Value(long sliderSetting) const
const TranslatableString sliderName
const TranslatableString name
FieldTypeStructureType::* MemberPointer
const TranslatableString name