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< EffectEditorPopulateOrExchange (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) override
 Add controls to effect panel; always succeeds. More...
 
bool TransferDataToWindow (const EffectSettings &settings) override
 
bool TransferDataFromWindow (EffectSettings &settings) override
 
- Public Member Functions inherited from StatefulPerTrackEffect
 ~StatefulPerTrackEffect () override
 
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
 
bool ProcessInitialize (EffectSettings &settings, double sampleRate, ChannelNames chanMap=nullptr) override
 
bool ProcessFinalize () noexcept override
 
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 ()
 
virtual bool Process (EffectInstance &instance, EffectSettings &settings)=0
 
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
 
virtual bool NeedsDither () const
 
virtual bool ProcessInitialize (EffectSettings &settings, double sampleRate, ChannelNames chanMap=nullptr)
 
virtual bool ProcessFinalize () noexcept
 
- 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
 
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
 
bool CanExportPresets () const override
 Whether the effect supports export of presets to files, and importing too. More...
 
bool HasOptions () const override
 
const EffectSettingsManagerGetDefinition () const override
 
virtual NumericFormatID GetSelectionFormat ()
 
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
 
unsigned TestUIFlags (unsigned mask)
 
bool Delegate (Effect &delegate, EffectSettings &settings, InstanceFinder finder={})
 Re-invoke DoEffect on another Effect object that implements the work. More...
 
- Public Member Functions inherited from EffectBase
 EffectBase ()
 
 ~EffectBase () override
 
bool IsLinearEffect () const
 
bool PreviewsFullSelection () const
 
void SetTracks (TrackList *pTracks)
 
virtual std::any BeginPreview (const EffectSettings &settings)
 Called when Preview() starts, to allow temporary effect state changes. More...
 
bool DoEffect (EffectSettings &settings, const InstanceFinder &finder, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, const EffectSettingsAccessPtr &pAccess) override
 
virtual double CalcPreviewInputLength (const EffectSettings &settings, double previewLength) const =0
 
void CountWaveTracks ()
 
- Public Member Functions inherited from EffectPlugin
EffectPluginoperator= (EffectPlugin &)=delete
 
virtual ~EffectPlugin ()
 
virtual bool HasOptions () const =0
 
virtual bool CanExportPresets () const =0
 Whether the effect supports export of presets to files, and importing too. More...
 
virtual const EffectSettingsManagerGetDefinition () const =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, const InstanceFinder &finder, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, const EffectSettingsAccessPtr &pAccess=nullptr)=0
 
- 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
 
- Public Member Functions inherited from StatefulEffectUIServices
 ~StatefulEffectUIServices () override
 
std::unique_ptr< EffectEditorPopulateUI (const EffectPlugin &plugin, ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) const override
 Allows PopulateOrExchange to return null. More...
 
virtual std::unique_ptr< EffectEditorPopulateOrExchange (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs)
 Add controls to effect panel; always succeeds. More...
 
virtual bool TransferDataToWindow (const EffectSettings &settings)
 
virtual bool TransferDataFromWindow (EffectSettings &settings)
 
- Public Member Functions inherited from BasicEffectUIServices
int ShowClientInterface (const EffectPlugin &plugin, wxWindow &parent, wxDialog &dialog, EffectEditor *pEditor, bool forceModal) const override
 
void ExportPresets (const EffectPlugin &plugin, const EffectSettings &settings) const override
 
OptionalMessage ImportPresets (const EffectPlugin &plugin, EffectSettings &settings) const override
 
void ShowOptions (const EffectPlugin &plugin) const override
 
bool ValidateUI (const EffectPlugin &context, EffectSettings &) const override
 
bool CloseUI () const override
 
- Public Member Functions inherited from EffectUIServices
virtual ~EffectUIServices ()
 
virtual int ShowHostInterface (EffectBase &plugin, wxWindow &parent, const EffectDialogFactory &factory, std::shared_ptr< EffectInstance > &pInstance, EffectSettingsAccess &access, bool forceModal=false)
 
virtual int ShowClientInterface (const EffectPlugin &plugin, wxWindow &parent, wxDialog &dialog, EffectEditor *pEditor, bool forceModal=false) const =0
 
virtual std::unique_ptr< EffectEditorPopulateUI (const EffectPlugin &plugin, ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) const =0
 Adds controls to a panel that is given as the parent window of S More...
 
virtual void ExportPresets (const EffectPlugin &plugin, const EffectSettings &settings) const =0
 
virtual OptionalMessage ImportPresets (const EffectPlugin &plugin, EffectSettings &settings) const =0
 
virtual void ShowOptions (const EffectPlugin &plugin) const =0
 
virtual bool ValidateUI (const EffectPlugin &context, EffectSettings &settings) const =0
 
virtual bool CloseUI () const =0
 

Static Public Member Functions

static EffectNoiseFetchParameters (EffectNoise &e, EffectSettings &)
 
- Static Public Member Functions inherited from Effect
static EffectFetchParameters (Effect &e, EffectSettings &)
 
