Audacity  3.0.3
Public Member Functions | Public Attributes | List of all members
EffectNoiseReduction::Settings Class Reference

Public Member Functions

 Settings ()
 
 ~Settings ()
 
bool PromptUser (EffectNoiseReduction *effect, wxWindow &parent, bool bHasProfile, bool bAllowTwiddleSettings)
 
bool PrefsIO (bool read)
 
bool Validate (EffectNoiseReduction *effect) const
 
size_t WindowSize () const
 
unsigned StepsPerWindow () const
 

Public Attributes

bool mDoProfile
 
double mNewSensitivity
 
double mFreqSmoothingBands
 
double mNoiseGain
 
double mAttackTime
 
double mReleaseTime
 
double mOldSensitivity
 
int mNoiseReductionChoice
 
int mWindowTypes
 
int mWindowSizeChoice
 
int mStepsPerWindowChoice
 
int mMethod
 

Detailed Description

Definition at line 208 of file NoiseReduction.cpp.

Constructor & Destructor Documentation

◆ Settings()

EffectNoiseReduction::Settings::Settings ( )

Definition at line 246 of file NoiseReduction.cpp.

247  : mDoProfile{ true }
248 {
249  PrefsIO(true);
250 }

◆ ~Settings()

EffectNoiseReduction::Settings::~Settings ( )
inline

Definition at line 212 of file NoiseReduction.cpp.

212 {}

Member Function Documentation

◆ PrefsIO()

bool EffectNoiseReduction::Settings::PrefsIO ( bool  read)

Definition at line 515 of file NoiseReduction.cpp.

516 {
517  static const double DEFAULT_OLD_SENSITIVITY = 0.0;
518 
519  static const PrefsTableEntry<Settings, double> doubleTable[] = {
520  { &Settings::mNewSensitivity, wxT("Sensitivity"), 6.0 },
521  { &Settings::mNoiseGain, wxT("Gain"), 12.0 },
522  { &Settings::mAttackTime, wxT("AttackTime"), 0.02 },
523  { &Settings::mReleaseTime, wxT("ReleaseTime"), 0.10 },
524  { &Settings::mFreqSmoothingBands, wxT("FreqSmoothing"), 3.0 },
525 
526  // Advanced settings
527  { &Settings::mOldSensitivity, wxT("OldSensitivity"), DEFAULT_OLD_SENSITIVITY },
528  };
529  static auto doubleTableSize = sizeof(doubleTable) / sizeof(doubleTable[0]);
530 
531  static const PrefsTableEntry<Settings, int> intTable[] = {
532  { &Settings::mNoiseReductionChoice, wxT("ReductionChoice"), NRC_REDUCE_NOISE },
533 
534  // Advanced settings
535  { &Settings::mWindowTypes, wxT("WindowTypes"), WT_DEFAULT_WINDOW_TYPES },
538  { &Settings::mMethod, wxT("Method"), DM_DEFAULT_METHOD },
539  };
540  static auto intTableSize = sizeof(intTable) / sizeof(intTable[0]);
541 
542  static const wxString prefix(wxT("/Effects/NoiseReduction/"));
543 
544  if (read) {
545  readPrefs(this, prefix, doubleTable, doubleTableSize);
546  readPrefs(this, prefix, intTable, intTableSize);
547 
548  // Ignore preferences for unavailable options.
549 #if !(defined(RESIDUE_CHOICE) || defined (ISOLATE_CHOICE))
551 #elif !(defined(RESIDUE_CHOICE))
554 #elif !(defined(ISOLATE_CHOICE))
557 #endif
558 
559 #ifndef ADVANCED_SETTINGS
560  // Initialize all hidden advanced settings to defaults.
565  mOldSensitivity = DEFAULT_OLD_SENSITIVITY;
566 #endif
567 
568 #ifndef OLD_METHOD_AVAILABLE
569  if (mMethod == DM_OLD_METHOD)
571 #endif
572 
573  return true;
574  }
575  else {
576  writePrefs(this, prefix, doubleTable, doubleTableSize);
577  writePrefs(this, prefix, intTable, intTableSize);
578  return gPrefs->Flush();
579  }
580 }

References anonymous_namespace{NoiseReduction.cpp}::DEFAULT_STEPS_PER_WINDOW_CHOICE, anonymous_namespace{NoiseReduction.cpp}::DEFAULT_WINDOW_SIZE_CHOICE, anonymous_namespace{NoiseReduction.cpp}::DM_DEFAULT_METHOD, anonymous_namespace{NoiseReduction.cpp}::DM_OLD_METHOD, FileConfig::Flush(), gPrefs, mAttackTime, mFreqSmoothingBands, mMethod, mNewSensitivity, mNoiseGain, mNoiseReductionChoice, mOldSensitivity, mReleaseTime, mStepsPerWindowChoice, mWindowSizeChoice, mWindowTypes, anonymous_namespace{NoiseReduction.cpp}::NRC_ISOLATE_NOISE, anonymous_namespace{NoiseReduction.cpp}::NRC_LEAVE_RESIDUE, anonymous_namespace{NoiseReduction.cpp}::NRC_REDUCE_NOISE, anonymous_namespace{NoiseReduction.cpp}::readPrefs(), anonymous_namespace{NoiseReduction.cpp}::writePrefs(), and anonymous_namespace{NoiseReduction.cpp}::WT_DEFAULT_WINDOW_TYPES.

