Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
EffectNoise Class Referencefinal

An effect to add white noise. More...

#include <Noise.h>

Inheritance diagram for EffectNoise:
[legend]
Collaboration diagram for EffectNoise:
[legend]

Public Member Functions

 EffectNoise ()
 
virtual ~EffectNoise ()
 
ComponentInterfaceSymbol GetSymbol () const override
 
TranslatableString GetDescription () const override
 
ManualPageID ManualPage () const override
 Name of a page in the Audacity alpha manual, default is empty. More...
 
EffectType GetType () const override
 Type determines how it behaves. More...
 
unsigned GetAudioOutCount () const override
 How many output buffers to allocate at once. More...
 
bool ProcessInitialize (EffectSettings &settings, double sampleRate, ChannelNames chanMap) override
 
size_t ProcessBlock (EffectSettings &settings, const float *const *inBlock, float *const *outBlock, size_t blockLen) override
 Called for destructive effect computation. More...
 
std::unique_ptr< EffectUIValidatorPopulateOrExchange (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) override
 Add controls to effect panel; always succeeds. More...
 
bool TransferDataToWindow (const EffectSettings &settings) override
 Update controls for the settings. More...
 
bool TransferDataFromWindow (EffectSettings &settings) override
 Update the given settings from controls. More...
 
- Public Member Functions inherited from StatefulPerTrackEffect
std::shared_ptr< EffectInstanceMakeInstance () const override
 Make an object maintaining short-term state of an Effect. More...
 
size_t SetBlockSize (size_t maxBlockSize) override
 
size_t GetBlockSize () const override
 
virtual bool ProcessInitialize (EffectSettings &settings, double sampleRate, ChannelNames chanMap=nullptr)
 
virtual bool ProcessFinalize () noexcept
 
virtual size_t ProcessBlock (EffectSettings &settings, const float *const *inBlock, float *const *outBlock, size_t blockLen)=0
 Called for destructive effect computation. More...
 
- Public Member Functions inherited from StatefulEffectBase
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, EffectOutputs *pOutputs, unsigned numChannels, float sampleRate)
 
virtual bool RealtimeSuspend ()
 
virtual bool RealtimeResume ()
 
virtual bool RealtimeProcessStart (MessagePackage &package)
 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
 
virtual unsigned GetAudioInCount () const
 How many input buffers to allocate at once. More...
 
virtual unsigned GetAudioOutCount () const
 How many output buffers to allocate at once. More...
 
virtual sampleCount GetLatency () const
 
- Public Member Functions inherited from PerTrackEffect
 ~PerTrackEffect () override
 
- Public Member Functions inherited from Effect
 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...
 
OptionalMessage LoadUserPreset (const RegistryPath &name, EffectSettings &settings) const override
 
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...
 
OptionalMessage LoadFactoryPreset (int id, EffectSettings &settings) const override
 
OptionalMessage LoadFactoryDefaults (EffectSettings &settings) const override
 
virtual const EffectParameterMethodsParameters () const
 
int ShowClientInterface (wxWindow &parent, wxDialog &dialog, EffectUIValidator *pValidator, bool forceModal) override
 
EffectUIClientInterfaceGetEffectUIClientInterface () override
 Returns the EffectUIClientInterface instance for this effect. More...
 
std::unique_ptr< EffectUIValidatorPopulateUI (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) 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
 
OptionalMessage ImportPresets (EffectSettings &settings) override
 
bool HasOptions () override
 
void ShowOptions () override
 
const EffectSettingsManagerGetDefinition () 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
 
OptionalMessage 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 ()
 
- Public Member Functions inherited from EffectBase
 EffectBase ()
 
 ~EffectBase () override
 
void SetTracks (TrackList *pTracks)
 
- Public Member Functions inherited from EffectUIClientInterface
virtual ~EffectUIClientInterface ()
 
virtual int ShowClientInterface (wxWindow &parent, wxDialog &dialog, EffectUIValidator *pValidator, bool forceModal=false)=0
 
virtual bool IsGraphicalUI ()=0
 
