Audacity 3.2.0
Public Member Functions | Public Attributes | List of all members
EffectReverb::Instance Struct Reference
Inheritance diagram for EffectReverb::Instance:
[legend]
Collaboration diagram for EffectReverb::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 ProcessFinalize (void) noexcept override
 
bool RealtimeInitialize (EffectSettings &settings, double sampleRate) override
 
bool RealtimeAddProcessor (EffectSettings &settings, EffectOutputs *, 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
 
bool RealtimeSuspend () override
 
unsigned GetAudioOutCount () const override
 How many output buffers to allocate at once. More...
 
unsigned GetAudioInCount () const override
 How many input buffers to allocate at once. More...
 
bool InstanceInit (EffectSettings &settings, double sampleRate, EffectReverbState &data, ChannelNames chanMap, bool forceStereo)
 
size_t InstanceProcess (EffectSettings &settings, EffectReverbState &data, const float *const *inBlock, float *const *outBlock, size_t blockLen)
 
- 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

EffectReverbState mState
 
std::vector< EffectReverb::InstancemSlaves
 
unsigned mChannels { 2 }
 
EffectReverbSettings mLastAppliedSettings
 
double mLastSampleRate { 0 }
 

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 213 of file Reverb.cpp.

Constructor & Destructor Documentation

◆ Instance()

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

Definition at line 217 of file Reverb.cpp.

Member Function Documentation

◆ GetAudioInCount()

unsigned EffectReverb::Instance::GetAudioInCount ( ) const
inlineoverridevirtual

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 323 of file Reverb.cpp.

324 {
325 return mChannels;
326 }

References mChannels.

◆ GetAudioOutCount()

unsigned EffectReverb::Instance::GetAudioOutCount ( ) const
inlineoverridevirtual

How many output buffers to allocate at once.

The result is not necessarily well defined before RealtimeInitialize

Implements EffectInstance.

Definition at line 318 of file Reverb.cpp.

319 {
320 return mChannels;
321 }

References mChannels.

◆ InstanceInit()

bool EffectReverb::Instance::InstanceInit ( EffectSettings settings,
double  sampleRate,
EffectReverbState data,
ChannelNames  chanMap,
bool  forceStereo 
)

Definition at line 404 of file Reverb.cpp.

407{
408 auto& rs = GetSettings(settings);
409
410 bool isStereo = false;
411 state.mNumChans = 1;
412 if ( (chanMap && chanMap[0] != ChannelNameEOL && chanMap[1] == ChannelNameFrontRight)
413 || forceStereo )
414 {
415 isStereo = true;
416 state.mNumChans = 2;
417 }
418
419 state.mP = std::make_unique<Reverb_priv_ex[]>(state.mNumChans);
420
421 for (unsigned int i = 0; i < state.mNumChans; i++)
422 {
423 reverb_create(&state.mP[i].reverb,
425 rs.mWetGain,
426 rs.mRoomSize,
427 rs.mReverberance,
428 rs.mHfDamping,
429 rs.mPreDelay,
430 rs.mStereoWidth * (isStereo ? 1 : 0),
431 rs.mToneLow,
432 rs.mToneHigh,
433 BLOCK,
434 state.mP[i].wet);
435 }
436
437 return true;
438}
@ ChannelNameEOL
@ ChannelNameFrontRight
static size_t BLOCK
Definition: Reverb.cpp:390
static void reverb_create(reverb_t *p, double sample_rate_Hz, double wet_gain_dB, double room_scale, double reverberance, double hf_damping, double pre_delay_ms, double stereo_depth, double tone_low, double tone_high, size_t buffer_size, float **out)
static Settings & settings()
Definition: TrackInfo.cpp:51
static EffectReverbSettings & GetSettings(EffectSettings &settings)
Assume settings originated from MakeSettings() and copies thereof.
Definition: Effect.h:166

References BLOCK, ChannelNameEOL, ChannelNameFrontRight, EffectWithSettings< EffectReverbSettings, StatelessPerTrackEffect >::GetSettings(), EffectReverbState::mNumChans, EffectReverbState::mP, reverb_create(), anonymous_namespace{ClipSegmentTest.cpp}::sampleRate, and settings().

Referenced by RealtimeAddProcessor().

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

◆ InstanceProcess()

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

Definition at line 451 of file Reverb.cpp.

453{
454 auto& rs = GetSettings(settings);
455
456 const float *ichans[2] = {NULL, NULL};
457 float *ochans[2] = {NULL, NULL};
458
459 for (unsigned int c = 0; c < state.mNumChans; c++)
460 {
461 ichans[c] = inBlock[c];
462 ochans[c] = outBlock[c];
463 }
464
465 float const dryMult = rs.mWetOnly ? 0 : dB_to_linear(rs.mDryGain);
466
467 auto remaining = blockLen;
468
469 while (remaining)
470 {
471 auto len = std::min(remaining, decltype(remaining)(BLOCK));
472 for (unsigned int c = 0; c < state.mNumChans; c++)
473 {
474 // Write the input samples to the reverb fifo. Returned value is the address of the
475 // fifo buffer which contains a copy of the input samples.
476 state.mP[c].dry = (float *) fifo_write(&state.mP[c].reverb.input_fifo, len, ichans[c]);
477 reverb_process(&state.mP[c].reverb, len);
478 }
479
480 if (state.mNumChans == 2)
481 {
482 for (decltype(len) i = 0; i < len; i++)
483 {
484 for (int w = 0; w < 2; w++)
485 {
486 ochans[w][i] = dryMult *
487 state.mP[w].dry[i] +
488 0.5 *
489 (state.mP[0].wet[w][i] + state.mP[1].wet[w][i]);
490 }
491 }
492 }
493 else
494 {
495 for (decltype(len) i = 0; i < len; i++)
496 {
497 ochans[0][i] = dryMult *
498 state.mP[0].dry[i] +
499 state.mP[0].wet[0][i];
500 }
501 }
502
503 remaining -= len;
504
505 for (unsigned int c = 0; c < state.mNumChans; c++)
506 {
507 ichans[c] += len;
508 ochans[c] += len;
509 }
510 }
511
512 return blockLen;
513}
int min(int a, int b)
#define dB_to_linear(x)
Definition: Reverb_libSoX.h:27
static void reverb_process(reverb_t *p, size_t length)
static void * fifo_write(fifo_t *f, FIFO_SIZE_T n, void const *data)
Definition: Reverb_libSoX.h:81

References BLOCK, dB_to_linear, fifo_write(), EffectWithSettings< EffectReverbSettings, StatelessPerTrackEffect >::GetSettings(), min(), EffectReverbState::mNumChans, EffectReverbState::mP, reverb_process(), and settings().

Referenced by RealtimeProcess().

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

◆ ProcessBlock()

size_t EffectReverb::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 445 of file Reverb.cpp.

447{
448 return InstanceProcess(settings, mState, inBlock, outBlock, blockLen);
449}
size_t InstanceProcess(EffectSettings &settings, EffectReverbState &data, const float *const *inBlock, float *const *outBlock, size_t blockLen)
Definition: Reverb.cpp:451
EffectReverbState mState
Definition: Reverb.cpp:334

References mState, and settings().

Here is the call graph for this function:

◆ ProcessFinalize()

bool EffectReverb::Instance::ProcessFinalize ( void  )
overridevirtualnoexcept

Called at end of destructive processing, for each (mono/stereo) track Default implementation does nothing, returns true This may be called during stack unwinding:

Implements EffectInstance.

Definition at line 440 of file Reverb.cpp.

441{
442 return true;
443}

◆ ProcessInitialize()

bool EffectReverb::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 392 of file Reverb.cpp.

394{
395 // For descructive processing, fix the number of channels, maybe as 1 not 2
396 auto& rs = GetSettings(settings);
397 mChannels = rs.mStereoWidth ? 2 : 1;
398
399 return InstanceInit(settings,
400 sampleRate, mState, chanMap, /* forceStereo = */ false);
401}
bool InstanceInit(EffectSettings &settings, double sampleRate, EffectReverbState &data, ChannelNames chanMap, bool forceStereo)
Definition: Reverb.cpp:404

References EffectWithSettings< EffectReverbSettings, StatelessPerTrackEffect >::GetSettings(), mState, anonymous_namespace{ClipSegmentTest.cpp}::sampleRate, and settings().

Here is the call graph for this function:

◆ RealtimeAddProcessor()

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

Reimplemented from EffectInstance.

Definition at line 242 of file Reverb.cpp.

244 {
246
247 // The notion of ChannelNames is unavailable here,
248 // so we'll have to force the stereo init, if this is the case
249 //
251 slave.mState, /*ChannelNames=*/nullptr, /*forceStereo=*/(numChannels == 2));
252
253 mSlaves.push_back( std::move(slave) );
254 return true;
255 }
const PerTrackEffect & mProcessor
std::vector< EffectReverb::Instance > mSlaves
Definition: Reverb.cpp:335

