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

#include <EchoBase.h>

Inheritance diagram for EchoBase::Instance:
[legend]
Collaboration diagram for EchoBase::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 () noexcept 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...
 
- 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

Floats history
 
size_t histPos
 
size_t histLen
 

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 48 of file EchoBase.h.

Constructor & Destructor Documentation

◆ Instance()

EchoBase::Instance::Instance ( const PerTrackEffect effect)
inline

Definition at line 52 of file EchoBase.h.

Member Function Documentation

◆ GetAudioInCount()

unsigned EchoBase::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 72 of file EchoBase.h.

73 {
74 return 1;
75 }

◆ GetAudioOutCount()

unsigned EchoBase::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 67 of file EchoBase.h.

68 {
69 return 1;
70 }

◆ ProcessBlock()

size_t EchoBase::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 91 of file EchoBase.cpp.

94{
95 auto& echoSettings = GetSettings(settings);
96
97 const float* ibuf = inBlock[0];
98 float* obuf = outBlock[0];
99
100 for (decltype(blockLen) i = 0; i < blockLen; i++, histPos++)
101 {
102 if (histPos == histLen)
103 {
104 histPos = 0;
105 }
106 history[histPos] = obuf[i] =
107 ibuf[i] + history[histPos] * echoSettings.decay;
108 }
109
110 return blockLen;
111}
static Settings & settings()
Definition: TrackInfo.cpp:51
static EchoSettings & GetSettings(EffectSettings &settings)
Assume settings originated from MakeSettings() and copies thereof.
Definition: Effect.h:166

References EffectWithSettings< EchoSettings, PerTrackEffect >::GetSettings(), and settings().

Here is the call graph for this function:

◆ ProcessFinalize()

bool EchoBase::Instance::ProcessFinalize ( )
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 86 of file EchoBase.cpp.

87{
88 return true;
89}

◆ ProcessInitialize()

bool EchoBase::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 56 of file EchoBase.cpp.

58{
59 auto& echoSettings = GetSettings(settings);
60 if (echoSettings.delay == 0.0)
61 return false;
62
63 histPos = 0;
64 auto requestedHistLen = (sampleCount)(sampleRate * echoSettings.delay);
65
66 // Guard against extreme delay values input by the user
67 try
68 {
69 // Guard against huge delay values from the user.
70 // Don't violate the assertion in as_size_t
71 if (
72 requestedHistLen !=
73 (histLen = static_cast<size_t>(requestedHistLen.as_long_long())))
74 throw std::bad_alloc {};
75 history.reinit(histLen, true);
76 }
77 catch (const std::bad_alloc&)
78 {
79 BasicUI::ShowMessageBox(XO("Requested value exceeds memory capacity."));
80 return false;
81 }
82
83 return history != NULL;
84}
XO("Cut/Copy/Paste")
void reinit(Integral count, bool initialize=false)
Definition: MemoryX.h:59
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19
MessageBoxResult ShowMessageBox(const TranslatableString &message, MessageBoxOptions options={})
Show a modal message box with either Ok or Yes and No, and optionally Cancel.
Definition: BasicUI.h:287

References EffectWithSettings< EchoSettings, PerTrackEffect >::GetSettings(), histLen, history, histPos, ArrayOf< X >::reinit(), anonymous_namespace{ClipSegmentTest.cpp}::sampleRate, settings(), BasicUI::ShowMessageBox(), and XO().

Here is the call graph for this function:

Member Data Documentation

◆ histLen

size_t EchoBase::Instance::histLen

Definition at line 79 of file EchoBase.h.

Referenced by ProcessInitialize().

◆ history

Floats EchoBase::Instance::history

Definition at line 77 of file EchoBase.h.

Referenced by ProcessInitialize().

◆ histPos

size_t EchoBase::Instance::histPos

Definition at line 78 of file EchoBase.h.

Referenced by ProcessInitialize().


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