virtual std::unique_ptr< EffectUIValidatorPopulateUI (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs)=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 OptionalMessage ImportPresets (EffectSettings &settings)=0
 
virtual bool HasOptions ()=0
 
virtual void ShowOptions ()=0
 
virtual bool ValidateUI (EffectSettings &settings)=0
 
virtual bool CloseUI ()=0
 
- Public Member Functions inherited from EffectPlugin
EffectPluginoperator= (EffectPlugin &)=delete
 
virtual ~EffectPlugin ()
 
virtual const EffectSettingsManagerGetDefinition () 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 EffectUIClientInterfaceGetEffectUIClientInterface ()=0
 Returns the EffectUIClientInterface instance for this effect. More...
 
virtual void Preview (EffectSettingsAccess &access, bool dryOnly)=0
 
virtual bool SaveSettingsAsString (const EffectSettings &settings, wxString &parms) const =0
 
virtual OptionalMessage 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...
 
- Public Member Functions inherited from EffectInstanceFactory
virtual ~EffectInstanceFactory ()
 
virtual std::shared_ptr< EffectInstanceMakeInstance () const =0
 Make an object maintaining short-term state of an Effect. More...
 
- Public Member Functions inherited from EffectSettingsManager
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 std::unique_ptr< EffectOutputsMakeOutputs () const
 Produce an object to hold values to send to effect output meters. More...
 
- Public Member Functions inherited from EffectDefinitionInterface
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...
 
- Public Member Functions inherited from ComponentInterface
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 Member Functions

static EffectNoiseFetchParameters (EffectNoise &e, EffectSettings &)
 
- Static Public Member Functions inherited from Effect
static EffectFetchParameters (Effect &e, EffectSettings &)
 
static void IncEffectCounter ()
 
- Static Public Member Functions inherited from EffectDefinitionInterface
static Identifier GetSquashedName (const Identifier &ident)
 A utility that strips spaces and CamelCases a name. More...
 

Static Public Attributes

static const ComponentInterfaceSymbol Symbol { XO("Noise") }
 
- Static Public Attributes inherited from EffectPlugin
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 Types

enum  kTypes { kWhite , kPink , kBrownian , nTypes }
 

Private Member Functions

const EffectParameterMethodsParameters () const override
 

Private Attributes

double mSampleRate {}
 
int mType
 
double mAmp
 
float y
 
float z
 
float buf0
 
float buf1
 
float buf2
 
float buf3
 
float buf4
 
float buf5
 
float buf6
 
NumericTextCtrlmNoiseDurationT
 

Static Private Attributes

static const EnumValueSymbol kTypeStrings [nTypes]
 
static constexpr EnumParameter Type
 
static constexpr EffectParameter Amp
 

Additional Inherited Members

- Public Types inherited from StatefulEffectBase
using MessagePackage = EffectInstance::MessagePackage
 
- Public Types inherited from Effect
enum  : long { DefaultMessageBoxStyle = wxOK | wxCENTRE }
 
- Public Types inherited from EffectPlugin
using EffectSettingsAccessPtr = std::shared_ptr< EffectSettingsAccess >
 
- Public Types inherited from EffectDefinitionInterface
enum class  RealtimeSince : unsigned { Never , Since_3_2 , Always }
 In which versions of Audacity was an effect realtime capable? More...
 
- Protected Member Functions inherited from PerTrackEffect
bool DoPass1 () const
 
bool DoPass2 () const
 
bool Process (EffectInstance &instance, EffectSettings &settings) const
 
- Protected Member Functions inherited from Effect
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< EffectUIValidatorPopulateOrExchange (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs)
 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< AddedAnalysisTrackAddAnalysisTrack (const wxString &name=wxString())
 
ModifiedAnalysisTrack ModifyAnalysisTrack (const LabelTrack *pOrigTrack, const wxString &name=wxString())
 
TrackAddToOutputTracks (const std::shared_ptr< Track > &t)
 
- Protected Member Functions inherited from EffectBase
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 TrackListinputTracks () const
 