References InstanceInit(), PerTrackEffect::Instance::mProcessor, mSlaves, mState, anonymous_namespace{ClipSegmentTest.cpp}::sampleRate, and settings().

Here is the call graph for this function:

◆ RealtimeFinalize()

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

Reimplemented from EffectInstance.

Definition at line 257 of file Reverb.cpp.

258 {
259 mSlaves.clear();
260 return true;
261 }

References mSlaves.

◆ RealtimeInitialize()

bool EffectReverb::Instance::RealtimeInitialize ( EffectSettings settings,
double  sampleRate 
)
inlineoverridevirtual
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 231 of file Reverb.cpp.

232 {
233 SetBlockSize(512);
234 mSlaves.clear();
235
238
239 return true;
240 }
size_t SetBlockSize(size_t maxBlockSize) override
EffectReverbSettings mLastAppliedSettings
Definition: Reverb.cpp:339

References EffectWithSettings< EffectReverbSettings, StatelessPerTrackEffect >::GetSettings(), mLastAppliedSettings, mLastSampleRate, mSlaves, anonymous_namespace{ClipSegmentTest.cpp}::sampleRate, EffectInstanceWithBlockSize::SetBlockSize(), and settings().

Here is the call graph for this function:

◆ RealtimeProcess()

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

Reimplemented from EffectInstance.

