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, bool multi, Source &upstream, Buffers &inBuffers, const Factory &factory, EffectSettings &settings, double sampleRate, std::optional< sampleCount > genLength, const Track &track) | |
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 (bool multi, Source &upstream, Buffers &inBuffers, const Factory &factory, EffectSettings &settings, double sampleRate, std::optional< sampleCount > genLength, const Track &track) |
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 28 of file EffectStage.h.
using AudioGraph::EffectStage::Factory = std::function<std::shared_ptr<EffectInstance>()> |
Definition at line 32 of file EffectStage.h.
AudioGraph::EffectStage::EffectStage | ( | CreateToken | , |
bool | multi, | ||
Source & | upstream, | ||
Buffers & | inBuffers, | ||
const Factory & | factory, | ||
EffectSettings & | settings, | ||
double | sampleRate, | ||
std::optional< sampleCount > | genLength, | ||
const Track & | track | ||
) |
Don't call directly but use Create()
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 |
Definition at line 69 of file EffectStage.cpp.
References AudioGraph::Source::AcceptsBlockSize(), AcceptsBlockSize(), AudioGraph::Buffers::BlockSize(), mInBuffers, and AudioGraph::Buffers::Rewind().
|
delete |
|
override |
Finalizes the instance.
Definition at line 102 of file EffectStage.cpp.
|
overridevirtual |
See postcondition of constructor.
Implements AudioGraph::Source.
Definition at line 115 of file EffectStage.cpp.
References size.
Referenced by EffectStage().
|
overridevirtual |
Implements AudioGraph::Source.
Definition at line 110 of file EffectStage.cpp.
|
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 122 of file EffectStage.cpp.
References AudioGraph::Buffers::BlockSize(), AudioGraph::Buffers::Discard(), limitSampleBufferSize(), min(), and AudioGraph::Buffers::Remaining().
|
static |
Satisfies postcondition of constructor or returns null.
Definition at line 87 of file EffectStage.cpp.
References cloud::factory, and settings().
Referenced by PerTrackEffect::ProcessTrack().
|
inlineprivate |
Definition at line 72 of file EffectStage.h.
|
private |
Definition at line 234 of file EffectStage.cpp.
References limitSampleBufferSize().
|
delete |
|
private |
Produce exactly curBlockSize
samples in data
Definition at line 304 of file EffectStage.cpp.
References AudioGraph::Buffers::Channels(), EffectInstance::GetAudioInCount(), EffectInstance::GetAudioOutCount(), AudioGraph::Buffers::Positions(), EffectInstance::ProcessBlock(), and size.
|
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 368 of file EffectStage.cpp.
|
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 356 of file EffectStage.cpp.
|
private |
Definition at line 100 of file EffectStage.h.
|
private |
Definition at line 96 of file EffectStage.h.
|
private |
Definition at line 90 of file EffectStage.h.
Referenced by EffectStage().
|
private |
Definition at line 91 of file EffectStage.h.
|
private |
Definition at line 94 of file EffectStage.h.
|
private |
Definition at line 97 of file EffectStage.h.
|
private |
Definition at line 98 of file EffectStage.h.
|
private |
Definition at line 99 of file EffectStage.h.
|
private |
Definition at line 93 of file EffectStage.h.
|
private |
Definition at line 92 of file EffectStage.h.
|
private |
Definition at line 88 of file EffectStage.h.