const AudacityProjectFindProject () const
 
- Protected Attributes inherited from PerTrackEffect
sampleCount mSampleCnt {}
 
- Protected Attributes inherited from Effect
wxWeakRef< wxDialog > mHostUIDialog
 This smart pointer tracks the lifetime of the dialog. More...
 
wxWindow * mUIParent {}
 
- Protected Attributes inherited from EffectBase
BasicUI::ProgressDialogmProgress {}
 
double mProjectRate {}
 
WaveTrackFactorymFactory {}
 
std::shared_ptr< TrackListmOutputTracks
 
double mT0 {}
 
double mT1 {}
 
wxArrayString mPresetNames
 
unsigned mUIFlags { 0 }
 
- Static Protected Attributes inherited from EffectBase
static int nEffectsDone = 0
 

Detailed Description

An effect to add white noise.

Definition at line 22 of file Noise.h.

Member Enumeration Documentation

◆ kTypes

enum EffectNoise::kTypes
private
Enumerator
kWhite 
kPink 
kBrownian 
nTypes 

Definition at line 70 of file Noise.h.

71 {
72 kWhite,
73 kPink,
75 nTypes
76 };
@ nTypes
Definition: Noise.h:75
@ kPink
Definition: Noise.h:73
@ kBrownian
Definition: Noise.h:74
@ kWhite
Definition: Noise.h:72

Constructor & Destructor Documentation

◆ EffectNoise()

EffectNoise::EffectNoise ( )

Definition at line 62 of file Noise.cpp.

63{
64 Parameters().Reset(*this);
65
67
68 y = z = buf0 = buf1 = buf2 = buf3 = buf4 = buf5 = buf6 = 0;
69}
void SetLinearEffectFlag(bool linearEffectFlag)
Definition: EffectBase.cpp:222
float buf3
Definition: Noise.h:64
float y
Definition: Noise.h:64
float buf0
Definition: Noise.h:64
const EffectParameterMethods & Parameters() const override
Definition: Noise.cpp:44
float buf4
Definition: Noise.h:64
float buf2
Definition: Noise.h:64
float buf6
Definition: Noise.h:64
float buf5
Definition: Noise.h:64
float z
Definition: Noise.h:64
float buf1
Definition: Noise.h:64
virtual void Reset(Effect &effect) const =0

References buf0, buf1, buf2, buf3, buf4, buf5, buf6, Parameters(), EffectParameterMethods::Reset(), EffectBase::SetLinearEffectFlag(), y, and z.

Referenced by Parameters().

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

◆ ~EffectNoise()

EffectNoise::~EffectNoise ( )
virtual

Definition at line 71 of file Noise.cpp.

72{
73}

Member Function Documentation

◆ FetchParameters()

static EffectNoise * EffectNoise::FetchParameters ( EffectNoise e,
EffectSettings  
)
inlinestatic

Definition at line 26 of file Noise.h.

26{ return &e; }

◆ GetAudioOutCount()

unsigned EffectNoise::GetAudioOutCount ( ) const
overridevirtual

How many output buffers to allocate at once.

The result is not necessarily well defined before RealtimeInitialize Default implementation returns 0

Reimplemented from StatefulEffectBase.

Definition at line 99 of file Noise.cpp.

100{
101 return 1;
102}

◆ GetDescription()

TranslatableString EffectNoise::GetDescription ( ) const
overridevirtual

Reimplemented from Effect.

Definition at line 82 of file Noise.cpp.

83{
84 return XO("Generates one of three different types of noise");
85}
#define XO(s)
Definition: Internat.h:31

References XO.

◆ GetSymbol()

ComponentInterfaceSymbol EffectNoise::GetSymbol ( ) const
overridevirtual

Reimplemented from Effect.

Definition at line 77 of file Noise.cpp.

78{
79 return Symbol;
80}
static const ComponentInterfaceSymbol Symbol
Definition: Noise.h:27

References Symbol.

◆ GetType()

EffectType EffectNoise::GetType ( ) const
overridevirtual