Definition at line 263 of file Reverb.cpp.

265 {
266
267 const auto& incomingSettings = GetSettings(settings);
268 if ( !(incomingSettings == mLastAppliedSettings) )
269 {
270 const bool onlySimpleOnes = OnlySimpleParametersChanged(incomingSettings, mLastAppliedSettings);
271
272 for (auto& slave : mSlaves)
273 {
274 for (unsigned int i = 0; i < slave.mState.mNumChans; i++)
275 {
276 auto& reverbCore = slave.mState.mP[i].reverb;
277 const auto& is = incomingSettings;
278
279 if (onlySimpleOnes)
280 {
282 is.mWetGain, is.mReverberance, is.mHfDamping, is.mToneLow, is.mToneHigh);
283 }
284 else
285 {
286 // One of the non-simple parameters changed, so we need to do a full reinit
287 reverb_init(&reverbCore, mLastSampleRate,
288 is.mWetGain, is.mRoomSize, is.mReverberance, is.mHfDamping,
289 is.mPreDelay, is.mStereoWidth, is.mToneLow, is.mToneHigh );
290 }
291 }
292 }
293
294 mLastAppliedSettings = incomingSettings;
295 }
296
297
298 if (group >= mSlaves.size())
299 return 0;
300 return InstanceProcess(settings, mSlaves[group].mState, inbuf, outbuf, numSamples);
301 }
bool OnlySimpleParametersChanged(const EffectReverbSettings &a, const EffectReverbSettings &b)
Definition: Reverb.cpp:677
static void reverb_init(reverb_t *p, double sample_rate_Hz, double wet_gain_dB, double room_scale, double reverberance, double hf_damping, double pre_delay_ms, double stereo_depth, double tone_low, double tone_high)
static void reverb_set_simple_params(reverb_t *p, double sample_rate_Hz, double wet_gain_dB, double reverberance, double hf_damping, double tone_low, double tone_high)

References EffectWithSettings< EffectReverbSettings, StatelessPerTrackEffect >::GetSettings(), InstanceProcess(), mLastAppliedSettings, mLastSampleRate, mSlaves, mState, OnlySimpleParametersChanged(), reverb_init(), reverb_set_simple_params(), and settings().

Here is the call graph for this function:

◆ RealtimeSuspend()

bool EffectReverb::Instance::RealtimeSuspend ( )
inlineoverridevirtual
Returns
success Default implementation does nothing, returns true

Reimplemented from EffectInstance.

Definition at line 304 of file Reverb.cpp.

305 {
306 for (auto& slave : mSlaves)
307 {
308 for (unsigned int i = 0; i < slave.mState.mNumChans; i++)
309 {
310 reverb_clear( &(slave.mState.mP[i].reverb) );
311 }
312 }
313
314 return true;
315 }
static void reverb_clear(reverb_t *p)

References mSlaves, and reverb_clear().

Here is the call graph for this function:

Member Data Documentation

◆ mChannels

unsigned EffectReverb::Instance::mChannels { 2 }

Definition at line 337 of file Reverb.cpp.

Referenced by GetAudioInCount(), and GetAudioOutCount().

◆ mLastAppliedSettings

EffectReverbSettings EffectReverb::Instance::mLastAppliedSettings

Definition at line 339 of file Reverb.cpp.

Referenced by RealtimeInitialize(), and RealtimeProcess().

◆ mLastSampleRate

double EffectReverb::Instance::mLastSampleRate { 0 }

Definition at line 340 of file Reverb.cpp.

Referenced by RealtimeInitialize(), and RealtimeProcess().

◆ mSlaves

std::vector<EffectReverb::Instance> EffectReverb::Instance::mSlaves

◆ mState

EffectReverbState EffectReverb::Instance::mState

Definition at line 334 of file Reverb.cpp.

Referenced by RealtimeAddProcessor(), and RealtimeProcess().


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