Referenced by PromptUser().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PromptUser()

bool EffectNoiseReduction::Settings::PromptUser ( EffectNoiseReduction effect,
wxWindow &  parent,
bool  bHasProfile,
bool  bAllowTwiddleSettings 
)

Definition at line 462 of file NoiseReduction.cpp.

465 {
467  (effect, this, &parent, bHasProfile, bAllowTwiddleSettings);
468 
469  dlog.CentreOnParent();
470  dlog.ShowModal();
471 
472  if (dlog.GetReturnCode() == 0)
473  return false;
474 
475  *this = dlog.GetTempSettings();
476  mDoProfile = (dlog.GetReturnCode() == 1);
477 
478  return PrefsIO(false);
479 }

References EffectNoiseReduction::Dialog::GetTempSettings(), mDoProfile, and PrefsIO().

Here is the call graph for this function:

◆ StepsPerWindow()

unsigned EffectNoiseReduction::Settings::StepsPerWindow ( ) const
inline

Definition at line 220 of file NoiseReduction.cpp.

220 { return 1u << (1 + mStepsPerWindowChoice); }

References mStepsPerWindowChoice.

Referenced by EffectNoiseReduction::Worker::Worker().

Here is the caller graph for this function:

◆ Validate()

bool EffectNoiseReduction::Settings::Validate ( EffectNoiseReduction effect) const

Definition at line 582 of file NoiseReduction.cpp.

583 {
584  if (StepsPerWindow() < windowTypesInfo[mWindowTypes].minSteps) {
585  effect->Effect::MessageBox(
586  XO("Steps per block are too few for the window types.") );
587  return false;
588  }
589 
590  if (StepsPerWindow() > WindowSize()) {
591  effect->Effect::MessageBox(
592  XO("Steps per block cannot exceed the window size.") );
593  return false;
594  }
595 
596  if (mMethod == DM_MEDIAN && StepsPerWindow() > 4) {
597  effect->Effect::MessageBox(
598  XO(
599 "Median method is not implemented for more than four steps per window.") );
600  return false;
601  }
602 
603  return true;
604 }

References anonymous_namespace{NoiseReduction.cpp}::DM_MEDIAN, anonymous_namespace{NoiseReduction.cpp}::windowTypesInfo, and XO.

◆ WindowSize()

size_t EffectNoiseReduction::Settings::WindowSize ( ) const
inline

Definition at line 219 of file NoiseReduction.cpp.

219 { return 1u << (3 + mWindowSizeChoice); }

References mWindowSizeChoice.

Referenced by EffectNoiseReduction::Worker::Worker().

Here is the caller graph for this function:

Member Data Documentation

◆ mAttackTime

double EffectNoiseReduction::Settings::mAttackTime

◆ mDoProfile

bool EffectNoiseReduction::Settings::mDoProfile

Definition at line 222 of file NoiseReduction.cpp.

Referenced by PromptUser(), and EffectNoiseReduction::Worker::Worker().

◆ mFreqSmoothingBands

double EffectNoiseReduction::Settings::mFreqSmoothingBands

◆ mMethod

int EffectNoiseReduction::Settings::mMethod

Definition at line 243 of file NoiseReduction.cpp.

Referenced by PrefsIO().

◆ mNewSensitivity

double EffectNoiseReduction::Settings::mNewSensitivity

◆ mNoiseGain

double EffectNoiseReduction::Settings::mNoiseGain

◆ mNoiseReductionChoice

int EffectNoiseReduction::Settings::mNoiseReductionChoice

Definition at line 237 of file NoiseReduction.cpp.

Referenced by PrefsIO().

◆ mOldSensitivity

double EffectNoiseReduction::Settings::mOldSensitivity

◆ mReleaseTime

double EffectNoiseReduction::Settings::mReleaseTime

◆ mStepsPerWindowChoice

int EffectNoiseReduction::Settings::mStepsPerWindowChoice

Definition at line 242 of file NoiseReduction.cpp.

Referenced by PrefsIO(), and StepsPerWindow().

◆ mWindowSizeChoice

int EffectNoiseReduction::Settings::mWindowSizeChoice

Definition at line 241 of file NoiseReduction.cpp.

Referenced by PrefsIO(), and WindowSize().

◆ mWindowTypes

int EffectNoiseReduction::Settings::mWindowTypes