Type determines how it behaves.

Reimplemented from Effect.

Definition at line 94 of file Noise.cpp.

95{
96 return EffectTypeGenerate;
97}
@ EffectTypeGenerate

References EffectTypeGenerate.

◆ ManualPage()

ManualPageID EffectNoise::ManualPage ( ) const
overridevirtual

Name of a page in the Audacity alpha manual, default is empty.

Reimplemented from EffectDefinitionInterface.

Definition at line 87 of file Noise.cpp.

88{
89 return L"Noise";
90}

◆ Parameters()

const EffectParameterMethods & EffectNoise::Parameters ( ) const
overrideprivatevirtual

Reimplemented from Effect.

Definition at line 44 of file Noise.cpp.

45{
47 Type, Amp
48 > parameters;
49 return parameters;
50}
Generates EffectParameterMethods overrides from variadic template arguments.
static constexpr EffectParameter Amp
Definition: Noise.h:81
static constexpr EnumParameter Type
Definition: Noise.h:79
EffectNoise()
Definition: Noise.cpp:62

References Amp, EffectNoise(), and Type.

Referenced by EffectNoise().

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

◆ PopulateOrExchange()

std::unique_ptr< EffectUIValidator > EffectNoise::PopulateOrExchange ( ShuttleGui S,
EffectInstance instance,
EffectSettingsAccess access,
const EffectOutputs pOutputs 
)
overridevirtual

Add controls to effect panel; always succeeds.

Returns
if not null, then return it from Effect::PopulateUI instead of a DefaultEffectUIValidator; default implementation returns null

Reimplemented from Effect.

Definition at line 179 of file Noise.cpp.

182{
183 wxASSERT(nTypes == WXSIZEOF(kTypeStrings));
184
185 S.StartMultiColumn(2, wxCENTER);
186 {
187 S.Validator<wxGenericValidator>(&mType)
188 .AddChoice(XXO("&Noise type:"), Msgids(kTypeStrings, nTypes));
189
190 S
191 .Validator<FloatingPointValidator<double>>(
192 6, &mAmp, NumValidatorStyle::NO_TRAILING_ZEROES, Amp.min, Amp.max )
193 .AddTextBox(XXO("&Amplitude (0-1):"), L"", 12);
194
195 S.AddPrompt(XXO("&Duration:"));
196 auto &extra = access.Get().extra;
198 NumericTextCtrl(S.GetParent(), wxID_ANY,
200 extra.GetDurationFormat(),
201 extra.GetDuration(),
204 .AutoPos(true));
205 S.Name(XO("Duration"))
206 .Position(wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL)
207 .AddWindow(mNoiseDurationT);
208 }
209 S.EndMultiColumn();
210 return nullptr;
211}
#define XXO(s)
Definition: Internat.h:44
#define safenew
Definition: MemoryX.h:10
TranslatableStrings Msgids(const EnumValueSymbol strings[], size_t nStrings)
Convenience function often useful when adding choice controls.
#define S(N)
Definition: ToChars.cpp:64
double mProjectRate
Definition: EffectBase.h:101
static const EnumValueSymbol kTypeStrings[nTypes]
Definition: Noise.h:77
double mAmp
Definition: Noise.h:62
NumericTextCtrl * mNoiseDurationT
Definition: Noise.h:66
int mType
Definition: Noise.h:61
virtual const EffectSettings & Get()=0
const Type min
Minimum value.
Definition: Shuttle.h:30
const Type max
Maximum value.
Definition: Shuttle.h:31
EffectSettingsExtra extra
Options & AutoPos(bool enable)

References Amp, NumericTextCtrl::Options::AutoPos(), EffectSettings::extra, EffectSettingsAccess::Get(), kTypeStrings, mAmp, EffectParameter< Structure, Member, Type, Value >::max, EffectParameter< Structure, Member, Type, Value >::min, mNoiseDurationT, EffectBase::mProjectRate, Msgids(), mType, nTypes, S, safenew, NumericConverter::TIME, XO, and XXO.

Here is the call graph for this function:

