Audacity 3.2.0
Public Member Functions | Public Attributes | List of all members
WahWahBase::Instance Struct Reference

#include <WahWahBase.h>

Inheritance diagram for WahWahBase::Instance:
[legend]
Collaboration diagram for WahWahBase::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< WahWahBase::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 80 of file WahWahBase.h.

Constructor & Destructor Documentation

◆ Instance()

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

Definition at line 84 of file WahWahBase.h.

Member Function Documentation

◆ GetAudioInCount()

unsigned WahWahBase::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 215 of file WahWahBase.cpp.

216{
217 return 1;
218}

◆ GetAudioOutCount()

unsigned WahWahBase::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 210 of file WahWahBase.cpp.

211{
212 return 1;
213}

◆ InstanceInit()

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

Definition at line 132 of file WahWahBase.cpp.

134{
135 auto& ms = GetSettings(settings);
136
137 data.samplerate = sampleRate;
138 data.lfoskip = ms.mFreq * 2 * M_PI / sampleRate;
139 data.skipcount = 0;
140 data.xn1 = 0;
141 data.xn2 = 0;
142 data.yn1 = 0;
143 data.yn2 = 0;
144 data.b0 = 0;
145 data.b1 = 0;
146 data.b2 = 0;
147 data.a0 = 0;
148 data.a1 = 0;
149 data.a2 = 0;
150
151 data.depth = ms.mDepth / 100.0;
152 data.freqofs = ms.mFreqOfs / 100.0;
153 data.phase = ms.mPhase * M_PI / 180.0;
154 data.outgain = DB_TO_LINEAR(ms.mOutGain);
155}
#define M_PI
Definition: Distortion.cpp:22
#define DB_TO_LINEAR(x)
Definition: MemoryX.h:338
static Settings & settings()
Definition: TrackInfo.cpp:51
unsigned long skipcount
Definition: WahWahBase.h:24
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, PerTrackEffect >::GetSettings(), EffectWahwahState::lfoskip, M_PI, EffectWahwahState::outgain, EffectWahwahState::phase, EffectWahwahState::samplerate, anonymous_namespace{ClipSegmentTest.cpp}::sampleRate, settings(), EffectWahwahState::skipcount, EffectWahwahState::xn1, EffectWahwahState::xn2, EffectWahwahState::yn1, and EffectWahwahState::yn2.

Referenced by ProcessInitialize().

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

◆ InstanceProcess()

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

Definition at line 157 of file WahWahBase.cpp.

160{
161 auto& ms = GetSettings(settings);
162
163 const float* ibuf = inBlock[0];
164 float* obuf = outBlock[0];
165 double frequency, omega, sn, cs, alpha;
166 double in, out;
167
168 data.lfoskip = ms.mFreq * 2 * M_PI / data.samplerate;
169 data.depth = ms.mDepth / 100.0;
170 data.freqofs = ms.mFreqOfs / 100.0;
171
172 data.phase = ms.mPhase * M_PI / 180.0;
173 data.outgain = DB_TO_LINEAR(ms.mOutGain);
174
175 for (decltype(blockLen) i = 0; i < blockLen; i++)
176 {
177 in = (double)ibuf[i];
178
179 if ((data.skipcount++) % lfoskipsamples == 0)
180 {
181 frequency = (1 + cos(data.skipcount * data.lfoskip + data.phase)) / 2;
182 frequency = frequency * data.depth * (1 - data.freqofs) + data.freqofs;
183 frequency = exp((frequency - 1) * 6);
184 omega = M_PI * frequency;
185 sn = sin(omega);
186 cs = cos(omega);
187 alpha = sn / (2 * ms.mRes);
188 data.b0 = (1 - cs) / 2;
189 data.b1 = 1 - cs;
190 data.b2 = (1 - cs) / 2;
191 data.a0 = 1 + alpha;
192 data.a1 = -2 * cs;
193 data.a2 = 1 - alpha;
194 };
195 out = (data.b0 * in + data.b1 * data.xn1 + data.b2 * data.xn2 -
196 data.a1 * data.yn1 - data.a2 * data.yn2) /
197 data.a0;
198 data.xn2 = data.xn1;
199 data.xn1 = in;
200 data.yn2 = data.yn1;
201 data.yn1 = out;
202 out *= data.outgain;
203
204 obuf[i] = (float)out;
205 }
206
207 return blockLen;
208}
#define lfoskipsamples
Definition: WahWahBase.cpp:26

References EffectWahwahState::a0, EffectWahwahState::a1, EffectWahwahState::a2, EffectWahwahState::b0, EffectWahwahState::b1, EffectWahwahState::b2, DB_TO_LINEAR, EffectWahwahState::depth, EffectWahwahState::freqofs, EffectWithSettings< EffectWahwahSettings, PerTrackEffect >::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 WahWahBase::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 87 of file WahWahBase.cpp.

90{
91 return InstanceProcess(settings, mState, inBlock, outBlock, blockLen);
92}
EffectWahwahState mState
Definition: WahWahBase.h:121
size_t InstanceProcess(EffectSettings &settings, EffectWahwahState &data, const float *const *inBlock, float *const *outBlock, size_t blockLen)
Definition: WahWahBase.cpp:157

References mState, and settings().

Here is the call graph for this function:

◆ ProcessInitialize()

bool WahWahBase::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 78 of file WahWahBase.cpp.

80{
82 if (chanMap[0] == ChannelNameFrontRight)
83 mState.phase += M_PI;
84 return true;
85}
@ ChannelNameFrontRight
void InstanceInit(EffectSettings &settings, EffectWahwahState &data, float sampleRate)
Definition: WahWahBase.cpp:132

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

Here is the call graph for this function:

◆ RealtimeAddProcessor()

bool WahWahBase::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 101 of file WahWahBase.cpp.

103{
105
106 InstanceInit(settings, slave.mState, sampleRate);
107
108 mSlaves.push_back(slave);
109
110 return true;
111}
const PerTrackEffect & mProcessor
std::vector< WahWahBase::Instance > mSlaves
Definition: WahWahBase.h:122

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

Here is the call graph for this function:

◆ RealtimeFinalize()

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

Reimplemented from EffectInstance.

Definition at line 113 of file WahWahBase.cpp.

114{
115 mSlaves.clear();
116
117 return true;
118}

◆ RealtimeInitialize()

bool WahWahBase::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 94 of file WahWahBase.cpp.

95{
96 SetBlockSize(512);
97 mSlaves.clear();
98 return true;
99}
size_t SetBlockSize(size_t maxBlockSize) override

◆ RealtimeProcess()

size_t WahWahBase::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 120 of file WahWahBase.cpp.

123{
124 if (group >= mSlaves.size())
125 return 0;
126 return InstanceProcess(
127 settings, mSlaves[group].mState, inbuf, outbuf, numSamples);
128}

References mState, and settings().

Here is the call graph for this function:

Member Data Documentation

◆ mSlaves

std::vector<WahWahBase::Instance> WahWahBase::Instance::mSlaves

Definition at line 122 of file WahWahBase.h.

◆ mState

EffectWahwahState WahWahBase::Instance::mState

Definition at line 121 of file WahWahBase.h.

Referenced by ProcessInitialize(), and RealtimeAddProcessor().


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