![]() |
Audacity 3.2.0
|
#include <MixerSource.h>
Public Types | |
using | TimesAndSpeed = MixerOptions::TimesAndSpeed |
using | ResampleParameters = MixerOptions::ResampleParameters |
![]() | |
using | Buffers = AudioGraph::Buffers |
Public Member Functions | |
MixerSource (const std::shared_ptr< const WideSampleSequence > &leader, size_t bufferSize, double rate, const MixerOptions::Warp &options, bool highQuality, bool mayThrow, std::shared_ptr< TimesAndSpeed > pTimesAndSpeed, const ArrayOf< bool > *pMap) | |
MixerSource (MixerSource &&)=default | |
MixerSource & | operator= (MixerSource &&)=delete |
~MixerSource () | |
unsigned | Channels () const |
const WideSampleSequence & | GetSequence () const |
const bool * | MixerSpec (unsigned iChannel) const |
bool | AcceptsBuffers (const Buffers &buffers) const override |
bool | AcceptsBlockSize (size_t blockSize) const override |
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... | |
bool | Terminates () const override |
void | Reposition (double time, bool skipping) |
bool | VariableRates () const |
![]() | |
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... | |
Private Member Functions | |
void | MakeResamplers () |
size_t | MixSameRate (unsigned nChannels, size_t maxOut, float *floatBuffers[]) |
size_t | MixVariableRates (unsigned nChannels, size_t maxOut, float *floatBuffers[]) |
void | ZeroFill (size_t produced, size_t max, float &floatBuffer) |
Private Attributes | |
const std::shared_ptr< const WideSampleSequence > | mpLeader |
size_t | i |
const size_t | mnChannels |
const double | mRate |
const BoundedEnvelope *const | mEnvelope |
Resampling, as needed, after gain envelope. More... | |
const bool | mMayThrow |
const std::shared_ptr< TimesAndSpeed > | mTimesAndSpeed |
sampleCount | mSamplePos |
Fetch position for source. More... | |
std::vector< std::vector< float > > | mSampleQueue |
First intermediate buffer when resampling is needed. More... | |
int | mQueueStart |
Position of the start of the next block to resample. More... | |
int | mQueueLen |
The number of available samples after the queue start. More... | |
const ResampleParameters | mResampleParameters |
std::vector< std::unique_ptr< Resample > > | mResample |
std::vector< double > | mEnvValues |
Gain envelopes are applied to input before other transformations. More... | |
const ArrayOf< bool > *const | mpMap |
unsigned | mMaxChannels {} |
Remember how many channels were passed to Acquire() More... | |
size_t | mLastProduced {} |
Static Private Attributes | |
static constexpr size_t | sProcessLen = 1024 |
static constexpr size_t | sQueueMaxLen = 65536 |
Fetches from tracks, applies envelopes; can resample, and warp time, even backwards, as for scrubbing.
This class inherits AudioGraph::Source but does not yet fulfill the contracts of all of the members. But it is not yet used through any pointer or reference to its base class.
Definition at line 33 of file MixerSource.h.
Definition at line 36 of file MixerSource.h.
Definition at line 35 of file MixerSource.h.
MixerSource::MixerSource | ( | const std::shared_ptr< const WideSampleSequence > & | leader, |
size_t | bufferSize, | ||
double | rate, | ||
const MixerOptions::Warp & | options, | ||
bool | highQuality, | ||
bool | mayThrow, | ||
std::shared_ptr< TimesAndSpeed > | pTimesAndSpeed, | ||
const ArrayOf< bool > * | pMap | ||
) |
pTimesAndSpeed != nullptr
pMap | Null or else must have a lifetime enclosing this objects's |
Definition at line 289 of file MixerSource.cpp.
References GetSequence(), MakeResamplers(), mSamplePos, mTimesAndSpeed, and WideSampleSequence::TimeToLongSamples().
|
default |
|
default |
|
overridevirtual |
Implements AudioGraph::Source.
Definition at line 331 of file MixerSource.cpp.
References mEnvValues.
Referenced by AcceptsBuffers(), and Acquire().
|
overridevirtual |
Implements AudioGraph::Source.
Definition at line 326 of file MixerSource.cpp.
References AcceptsBlockSize(), and AudioGraph::Buffers::BufferSize().
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 338 of file MixerSource.cpp.
References _, AcceptsBlockSize(), AcceptsBuffers(), sampleCount::as_double(), AudioGraph::Buffers::BlockSize(), AudioGraph::Buffers::Channels(), WideSampleSequence::GetRate(), GetSequence(), AudioGraph::Buffers::GetWritePosition(), min(), MixSameRate(), MixVariableRates(), mLastProduced, mMaxChannels, mnChannels, mRate, mResampleParameters, mSamplePos, mTimesAndSpeed, MixerOptions::ResampleParameters::mVariableRates, AudioGraph::Buffers::Remaining(), Remaining(), stackAllocate, and ZeroFill().
|
inline |
const WideSampleSequence & MixerSource::GetSequence | ( | ) | const |
Definition at line 316 of file MixerSource.cpp.
References mpLeader.
Referenced by Acquire(), MixerSource(), and Reposition().
|
private |
Definition at line 40 of file MixerSource.cpp.
References MixerOptions::ResampleParameters::mHighQuality, MixerOptions::ResampleParameters::mMaxFactor, MixerOptions::ResampleParameters::mMinFactor, mnChannels, mResample, and mResampleParameters.
Referenced by MixerSource(), and Reposition().
const bool * MixerSource::MixerSpec | ( | unsigned | iChannel | ) | const |
Definition at line 321 of file MixerSource.cpp.
References anonymous_namespace{StretchingSequenceIntegrationTest.cpp}::iChannel, and mpMap.
|
private |
Assume floatBuffers has extent nChannels
result <= maxOut
Definition at line 219 of file MixerSource.cpp.
References _, fillZero, i, anonymous_namespace{StretchingSequenceIntegrationTest.cpp}::iChannel, limitSampleBufferSize(), mEnvValues, min(), mMayThrow, mpLeader, mSamplePos, and mTimesAndSpeed.
Referenced by Acquire().
|
private |
Assume floatBuffers has extent nChannels
result <= maxOut
Definition at line 68 of file MixerSource.cpp.
References _, anonymous_namespace{MixerSource.cpp}::ComputeWarpFactor(), fillZero, floatSample, i, anonymous_namespace{StretchingSequenceIntegrationTest.cpp}::iChannel, limitSampleBufferSize(), mEnvelope, mEnvValues, min(), mMayThrow, mpLeader, mQueueLen, mQueueStart, mRate, mResample, mSamplePos, mSampleQueue, mTimesAndSpeed, SAMPLE_SIZE, sProcessLen, and sQueueMaxLen.
Referenced by Acquire().
|
delete |
|
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 392 of file MixerSource.cpp.
References mLastProduced.
|
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 386 of file MixerSource.cpp.
References mLastProduced.
Referenced by Acquire().
void MixerSource::Reposition | ( | double | time, |
bool | skipping | ||
) |
Definition at line 408 of file MixerSource.cpp.
References GetSequence(), MakeResamplers(), mQueueLen, mQueueStart, mSamplePos, and WideSampleSequence::TimeToLongSamples().
|
overridevirtual |
Reimplemented from AudioGraph::Source.
Definition at line 398 of file MixerSource.cpp.
|
inline |
Definition at line 65 of file MixerSource.h.
References mResampleParameters, and MixerOptions::ResampleParameters::mVariableRates.
Referenced by Mixer::NeedsDither().
|
private |
produced <= max
Definition at line 281 of file MixerSource.cpp.
Referenced by Acquire().
|
private |
Definition at line 101 of file MixerSource.h.
Referenced by MixSameRate(), and MixVariableRates().
|
private |
Resampling, as needed, after gain envelope.
Definition at line 107 of file MixerSource.h.
Referenced by MixVariableRates().
|
private |
Gain envelopes are applied to input before other transformations.
Definition at line 131 of file MixerSource.h.
Referenced by AcceptsBlockSize(), MixSameRate(), and MixVariableRates().
|
private |
Definition at line 139 of file MixerSource.h.
Referenced by Acquire(), Release(), and Remaining().
|
private |
Remember how many channels were passed to Acquire()
Definition at line 138 of file MixerSource.h.
Referenced by Acquire().
|
private |
Definition at line 108 of file MixerSource.h.
Referenced by MixSameRate(), and MixVariableRates().
|
private |
Definition at line 103 of file MixerSource.h.
Referenced by Acquire(), Channels(), and MakeResamplers().
|
private |
Definition at line 100 of file MixerSource.h.
Referenced by GetSequence(), MixSameRate(), and MixVariableRates().
|
private |
many-to-one mixing of channels Pointer into array of arrays
Definition at line 135 of file MixerSource.h.
Referenced by MixerSpec().
|
private |
The number of available samples after the queue start.
Definition at line 125 of file MixerSource.h.
Referenced by MixVariableRates(), and Reposition().
|
private |
Position of the start of the next block to resample.
Definition at line 122 of file MixerSource.h.
Referenced by MixVariableRates(), and Reposition().
|
private |
Definition at line 104 of file MixerSource.h.
Referenced by Acquire(), and MixVariableRates().
|
private |
Definition at line 128 of file MixerSource.h.
Referenced by MakeResamplers(), and MixVariableRates().
|
private |
Definition at line 127 of file MixerSource.h.
Referenced by Acquire(), MakeResamplers(), and VariableRates().
|
private |
Fetch position for source.
mSamplePos holds the next sample position not yet processed
Definition at line 116 of file MixerSource.h.
Referenced by Acquire(), MixerSource(), MixSameRate(), MixVariableRates(), and Reposition().
|
private |
First intermediate buffer when resampling is needed.
Definition at line 119 of file MixerSource.h.
Referenced by MixVariableRates().
|
private |
Definition at line 110 of file MixerSource.h.
Referenced by Acquire(), MixerSource(), MixSameRate(), and MixVariableRates().
|
staticconstexprprivate |
Cut the queue into blocks of this finer size for variable rate resampling. Each block is resampled at some constant rate.
Definition at line 73 of file MixerSource.h.
Referenced by MixVariableRates().
|
staticconstexprprivate |
This is the number of samples grabbed in one go from a track and placed in a queue, when mixing with resampling.
(Should we use SampleTrack::GetBestBlockSize instead?)
Definition at line 80 of file MixerSource.h.
Referenced by MixVariableRates().