◆ ProcessBlock()

size_t EffectNoise::ProcessBlock ( EffectSettings settings,
const float *const *  inBlock,
float *const *  outBlock,
size_t  blockLen 
)
overridevirtual

Called for destructive effect computation.

Implements StatefulPerTrackEffect.

Definition at line 111 of file Noise.cpp.

113{
114 float *buffer = outbuf[0];
115
116 float white;
117 float amplitude;
118 float div = ((float) RAND_MAX) / 2.0f;
119
120 switch (mType)
121 {
122 default:
123 case kWhite: // white
124 for (decltype(size) i = 0; i < size; i++)
125 {
126 buffer[i] = mAmp * ((rand() / div) - 1.0f);
127 }
128 break;
129
130 case kPink: // pink
131 // based on Paul Kellet's "instrumentation grade" algorithm.
132
133 // 0.129f is an experimental normalization factor.
134 amplitude = mAmp * 0.129f;
135 for (decltype(size) i = 0; i < size; i++)
136 {
137 white = (rand() / div) - 1.0f;
138 buf0 = 0.99886f * buf0 + 0.0555179f * white;
139 buf1 = 0.99332f * buf1 + 0.0750759f * white;
140 buf2 = 0.96900f * buf2 + 0.1538520f * white;
141 buf3 = 0.86650f * buf3 + 0.3104856f * white;
142 buf4 = 0.55000f * buf4 + 0.5329522f * white;
143 buf5 = -0.7616f * buf5 - 0.0168980f * white;
144 buffer[i] = amplitude *
145 (buf0 + buf1 + buf2 + buf3 + buf4 + buf5 + buf6 + white * 0.5362);
146 buf6 = white * 0.115926;
147 }
148 break;
149
150 case kBrownian: // Brownian
151 //float leakage=0.997; // experimental value at 44.1kHz
152 //double scaling = 0.05; // experimental value at 44.1kHz
153 // min and max protect against instability at extreme sample rates.
154 float leakage = ((mSampleRate - 144.0) / mSampleRate < 0.9999)
155 ? (mSampleRate - 144.0) / mSampleRate
156 : 0.9999f;
157
158 float scaling = (9.0 / sqrt(mSampleRate) > 0.01)
159 ? 9.0 / sqrt(mSampleRate)
160 : 0.01f;
161
162 for (decltype(size) i = 0; i < size; i++)
163 {
164 white = (rand() / div) - 1.0f;
165 z = leakage * y + white * scaling;
166 y = fabs(z) > 1.0
167 ? leakage * y - white * scaling
168 : z;
169 buffer[i] = mAmp * y;
170 }
171 break;
172 }
173
174 return size;
175}
double mSampleRate
Definition: Noise.h:60

References buf0, buf1, buf2, buf3, buf4, buf5, buf6, kBrownian, kPink, kWhite, mAmp, mSampleRate, mType, size, y, and z.

◆ ProcessInitialize()

bool EffectNoise::ProcessInitialize ( EffectSettings settings,
double  sampleRate,
ChannelNames  chanMap 
)
overridevirtual

Called at start of destructive processing, for each (mono/stereo) track Default implementation does nothing, returns true

Parameters
chanMapnull or array terminated with ChannelNameEOL. Do not retain the pointer
Postcondition
GetAudioInCount() and GetAudioOutCount() are well defined

Reimplemented from StatefulPerTrackEffect.

Definition at line 104 of file Noise.cpp.

106{
107 mSampleRate = sampleRate;
108 return true;
109}

References mSampleRate.

◆ TransferDataFromWindow()

bool EffectNoise::TransferDataFromWindow ( EffectSettings settings)
overridevirtual

Update the given settings from controls.

Reimplemented from Effect.

Definition at line 224 of file Noise.cpp.

