Audacity 3.2.0
|
Decorates a source with a non-timewarping effect, which may have latency. More...
#include <EffectStage.h>
Classes | |
struct | CreateToken |
Public Types | |
using | Factory = std::function< std::shared_ptr< EffectInstance >()> |
Public Types inherited from AudioGraph::Source | |
using | Buffers = AudioGraph::Buffers |
Public Member Functions | |
EffectStage (CreateToken, int channel, int nInputChannels, Source &upstream, Buffers &inBuffers, const Factory &factory, EffectSettings &settings, double sampleRate, std::optional< sampleCount > genLength) | |
Don't call directly but use Create() More... | |
EffectStage (const EffectStage &)=delete | |
EffectStage & | operator= (const EffectStage &)=delete |
~EffectStage () override | |
Finalizes the instance. More... | |
bool | AcceptsBuffers (const Buffers &buffers) const override |
bool | AcceptsBlockSize (size_t size) const override |
See postcondition of constructor. More... | |
std::optional< size_t > | Acquire (Buffers &data, size_t bound) override |
Occupy vacant space in Buffers with some data. More... | |
sampleCount | Remaining () const override |
Result includes any amount Acquired and not yet Released. More... | |
bool | Release () override |
Caller is done examining last Acquire()d positions. More... | |
Public Member Functions inherited from AudioGraph::Source | |
virtual | ~Source () |
virtual bool | AcceptsBuffers (const Buffers &buffers) const =0 |
virtual bool | AcceptsBlockSize (size_t blockSize) const =0 |
virtual std::optional< size_t > | Acquire (Buffers &data, size_t bound)=0 |
Occupy vacant space in Buffers with some data. More... | |
virtual sampleCount | Remaining () const =0 |
Result includes any amount Acquired and not yet Released. More... | |
virtual bool | Release ()=0 |
Caller is done examining last Acquire()d positions. More... | |
virtual bool | Terminates () const |
Needed only to make some postconditions assertable; defaults true. More... | |
Static Public Member Functions | |
static std::unique_ptr< EffectStage > | Create (int channel, int nInputChannels, Source &upstream, Buffers &inBuffers, const Factory &factory, EffectSettings &settings, double sampleRate, std::optional< sampleCount > genLength) |
Satisfies postcondition of constructor or returns null. More... | |
Private Member Functions | |
sampleCount | DelayRemaining () const |
bool | Process (EffectInstance &instance, size_t channel, const Buffers &data, size_t curBlockSize, size_t outBufferOffset) const |
Produce exactly curBlockSize samples in data More... | |
std::optional< size_t > | FetchProcessAndAdvance (Buffers &data, size_t bound, bool doZeros, size_t outBufferOffset=0) |
Private Attributes | |
Source & | mUpstream |
Buffers & | mInBuffers |
const std::vector< std::shared_ptr< EffectInstance > > | mInstances |
EffectSettings & | mSettings |
const double | mSampleRate |
const bool | mIsProcessor |
sampleCount | mDelayRemaining |
size_t | mLastProduced {} |
size_t | mLastZeroes {} |
bool | mLatencyDone { false } |
bool | mCleared { false } |
Decorates a source with a non-timewarping effect, which may have latency.
Definition at line 26 of file EffectStage.h.
using EffectStage::Factory = std::function<std::shared_ptr<EffectInstance>()> |
Definition at line 30 of file EffectStage.h.
EffectStage::EffectStage | ( | CreateToken | , |
int | channel, | ||
int | nInputChannels, | ||
Source & | upstream, | ||
Buffers & | inBuffers, | ||
const Factory & | factory, | ||
EffectSettings & | settings, | ||
double | sampleRate, | ||
std::optional< sampleCount > | genLength | ||
) |
Don't call directly but use Create()
channel | selects one channel if non-negative; else, all channels |
factory | used only in construction, will be invoked one or more times |
upstream.AcceptsBlockSize(inBuffers.BlockSize())
AcceptsBlockSize(inBuffers.BlockSize())
ProcessInitialize()
succeeded on each instance that was made by factory
map | not required after construction |
channel < sequence.NChannels()
Definition at line 59 of file EffectStage.cpp.
References AcceptsBlockSize(), AudioGraph::Buffers::BlockSize(), mInBuffers, and AudioGraph::Buffers::Rewind().
|
delete |
|
override |
Finalizes the instance.
Definition at line 94 of file EffectStage.cpp.
References mInstances.
|
overridevirtual |
See postcondition of constructor.
Implements AudioGraph::Source.
Definition at line 107 of file EffectStage.cpp.
References AudioGraph::Buffers::BlockSize(), mInBuffers, and size.
Referenced by Acquire(), and EffectStage().
|
overridevirtual |
Implements AudioGraph::Source.
Definition at line 102 of file EffectStage.cpp.
Referenced by Acquire().
|
overridevirtual |
Occupy vacant space in Buffers with some data.
May exceeed a single block of production Can assume same buffer is passed each time, while the caller advances it over the previous production, or discards it, or rotates the buffer. May rewind or rotate the buffer.
data
or nullopt to fail AcceptsBuffers(data)
AcceptsBlockSize(data.BlockSize())
bound <= data.BlockSize()
data.BlockSize() <= data.Remaining()
!result || *result <= bound
!result || *result <= data.Remaining()
!result || *result <= Remaining()
data.Remaining() > 0
!result || bound == 0 || Remaining() == 0 || *result > 0
(progress guarantee) !Terminates()
or Remaining()
was not previously defined, or is unchanged Implements AudioGraph::Source.
Definition at line 113 of file EffectStage.cpp.
References AcceptsBlockSize(), AcceptsBuffers(), AudioGraph::Buffers::BlockSize(), AudioGraph::Buffers::Discard(), FetchProcessAndAdvance(), limitSampleBufferSize(), mDelayRemaining, min(), mInBuffers, mInstances, mIsProcessor, mLastProduced, mLastZeroes, mLatencyDone, mSampleRate, mSettings, mUpstream, AudioGraph::Buffers::Remaining(), and Remaining().
|
static |
Satisfies postcondition of constructor or returns null.
Definition at line 79 of file EffectStage.cpp.
References factory, anonymous_namespace{ClipSegmentTest.cpp}::sampleRate, and settings().
Referenced by PerTrackEffect::ProcessTrack(), and Mixer::RegisterEffectStage().
|
inlineprivate |
Definition at line 72 of file EffectStage.h.
Referenced by FetchProcessAndAdvance(), and Remaining().
|
private |
Definition at line 225 of file EffectStage.cpp.
References AudioGraph::Buffers::Advance(), AudioGraph::Buffers::BlockSize(), AudioGraph::Buffers::Channels(), DelayRemaining(), AudioGraph::Buffers::GetWritePosition(), limitSampleBufferSize(), mCleared, mDelayRemaining, mInBuffers, mInstances, mIsProcessor, mLastProduced, mLastZeroes, mUpstream, Process(), AudioGraph::Buffers::Remaining(), AudioGraph::Buffers::Rewind(), and AudioGraph::Buffers::Rotate().
Referenced by Acquire().
|
delete |
|
private |
Produce exactly curBlockSize
samples in data
Definition at line 295 of file EffectStage.cpp.
References AudioGraph::Buffers::Channels(), EffectInstance::GetAudioInCount(), EffectInstance::GetAudioOutCount(), mInBuffers, mSettings, AudioGraph::Buffers::Positions(), EffectInstance::ProcessBlock(), and size.
Referenced by FetchProcessAndAdvance().
|
overridevirtual |
Caller is done examining last Acquire()d positions.
May be called only after at least one successful call to Acquire()
!Terminates()
or Remaining()
reduced by what was last returned by Acquire()
Implements AudioGraph::Source.
Definition at line 359 of file EffectStage.cpp.
References mDelayRemaining, mLastProduced, and mLastZeroes.
|
overridevirtual |
Result includes any amount Acquired and not yet Released.
May be undefined before the first successful call to Acquire()
result >= 0
Implements AudioGraph::Source.
Definition at line 347 of file EffectStage.cpp.
References DelayRemaining(), mIsProcessor, mLastProduced, and mUpstream.
Referenced by Acquire().
|
private |
Definition at line 100 of file EffectStage.h.
Referenced by FetchProcessAndAdvance().
|
private |
Definition at line 96 of file EffectStage.h.
Referenced by Acquire(), FetchProcessAndAdvance(), and Release().
|
private |
Definition at line 90 of file EffectStage.h.
Referenced by AcceptsBlockSize(), Acquire(), EffectStage(), FetchProcessAndAdvance(), and Process().
|
private |
Definition at line 91 of file EffectStage.h.
Referenced by Acquire(), FetchProcessAndAdvance(), and ~EffectStage().
|
private |
Definition at line 94 of file EffectStage.h.
Referenced by Acquire(), FetchProcessAndAdvance(), and Remaining().
|
private |
Definition at line 97 of file EffectStage.h.
Referenced by Acquire(), FetchProcessAndAdvance(), Release(), and Remaining().
|
private |
Definition at line 98 of file EffectStage.h.
Referenced by Acquire(), FetchProcessAndAdvance(), and Release().
|
private |
Definition at line 99 of file EffectStage.h.
Referenced by Acquire().
|
private |
Definition at line 93 of file EffectStage.h.
Referenced by Acquire().
|
private |
Definition at line 92 of file EffectStage.h.
|
private |
Definition at line 88 of file EffectStage.h.
Referenced by Acquire(), FetchProcessAndAdvance(), and Remaining().