- Static Public Member Functions inherited from EffectBase
static std::optional< InstancePointerFindInstance (EffectPlugin &plugin)
 
static InstanceFinder DefaultInstanceFinder (EffectPlugin &plugin)
 
- 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 Member Functions inherited from EffectUIServices
static int DoMessageBox (const EffectPlugin &plugin, const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
 

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

wxWeakRef< wxWindow > mUIParent {}
 
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 EffectPlugin
using EffectSettingsAccessPtr = std::shared_ptr< EffectSettingsAccess >
 
using InstancePointer = std::shared_ptr< EffectInstanceEx >
 
using InstanceFinder = std::function< std::optional< InstancePointer >(EffectSettings &settings) >
 
- Public Types inherited from EffectDefinitionInterface
enum class  RealtimeSince : unsigned { Never , After_3_1 , Always }
 In which versions of Audacity was an effect realtime capable? More...
 
- Public Types inherited from EffectUIServices
enum  : long { DefaultMessageBoxStyle = wxOK | wxCENTRE }
 
- Public Attributes inherited from EffectBase
std::shared_ptr< TrackListmTracks {}
 
int mNumTracks {}
 
BasicUI::ProgressDialogmProgress {}
 
double mProjectRate {}
 
WaveTrackFactorymFactory {}
 
double mT0 {}
 
double mT1 {}
 
bool mIsPreview { false }
 
- Protected Member Functions inherited from PerTrackEffect
bool DoPass1 () const
 
bool DoPass2 () const
 
bool Process (EffectInstance &instance, EffectSettings &settings) const
 
std::shared_ptr< EffectOutputTracksMakeOutputTracks ()
 
void DestroyOutputTracks () const
 
- Protected Member Functions inherited from Effect
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...
 
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, sampleCount *start, sampleCount *len)
 
- Protected Member Functions inherited from EffectBase
virtual bool CheckWhetherSkipEffect (const EffectSettings &settings) const =0
 After Init(), tell whether Process() should be skipped. More...
 
void SetLinearEffectFlag (bool linearEffectFlag)
 
void SetPreviewFullSelectionFlag (bool previewDurationFlag)
 
bool IsPreviewing () const
 
const TrackListinputTracks () const
 
const AudacityProjectFindProject () const
 
- Protected Attributes inherited from PerTrackEffect
sampleCount mSampleCnt {}
 
- Protected Attributes inherited from EffectBase
double mF0 {}
 
double mF1 {}
 
wxArrayString mPresetNames
 
unsigned mUIFlags { 0 }
 

Detailed Description

An effect to add white noise.

Definition at line 23 of file Noise.h.

Member Enumeration Documentation

◆ kTypes

enum EffectNoise::kTypes
private
Enumerator
kWhite 
kPink 
kBrownian 
nTypes 

Definition at line 73 of file Noise.h.

74 {
75 kWhite,
76 kPink,
78 nTypes
79 };
@ nTypes
Definition: Noise.h:78
@ kPink
Definition: Noise.h:76
@ kBrownian
Definition: Noise.h:77
@ kWhite
Definition: Noise.h:75

Constructor & Destructor Documentation

◆ EffectNoise()

EffectNoise::EffectNoise ( )

Definition at line 60 of file Noise.cpp.

61{
62 Parameters().Reset(*this);
63
65
66 y = z = buf0 = buf1 = buf2 = buf3 = buf4 = buf5 = buf6 = 0;
67}
void SetLinearEffectFlag(bool linearEffectFlag)
Definition: EffectBase.cpp:210
float buf3
Definition: Noise.h:67
float y
Definition: Noise.h:67
float buf0
Definition: Noise.h:67
const EffectParameterMethods & Parameters() const override
Definition: Noise.cpp:42
float buf4
Definition: Noise.h:67
float buf2
Definition: Noise.h:67
float buf6
Definition: Noise.h:67
float buf5
Definition: Noise.h:67
float z
Definition: Noise.h:67
float buf1
Definition: Noise.h:67
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 69 of file Noise.cpp.

70{
71}

Member Function Documentation

◆ FetchParameters()

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

Definition at line 27 of file Noise.h.

