Audacity 3.2.0
Public Member Functions | Public Attributes | List of all members
EffectWahwah::Instance Struct Reference
Inheritance diagram for EffectWahwah::Instance:
[legend]
Collaboration diagram for EffectWahwah::Instance:
[legend]

Public Member Functions

 Instance (const PerTrackEffect &effect)
 
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...
 
bool RealtimeInitialize (EffectSettings &settings, double) override
 
bool RealtimeAddProcessor (EffectSettings &settings, EffectOutputs *pOutputs, unsigned numChannels, float sampleRate) override
 
bool RealtimeFinalize (EffectSettings &settings) noexcept override
 
size_t RealtimeProcess (size_t group, EffectSettings &settings, const float *const *inbuf, float *const *outbuf, size_t numSamples) override
 
void InstanceInit (EffectSettings &settings, EffectWahwahState &data, float sampleRate)
 
size_t InstanceProcess (EffectSettings &settings, EffectWahwahState &data, const float *const *inBlock, float *const *outBlock, size_t blockLen)
 
unsigned GetAudioInCount () const override
 How many input buffers to allocate at once. More...
 
unsigned GetAudioOutCount () const override
 How many output buffers to allocate at once. More...
 
- Public Member Functions inherited from PerTrackEffect::Instance
 Instance (const PerTrackEffect &processor)
 
 ~Instance () override
 
bool Process (EffectSettings &settings) final
 Uses the other virtual functions of this class. More...
 
bool ProcessInitialize (EffectSettings &settings, double sampleRate, ChannelNames chanMap) override
 
bool ProcessFinalize () noexcept override
 
- Public Member Functions inherited from EffectInstanceEx
virtual bool Init ()
 Call once to set up state for whole list of tracks to be processed. More...
 
virtual bool Process (EffectSettings &settings)=0
 Actually do the effect here. More...
 
 ~EffectInstanceEx () override
 
- Public Member Functions inherited from EffectInstance
virtual ~EffectInstance ()
 
virtual size_t GetBlockSize () const =0
 
virtual size_t SetBlockSize (size_t maxBlockSize)=0
 
virtual unsigned GetAudioInCount () const =0
 How many input buffers to allocate at once. More...
 
virtual unsigned GetAudioOutCount () const =0
 How many output buffers to allocate at once. 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 std::unique_ptr< MessageMakeMessage () const
 Called on the main thread, in which the result may be cloned. More...
 
virtual bool UsesMessages () const noexcept
 
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 void RealtimePassThrough (size_t group, EffectSettings &settings, const float *const *inBuf, size_t numSamples)
 Called instead of RealtimeProcess when the effect is bypassed. Default implementation does nothing. More...
 
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 GetTailSize () const
 
virtual SampleCount GetLatency (const EffectSettings &settings, double sampleRate) const
 
virtual bool NeedsDither () const
 
virtual bool ProcessInitialize (EffectSettings &settings, double sampleRate, ChannelNames chanMap)=0
 
virtual bool ProcessFinalize () noexcept=0
 
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 EffectInstanceWithBlockSize
 ~EffectInstanceWithBlockSize () override
 
size_t GetBlockSize () const override
 
size_t SetBlockSize (size_t maxBlockSize) override
 

Public Attributes

EffectWahwahState mState
 
std::vector< EffectWahwah::InstancemSlaves
 

Additional Inherited Members

- Public Types inherited from EffectInstance
using Message = EffectSettingsAccess::Message
 
using SampleCount = uint64_t
 
- Protected Attributes inherited from PerTrackEffect::Instance
const PerTrackEffectmProcessor
 
- Protected Attributes inherited from EffectInstanceWithBlockSize
size_t mBlockSize { 0 }
 

Detailed Description

Definition at line 129 of file Wahwah.cpp.

Constructor & Destructor Documentation

◆ Instance()

EffectWahwah::Instance::Instance ( const PerTrackEffect effect)
inlineexplicit

Definition at line 133 of file Wahwah.cpp.

Member Function Documentation

◆ GetAudioInCount()

unsigned EffectWahwah::Instance::GetAudioInCount ( ) const
overridevirtual

How many input buffers to allocate at once.

If the instance processes channels independently, this can return 1 The result is not necessarily well defined before RealtimeInitialize

Implements EffectInstance.

Definition at line 470 of file Wahwah.cpp.

471{
472 return 1;
473}

◆ GetAudioOutCount()

unsigned EffectWahwah::Instance::GetAudioOutCount ( ) const
overridevirtual

How many output buffers to allocate at once.

The result is not necessarily well defined before RealtimeInitialize

Implements EffectInstance.

Definition at line 465 of file Wahwah.cpp.

466{
467 return 1;
468}

◆ InstanceInit()

void EffectWahwah::Instance::InstanceInit ( EffectSettings settings,
EffectWahwahState data,
float  sampleRate 
)