225{
226 if (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
227 {
228 return false;
229 }
230
231 settings.extra.SetDuration(mNoiseDurationT->GetValue());
232 return true;
233}
static Settings & settings()
Definition: TrackInfo.cpp:87
wxWindow * mUIParent
Definition: Effect.h:307

References NumericConverter::GetValue(), mNoiseDurationT, Effect::mUIParent, and settings().

Here is the call graph for this function:

◆ TransferDataToWindow()

bool EffectNoise::TransferDataToWindow ( const EffectSettings settings)
overridevirtual

Update controls for the settings.

Reimplemented from Effect.

Definition at line 213 of file Noise.cpp.

214{
215 if (!mUIParent->TransferDataToWindow())
216 {
217 return false;
218 }
219
220 mNoiseDurationT->SetValue(settings.extra.GetDuration());
221 return true;
222}
void SetValue(double newValue)

References mNoiseDurationT, Effect::mUIParent, settings(), and NumericTextCtrl::SetValue().

Here is the call graph for this function:

Member Data Documentation

◆ Amp

constexpr EffectParameter EffectNoise::Amp
staticconstexprprivate
Initial value:
L"Amplitude", 0.8, 0.0, 1.0, 1 }

Definition at line 81 of file Noise.h.

Referenced by Parameters(), and PopulateOrExchange().

◆ buf0

float EffectNoise::buf0
private

Definition at line 64 of file Noise.h.

Referenced by EffectNoise(), and ProcessBlock().

◆ buf1

float EffectNoise::buf1
private

Definition at line 64 of file Noise.h.

Referenced by EffectNoise(), and ProcessBlock().

◆ buf2

float EffectNoise::buf2
private

Definition at line 64 of file Noise.h.

Referenced by EffectNoise(), and ProcessBlock().

◆ buf3

float EffectNoise::buf3
private

Definition at line 64 of file Noise.h.

Referenced by EffectNoise(), and ProcessBlock().

◆ buf4

float EffectNoise::buf4
private

Definition at line 64 of file Noise.h.

Referenced by EffectNoise(), and ProcessBlock().

◆ buf5

float EffectNoise::buf5
private

Definition at line 64 of file Noise.h.

Referenced by EffectNoise(), and ProcessBlock().

◆ buf6

float EffectNoise::buf6
private

Definition at line 64 of file Noise.h.

Referenced by EffectNoise(), and ProcessBlock().

◆ kTypeStrings

const EnumValueSymbol EffectNoise::kTypeStrings
staticprivate
Initial value:
=
{
{ XC("White", "noise") },
{ XC("Pink", "noise") },
{ XC("Brownian", "noise") }
}
#define XC(s, c)
Definition: Internat.h:37

Definition at line 77 of file Noise.h.

Referenced by PopulateOrExchange().

◆ mAmp

double EffectNoise::mAmp
private

Definition at line 62 of file Noise.h.

Referenced by PopulateOrExchange(), and ProcessBlock().

◆ mNoiseDurationT

NumericTextCtrl* EffectNoise::mNoiseDurationT
private

Definition at line 66 of file Noise.h.

Referenced by PopulateOrExchange(), TransferDataFromWindow(), and TransferDataToWindow().

◆ mSampleRate

double EffectNoise::mSampleRate {}
private

Definition at line 60 of file Noise.h.

Referenced by ProcessBlock(), and ProcessInitialize().

◆ mType

int EffectNoise::mType
private

Definition at line 61 of file Noise.h.

Referenced by PopulateOrExchange(), and ProcessBlock().

◆ Symbol

const ComponentInterfaceSymbol EffectNoise::Symbol { XO("Noise") }
static

Definition at line 27 of file Noise.h.

Referenced by GetSymbol().

◆ Type

constexpr EnumParameter EffectNoise::Type
staticconstexprprivate
Initial value:
L"Type", kWhite, 0, nTypes - 1, 1, kTypeStrings, nTypes }

Definition at line 79 of file Noise.h.

Referenced by Parameters().

◆ y

float EffectNoise::y
private

Definition at line 64 of file Noise.h.

Referenced by EffectNoise(), and ProcessBlock().

◆ z

float EffectNoise::z
private

Definition at line 64 of file Noise.h.

Referenced by EffectNoise(), and ProcessBlock().


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