Definition at line 240 of file NoiseReduction.cpp.

Referenced by PrefsIO().


The documentation for this class was generated from the following file:
anonymous_namespace{NoiseReduction.cpp}::NRC_REDUCE_NOISE
@ NRC_REDUCE_NOISE
Definition: NoiseReduction.cpp:158
anonymous_namespace{NoiseReduction.cpp}::NRC_LEAVE_RESIDUE
@ NRC_LEAVE_RESIDUE
Definition: NoiseReduction.cpp:160
EffectNoiseReduction::Settings::mDoProfile
bool mDoProfile
Definition: NoiseReduction.cpp:222
EffectNoiseReduction::Settings::StepsPerWindow
unsigned StepsPerWindow() const
Definition: NoiseReduction.cpp:220
EffectNoiseReduction::Settings::mNoiseReductionChoice
int mNoiseReductionChoice
Definition: NoiseReduction.cpp:237
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:70
anonymous_namespace{NoiseReduction.cpp}::writePrefs
void writePrefs(const StructureType *structure, const wxString &prefix, const PrefsTableEntry< StructureType, FieldType > *fields, size_t numFields)
Definition: NoiseReduction.cpp:504
anonymous_namespace{NoiseReduction.cpp}::windowTypesInfo
const struct anonymous_namespace{NoiseReduction.cpp}::WindowTypesInfo windowTypesInfo[WT_N_WINDOW_TYPES]
EffectNoiseReduction::Settings::mWindowSizeChoice
int mWindowSizeChoice
Definition: NoiseReduction.cpp:241
XO
#define XO(s)
Definition: Internat.h:31
anonymous_namespace{NoiseReduction.cpp}::DEFAULT_STEPS_PER_WINDOW_CHOICE
@ DEFAULT_STEPS_PER_WINDOW_CHOICE
Definition: NoiseReduction.cpp:154
anonymous_namespace{NoiseReduction.cpp}::DM_OLD_METHOD
@ DM_OLD_METHOD
Definition: NoiseReduction.cpp:99
EffectNoiseReduction::Settings::mAttackTime
double mAttackTime
Definition: NoiseReduction.cpp:230
EffectNoiseReduction::Settings::mReleaseTime
double mReleaseTime
Definition: NoiseReduction.cpp:231
EffectNoiseReduction::Settings::mOldSensitivity
double mOldSensitivity
Definition: NoiseReduction.cpp:234
EffectNoiseReduction::Settings::mMethod
int mMethod
Definition: NoiseReduction.cpp:243
anonymous_namespace{NoiseReduction.cpp}::NRC_ISOLATE_NOISE
@ NRC_ISOLATE_NOISE
Definition: NoiseReduction.cpp:159
EffectNoiseReduction::Settings::mStepsPerWindowChoice
int mStepsPerWindowChoice
Definition: NoiseReduction.cpp:242
anonymous_namespace{NoiseReduction.cpp}::DM_DEFAULT_METHOD
@ DM_DEFAULT_METHOD
Definition: NoiseReduction.cpp:102
EffectNoiseReduction::Settings::WindowSize
size_t WindowSize() const
Definition: NoiseReduction.cpp:219
FileConfig::Flush
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
anonymous_namespace{NoiseReduction.cpp}::WT_DEFAULT_WINDOW_TYPES
@ WT_DEFAULT_WINDOW_TYPES
Definition: NoiseReduction.cpp:128
EffectNoiseReduction::Settings::PrefsIO
bool PrefsIO(bool read)
Definition: NoiseReduction.cpp:515
EffectNoiseReduction::Settings::mWindowTypes
int mWindowTypes
Definition: NoiseReduction.cpp:240
EffectNoiseReduction::Settings::mNoiseGain
double mNoiseGain
Definition: NoiseReduction.cpp:229
anonymous_namespace{NoiseReduction.cpp}::DM_MEDIAN
@ DM_MEDIAN
Definition: NoiseReduction.cpp:97
EffectNoiseReduction::Dialog
Dialog used with EffectNoiseReduction.
Definition: NoiseReduction.cpp:346
EffectNoiseReduction::Settings::mNewSensitivity
double mNewSensitivity
Definition: NoiseReduction.cpp:227
EffectNoiseReduction::Settings::mFreqSmoothingBands
double mFreqSmoothingBands
Definition: NoiseReduction.cpp:228
anonymous_namespace{NoiseReduction.cpp}::readPrefs
void readPrefs(StructureType *structure, const wxString &prefix, const PrefsTableEntry< StructureType, FieldType > *fields, size_t numFields)
Definition: NoiseReduction.cpp:492
anonymous_namespace{NoiseReduction.cpp}::DEFAULT_WINDOW_SIZE_CHOICE
@ DEFAULT_WINDOW_SIZE_CHOICE
Definition: NoiseReduction.cpp:153