27{ 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 97 of file Noise.cpp.

98{
99 return 1;
100}

◆ GetDescription()

TranslatableString EffectNoise::GetDescription ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 80 of file Noise.cpp.

81{
82 return XO("Generates one of three different types of noise");
83}
XO("Cut/Copy/Paste")

References XO().

Here is the call graph for this function:

◆ GetSymbol()

ComponentInterfaceSymbol EffectNoise::GetSymbol ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 75 of file Noise.cpp.

76{
77 return Symbol;
78}
static const ComponentInterfaceSymbol Symbol
Definition: Noise.h:28

References Symbol.

◆ GetType()

EffectType EffectNoise::GetType ( ) const
overridevirtual

Type determines how it behaves.

Implements EffectDefinitionInterface.

Definition at line 92 of file Noise.cpp.

93{
94 return EffectTypeGenerate;
95}
@ 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 85 of file Noise.cpp.

86{
87 return L"Noise";
88}

◆ Parameters()

const EffectParameterMethods & EffectNoise::Parameters ( ) const
overrideprivatevirtual

Reimplemented from Effect.

Definition at line 42 of file Noise.cpp.

43{
45 Type, Amp
46 > parameters;
47 return parameters;
48}
Generates EffectParameterMethods overrides from variadic template arguments.
static constexpr EffectParameter Amp
Definition: Noise.h:84
static constexpr EnumParameter Type
Definition: Noise.h:82
EffectNoise()
Definition: Noise.cpp:60

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< EffectEditor > 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 PopulateUI instead of a DefaultEffectEditor; default implementation returns null

Reimplemented from StatefulEffectUIServices.

Definition at line 177 of file Noise.cpp.

180{
181 mUIParent = S.GetParent();
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;
199 S.GetParent(), wxID_ANY,
201 extra.GetDurationFormat(),
202 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}
XXO("&Cut/Copy/Paste Toolbar")
#define safenew
Definition: MemoryX.h:9
const NumericConverterType & NumericConverterType_TIME()
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:110
static const EnumValueSymbol kTypeStrings[nTypes]
Definition: Noise.h:80
double mAmp
Definition: Noise.h:65
NumericTextCtrl * mNoiseDurationT
Definition: Noise.h:69
wxWeakRef< wxWindow > mUIParent
Definition: Noise.h:61
int mType
Definition: Noise.h:64
virtual const EffectSettings & Get()=0
static FormatterContext SampleRateContext(double sampleRate)
const Type min
Minimum value.
const Type max
Maximum value.
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, mUIParent, nTypes, NumericConverterType_TIME(), S, safenew, FormatterContext::SampleRateContext(), 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 109 of file Noise.cpp.

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

References buf0, buf1, buf2, buf3, buf4, buf5, buf6, kBrownian, kPink, kWhite, mAmp, mSampleRate, mType, size, staffpad::audio::simd::sqrt(), y, and z.

Here is the call graph for this function:

◆ 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 StatefulEffectBase.

Definition at line 102 of file Noise.cpp.

104{
106 return true;
107}

References mSampleRate, and anonymous_namespace{ClipSegmentTest.cpp}::sampleRate.

◆ TransferDataFromWindow()

bool EffectNoise::TransferDataFromWindow ( EffectSettings settings)
overridevirtual

Update the given settings from controls; default does nothing, returns true

Reimplemented from StatefulEffectUIServices.

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:69

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

Here is the call graph for this function:

◆ TransferDataToWindow()

bool EffectNoise::TransferDataToWindow ( const EffectSettings settings)
overridevirtual

Update controls for the settings; default does nothing, returns true

Reimplemented from StatefulEffectUIServices.

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, 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 84 of file Noise.h.

Referenced by Parameters(), and PopulateOrExchange().

◆ buf0

float EffectNoise::buf0
private

Definition at line 67 of file Noise.h.

Referenced by EffectNoise(), and ProcessBlock().

◆ buf1

float EffectNoise::buf1
private

Definition at line 67 of file Noise.h.

Referenced by EffectNoise(), and ProcessBlock().

◆ buf2

float EffectNoise::buf2
private

Definition at line 67 of file Noise.h.

Referenced by EffectNoise(), and ProcessBlock().

◆ buf3

float EffectNoise::buf3
private

Definition at line 67 of file Noise.h.

Referenced by EffectNoise(), and ProcessBlock().

◆ buf4

float EffectNoise::buf4
private

Definition at line 67 of file Noise.h.

Referenced by EffectNoise(), and ProcessBlock().

◆ buf5

float EffectNoise::buf5
private

Definition at line 67 of file Noise.h.

Referenced by EffectNoise(), and ProcessBlock().

◆ buf6

float EffectNoise::buf6
private

Definition at line 67 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 80 of file Noise.h.

Referenced by PopulateOrExchange().

◆ mAmp

double EffectNoise::mAmp
private

Definition at line 65 of file Noise.h.

Referenced by PopulateOrExchange(), and ProcessBlock().

◆ mNoiseDurationT

NumericTextCtrl* EffectNoise::mNoiseDurationT
private

Definition at line 69 of file Noise.h.

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

◆ mSampleRate

double EffectNoise::mSampleRate {}
private

Definition at line 63 of file Noise.h.

Referenced by ProcessBlock(), and ProcessInitialize().

◆ mType

int EffectNoise::mType
private

Definition at line 64 of file Noise.h.

Referenced by PopulateOrExchange(), and ProcessBlock().

◆ mUIParent

wxWeakRef<wxWindow> EffectNoise::mUIParent {}
private

Definition at line 61 of file Noise.h.

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

◆ Symbol

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

Definition at line 28 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 82 of file Noise.h.

Referenced by Parameters().

◆ y

float EffectNoise::y
private

Definition at line 67 of file Noise.h.

Referenced by EffectNoise(), and ProcessBlock().

◆ z

float EffectNoise::z
private

Definition at line 67 of file Noise.h.

Referenced by EffectNoise(), and ProcessBlock().


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