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

Public Member Functions

 Instance (const PerTrackEffect &effect)
 
bool ProcessInitialize (EffectSettings &settings, sampleCount totalLen, 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) override
 
- 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...
 
virtual bool ProcessInitialize (EffectSettings &settings, sampleCount totalLen, ChannelNames chanMap)
 
virtual bool ProcessFinalize ()
 
virtual size_t ProcessBlock (EffectSettings &settings, const float *const *inBlock, float *const *outBlock, size_t blockLen)=0
 Called for destructive effect computation. More...
 
virtual sampleCount GetLatency (const EffectSettings &settings)
 
- Public Member Functions inherited from EffectInstance
virtual ~EffectInstance ()
 
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...
 
virtual void SetSampleRate (double rate)=0
 
virtual size_t GetBlockSize () const =0
 
virtual size_t SetBlockSize (size_t maxBlockSize)=0
 
virtual bool RealtimeInitialize (EffectSettings &settings)
 
virtual bool RealtimeAddProcessor (EffectSettings &settings, unsigned numChannels, float sampleRate)
 
virtual bool RealtimeSuspend ()
 
virtual bool RealtimeResume () noexcept
 
virtual bool RealtimeProcessStart (EffectSettings &settings)
 settings are possibly changed, since last call, by an asynchronous dialog More...
 
virtual size_t RealtimeProcess (int 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 GetTailSize () const
 
- Public Member Functions inherited from EffectInstanceWithBlockSize
 ~EffectInstanceWithBlockSize () override
 
size_t GetBlockSize () const override
 
size_t SetBlockSize (size_t maxBlockSize) override
 
- Public Member Functions inherited from EffectInstanceWithSampleRate
 ~EffectInstanceWithSampleRate () override
 
void SetSampleRate (double rate) override
 

Public Attributes

Floats history
 
size_t histPos
 
size_t histLen
 

Additional Inherited Members

- Protected Attributes inherited from PerTrackEffect::Instance
const PerTrackEffectmProcessor
 
- Protected Attributes inherited from EffectInstanceWithBlockSize
size_t mBlockSize { 0 }
 
- Protected Attributes inherited from EffectInstanceWithSampleRate
double mSampleRate { 0 }
 

Detailed Description

Definition at line 46 of file Echo.cpp.

Constructor & Destructor Documentation

◆ Instance()

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

Definition at line 52 of file Echo.cpp.

Member Function Documentation

◆ ProcessBlock()

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

Called for destructive effect computation.

Implements PerTrackEffect::Instance.

Definition at line 157 of file Echo.cpp.

159{
160 auto& echoSettings = GetSettings(settings);
161
162 const float *ibuf = inBlock[0];
163 float *obuf = outBlock[0];
164
165 for (decltype(blockLen) i = 0; i < blockLen; i++, histPos++)
166 {
167 if (histPos == histLen)
168 {
169 histPos = 0;
170 }
171 history[histPos] = obuf[i] = ibuf[i] + history[histPos] * echoSettings.decay;
172 }
173
174 return blockLen;
175}
static Settings & settings()
Definition: TrackInfo.cpp:87
static EffectEchoSettings & GetSettings(EffectSettings &settings)
Assume settings originated from MakeSettings() and copies thereof.
Definition: Effect.h:415

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

Here is the call graph for this function:

◆ ProcessFinalize()

bool EffectEcho::Instance::ProcessFinalize ( void  )
overridevirtual

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

Reimplemented from PerTrackEffect::Instance.

Definition at line 152 of file Echo.cpp.

153{
154 return true;
155}

◆ ProcessInitialize()

bool EffectEcho::Instance::ProcessInitialize ( EffectSettings settings,
sampleCount  totalLen,
ChannelNames  chanMap 
)
overridevirtual

Called at start of destructive processing, for each (mono/stereo) track Default implementation does nothing, returns true

Reimplemented from PerTrackEffect::Instance.

Definition at line 122 of file Echo.cpp.

124{
125 auto& echoSettings = GetSettings(settings);
126
127 if (echoSettings.delay == 0.0)
128 {
129 return false;
130 }
131
132 histPos = 0;
133 auto requestedHistLen = (sampleCount) (mSampleRate * echoSettings.delay);
134
135 // Guard against extreme delay values input by the user
136 try {
137 // Guard against huge delay values from the user.
138 // Don't violate the assertion in as_size_t
139 if (requestedHistLen !=
140 (histLen = static_cast<size_t>(requestedHistLen.as_long_long())))
141 throw std::bad_alloc{};
142 history.reinit(histLen, true);
143 }
144 catch ( const std::bad_alloc& ) {
145 mProcessor.MessageBox( XO("Requested value exceeds memory capacity.") );
146 return false;
147 }
148
149 return history != NULL;
150}
#define XO(s)
Definition: Internat.h:31
void reinit(Integral count, bool initialize=false)
Definition: MemoryX.h:57
int MessageBox(const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={}) const
Definition: Effect.cpp:869
const PerTrackEffect & mProcessor
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:18

References EffectWithSettings< EffectEchoSettings, PerTrackEffect >::GetSettings(), histLen, history, histPos, Effect::MessageBox(), PerTrackEffect::Instance::mProcessor, EffectInstanceWithSampleRate::mSampleRate, ArrayOf< X >::reinit(), settings(), and XO.

Here is the call graph for this function:

Member Data Documentation

◆ histLen

size_t EffectEcho::Instance::histLen

Definition at line 66 of file Echo.cpp.

Referenced by ProcessInitialize().

◆ history

Floats EffectEcho::Instance::history

Definition at line 64 of file Echo.cpp.

Referenced by ProcessInitialize().

◆ histPos

size_t EffectEcho::Instance::histPos

Definition at line 65 of file Echo.cpp.

Referenced by ProcessInitialize().


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