Definition at line 390 of file Wahwah.cpp.

391{
392 auto& ms = GetSettings(settings);
393
394 data.samplerate = sampleRate;
395 data.lfoskip = ms.mFreq * 2 * M_PI / sampleRate;
396 data.skipcount = 0;
397 data.xn1 = 0;
398 data.xn2 = 0;
399 data.yn1 = 0;
400 data.yn2 = 0;
401 data.b0 = 0;
402 data.b1 = 0;
403 data.b2 = 0;
404 data.a0 = 0;
405 data.a1 = 0;
406 data.a2 = 0;
407
408 data.depth = ms.mDepth / 100.0;
409 data.freqofs = ms.mFreqOfs / 100.0;
410 data.phase = ms.mPhase * M_PI / 180.0;
411 data.outgain = DB_TO_LINEAR(ms.mOutGain);
412}
#define M_PI
Definition: Distortion.cpp:30
#define DB_TO_LINEAR(x)
Definition: MemoryX.h:338
static Settings & settings()
Definition: TrackInfo.cpp:47
double yn2
Definition: Wahwah.h:34
double freqofs
Definition: Wahwah.h:29
double xn2
Definition: Wahwah.h:34
float samplerate
Definition: Wahwah.h:27
unsigned long skipcount
Definition: Wahwah.h:33
double yn1
Definition: Wahwah.h:34
double outgain
Definition: Wahwah.h:31
double xn1
Definition: Wahwah.h:34
double phase
Definition: Wahwah.h:30
double depth
Definition: Wahwah.h:28
double lfoskip
Definition: Wahwah.h:32
static EffectWahwahSettings & GetSettings(EffectSettings &settings)
Assume settings originated from MakeSettings() and copies thereof.
Definition: Effect.h:166

References EffectWahwahState::a0, EffectWahwahState::a1, EffectWahwahState::a2, EffectWahwahState::b0, EffectWahwahState::b1, EffectWahwahState::b2, DB_TO_LINEAR, EffectWahwahState::depth, EffectWahwahState::freqofs, EffectWithSettings< EffectWahwahSettings, StatelessPerTrackEffect >::GetSettings(), EffectWahwahState::lfoskip, M_PI, EffectWahwahState::outgain, EffectWahwahState::phase, anonymous_namespace{ClipSegmentTest.cpp}::sampleRate, EffectWahwahState::samplerate, settings(), EffectWahwahState::skipcount, EffectWahwahState::xn1, EffectWahwahState::xn2, EffectWahwahState::yn1, and EffectWahwahState::yn2.

Here is the call graph for this function:

◆ InstanceProcess()

size_t EffectWahwah::Instance::InstanceProcess ( EffectSettings settings,
EffectWahwahState data,
const float *const *  inBlock,
float *const *  outBlock,
size_t  blockLen 
)

Definition at line 414 of file Wahwah.cpp.

417{
418 auto& ms = GetSettings(settings);
419
420 const float *ibuf = inBlock[0];
421 float *obuf = outBlock[0];
422 double frequency, omega, sn, cs, alpha;
423 double in, out;
424
425 data.lfoskip = ms.mFreq * 2 * M_PI / data.samplerate;
426 data.depth = ms.mDepth / 100.0;
427 data.freqofs = ms.mFreqOfs / 100.0;
428
429 data.phase = ms.mPhase * M_PI / 180.0;
430 data.outgain = DB_TO_LINEAR(ms.mOutGain);
431
432 for (decltype(blockLen) i = 0; i < blockLen; i++)
433 {
434 in = (double) ibuf[i];
435
436 if ((data.skipcount++) % lfoskipsamples == 0)
437 {
438 frequency = (1 + cos(data.skipcount * data.lfoskip + data.phase)) / 2;
439 frequency = frequency * data.depth * (1 - data.freqofs) + data.freqofs;
440 frequency = exp((frequency - 1) * 6);
441 omega = M_PI * frequency;
442 sn = sin(omega);
443 cs = cos(omega);
444 alpha = sn / (2 * ms.mRes);
445 data.b0 = (1 - cs) / 2;
446 data.b1 = 1 - cs;
447 data.b2 = (1 - cs) / 2;
448 data.a0 = 1 + alpha;
449 data.a1 = -2 * cs;
450 data.a2 = 1 - alpha;
451 };
452 out = (data.b0 * in + data.b1 * data.xn1 + data.b2 * data.xn2 - data.a1 * data.yn1 - data.a2 * data.yn2) / data.a0;
453 data.xn2 = data.xn1;
454 data.xn1 = in;
455 data.yn2 = data.yn1;
456 data.yn1 = out;
457 out *= data.outgain;
458
459 obuf[i] = (float) out;
460 }
461
462 return blockLen;
463}
#define lfoskipsamples
Definition: Wahwah.cpp:43

