![]() |
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 SampleTrack &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 SampleTrack * | GetChannel (unsigned iChannel) 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 iChannel, size_t maxOut, float &floatBuffer) |
size_t | MixVariableRates (unsigned iChannel, size_t maxOut, float &floatBuffer) |
void | ZeroFill (size_t produced, size_t max, float &floatBuffer) |
Private Attributes | |
const std::shared_ptr< const SampleTrack > | 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 |
std::vector< SampleTrackCache > | mInputTrack |
SampleTrackCaches are the source of data. More... | |
std::vector< sampleCount > | mSamplePos |
Fetch position for source. More... | |
std::vector< std::vector< float > > | mSampleQueue |
First intermediate buffer when resampling is needed. More... | |
std::vector< int > | mQueueStart |
Position in each queue of the start of the next block to resample. More... | |
std::vector< int > | mQueueLen |
For each queue, 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 30 of file MixerSource.h.
Definition at line 33 of file MixerSource.h.
Definition at line 32 of file MixerSource.h.
MixerSource::MixerSource | ( | const SampleTrack & | 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 283 of file MixerSource.cpp.
References TrackList::Channels(), GetChannel(), MakeResamplers(), mInputTrack, mnChannels, mSamplePos, mTimesAndSpeed, and SampleTrack::TimeToLongSamples().
|
default |
|
default |
|
overridevirtual |
Implements AudioGraph::Source.
Definition at line 335 of file MixerSource.cpp.
References mEnvValues.
Referenced by AcceptsBuffers(), and Acquire().
|
overridevirtual |
Implements AudioGraph::Source.
Definition at line 330 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 342 of file MixerSource.cpp.
References _, AcceptsBlockSize(), AcceptsBuffers(), AudioGraph::Buffers::BlockSize(), AudioGraph::Buffers::Channels(), GetChannel(), 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 SampleTrack * MixerSource::GetChannel | ( | unsigned | iChannel | ) | const |
Definition at line 317 of file MixerSource.cpp.
References TrackList::Channels(), and mpLeader.
Referenced by Acquire(), MixerSource(), and Reposition().
|
private |
Definition at line 41 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 325 of file MixerSource.cpp.
References mpMap.
|
private |
result <= maxOut
Definition at line 213 of file MixerSource.cpp.
References _, floatSample, i, limitSampleBufferSize(), mEnvValues, min(), mInputTrack, mMayThrow, mRate, mSamplePos, mTimesAndSpeed, and ReverseSamples().
Referenced by Acquire().
|
private |
result <= maxOut
Definition at line 69 of file MixerSource.cpp.
References _, anonymous_namespace{MixerSource.cpp}::ComputeWarpFactor(), floatSample, i, limitSampleBufferSize(), mEnvelope, mEnvValues, min(), mInputTrack, mMayThrow, mQueueLen, mQueueStart, mRate, mResample, mSamplePos, mSampleQueue, mTimesAndSpeed, ReverseSamples(), 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 395 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 389 of file MixerSource.cpp.
References mLastProduced.
Referenced by Acquire().
void MixerSource::Reposition | ( | double | time, |
bool | skipping | ||
) |
Definition at line 411 of file MixerSource.cpp.
References GetChannel(), MakeResamplers(), mnChannels, mQueueLen, mQueueStart, mSamplePos, and SampleTrack::TimeToLongSamples().
|
overridevirtual |
Reimplemented from AudioGraph::Source.
Definition at line 401 of file MixerSource.cpp.
|
inline |
Definition at line 61 of file MixerSource.h.
References mResampleParameters, and MixerOptions::ResampleParameters::mVariableRates.
Referenced by Mixer::NeedsDither().
|
private |
produced <= max
Definition at line 275 of file MixerSource.cpp.
Referenced by Acquire().
|
private |
Definition at line 95 of file MixerSource.h.
Referenced by MixSameRate(), and MixVariableRates().
|
private |
Resampling, as needed, after gain envelope.
Definition at line 101 of file MixerSource.h.
Referenced by MixVariableRates().
|
private |
Gain envelopes are applied to input before other transformations.
Definition at line 128 of file MixerSource.h.
Referenced by AcceptsBlockSize(), MixSameRate(), and MixVariableRates().
|
private |
SampleTrackCaches are the source of data.
Definition at line 107 of file MixerSource.h.
Referenced by MixerSource(), MixSameRate(), and MixVariableRates().
|
private |
Definition at line 136 of file MixerSource.h.
Referenced by Acquire(), Release(), and Remaining().
|
private |
Remember how many channels were passed to Acquire()
Definition at line 135 of file MixerSource.h.
Referenced by Acquire().
|
private |
Definition at line 102 of file MixerSource.h.
Referenced by MixSameRate(), and MixVariableRates().
|
private |
Definition at line 97 of file MixerSource.h.
Referenced by Acquire(), Channels(), MakeResamplers(), MixerSource(), and Reposition().
|
private |
Definition at line 94 of file MixerSource.h.
Referenced by GetChannel().
|
private |
many-to-one mixing of channels Pointer into array of arrays
Definition at line 132 of file MixerSource.h.
Referenced by MixerSpec().
|
private |
For each queue, the number of available samples after the queue start.
Definition at line 122 of file MixerSource.h.
Referenced by MixVariableRates(), and Reposition().
|
private |
Position in each queue of the start of the next block to resample.
Definition at line 119 of file MixerSource.h.
Referenced by MixVariableRates(), and Reposition().
|
private |
Definition at line 98 of file MixerSource.h.
Referenced by Acquire(), MixSameRate(), and MixVariableRates().
|
private |
Definition at line 125 of file MixerSource.h.
Referenced by MakeResamplers(), and MixVariableRates().
|
private |
Definition at line 124 of file MixerSource.h.
Referenced by Acquire(), MakeResamplers(), and VariableRates().
|
private |
Fetch position for source.
mSamplePos holds for each track the next sample position not yet processed.
Definition at line 113 of file MixerSource.h.
Referenced by Acquire(), MixerSource(), MixSameRate(), MixVariableRates(), and Reposition().
|
private |
First intermediate buffer when resampling is needed.
Definition at line 116 of file MixerSource.h.
Referenced by MixVariableRates().
|
private |
Definition at line 104 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 69 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 76 of file MixerSource.h.
Referenced by MixVariableRates().