References EffectWahwahState::a0, EffectWahwahState::a1, EffectWahwahState::a2, EffectWahwahState::b0, EffectWahwahState::b1, EffectWahwahState::b2, DB_TO_LINEAR, EffectWahwahState::depth, EffectWahwahState::freqofs, EffectWithSettings< EffectWahwahSettings, StatelessPerTrackEffect >::GetSettings(), EffectWahwahState::lfoskip, lfoskipsamples, M_PI, EffectWahwahState::outgain, EffectWahwahState::phase, EffectWahwahState::samplerate, settings(), EffectWahwahState::skipcount, EffectWahwahState::xn1, EffectWahwahState::xn2, EffectWahwahState::yn1, and EffectWahwahState::yn2.

Here is the call graph for this function:

◆ ProcessBlock()

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

Called for destructive effect computation.

Implements EffectInstance.

Definition at line 222 of file Wahwah.cpp.

224{
225 return InstanceProcess(settings, mState, inBlock, outBlock, blockLen);
226}
EffectWahwahState mState
Definition: Wahwah.cpp:165
size_t InstanceProcess(EffectSettings &settings, EffectWahwahState &data, const float *const *inBlock, float *const *outBlock, size_t blockLen)
Definition: Wahwah.cpp:414

References mState, and settings().

Here is the call graph for this function:

◆ ProcessInitialize()

bool EffectWahwah::Instance::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

Implements EffectInstance.

Definition at line 213 of file Wahwah.cpp.

215{
217 if (chanMap[0] == ChannelNameFrontRight)
218 mState.phase += M_PI;
219 return true;
220}
@ ChannelNameFrontRight
void InstanceInit(EffectSettings &settings, EffectWahwahState &data, float sampleRate)
Definition: Wahwah.cpp:390

References ChannelNameFrontRight, M_PI, mState, anonymous_namespace{ClipSegmentTest.cpp}::sampleRate, and settings().

Here is the call graph for this function:

◆ RealtimeAddProcessor()

bool EffectWahwah::Instance::RealtimeAddProcessor ( EffectSettings settings,
EffectOutputs pOutputs,
unsigned  numChannels,
float  sampleRate 
)
overridevirtual
Returns
success Default implementation does nothing, returns true

Reimplemented from EffectInstance.

Definition at line 235 of file Wahwah.cpp.

237{
239
240 InstanceInit(settings, slave.mState, sampleRate);
241
242 mSlaves.push_back(slave);
243
244 return true;
245}
const PerTrackEffect & mProcessor
std::vector< EffectWahwah::Instance > mSlaves
Definition: Wahwah.cpp:166

References mState, anonymous_namespace{ClipSegmentTest.cpp}::sampleRate, and settings().

Here is the call graph for this function:

◆ RealtimeFinalize()

bool EffectWahwah::Instance::RealtimeFinalize ( EffectSettings settings)
overridevirtualnoexcept
Returns
success Default implementation does nothing, returns true

Reimplemented from EffectInstance.

Definition at line 247 of file Wahwah.cpp.

248{
249 mSlaves.clear();
250
251 return true;
252}

◆ RealtimeInitialize()

bool EffectWahwah::Instance::RealtimeInitialize ( EffectSettings settings,
double  sampleRate 
)
overridevirtual
Returns
success
Postcondition
GetAudioInCount() and GetAudioOutCount() are well defined

Default implementation does nothing, returns false (so assume realtime is not supported). Other member functions related to realtime return true or zero, but will not be called, unless a derived class overrides RealtimeInitialize.

Reimplemented from EffectInstance.

Definition at line 228 of file Wahwah.cpp.

229{
230 SetBlockSize(512);
231 mSlaves.clear();
232 return true;
233}
size_t SetBlockSize(size_t maxBlockSize) override

◆ RealtimeProcess()

size_t EffectWahwah::Instance::RealtimeProcess ( size_t  group,
EffectSettings settings,
const float *const *  inBuf,
float *const *  outBuf,
size_t  numSamples 
)
overridevirtual
Returns
success Default implementation does nothing, returns 0

Reimplemented from EffectInstance.

Definition at line 254 of file Wahwah.cpp.

256{
257 if (group >= mSlaves.size())
258 return 0;
259 return InstanceProcess(settings, mSlaves[group].mState, inbuf, outbuf, numSamples);
260}

References mState, and settings().

Here is the call graph for this function:

Member Data Documentation

◆ mSlaves

std::vector<EffectWahwah::Instance> EffectWahwah::Instance::mSlaves

Definition at line 166 of file Wahwah.cpp.

◆ mState

EffectWahwahState EffectWahwah::Instance::mState

Definition at line 165 of file Wahwah.cpp.

Referenced by RealtimeAddProcessor().


The documentation for this struct was generated from the following file: