![]() |
Audacity 3.2.0
|
Functions for doing the mixdown of the tracks. More...
#include <Mix.h>
Classes | |
struct | Input |
struct | Source |
Public Types | |
enum class | ApplyGain { Discard , MapChannels , Mixdown } |
using | WarpOptions = MixerOptions::Warp |
using | MixerSpec = MixerOptions::Downmix |
using | ResampleParameters = MixerOptions::ResampleParameters |
using | TimesAndSpeed = MixerOptions::TimesAndSpeed |
using | Stages = std::vector< MixerOptions::StageSpecification > |
using | Inputs = std::vector< Input > |
![]() | |
using | Buffers = AudioGraph::Buffers |
Public Member Functions | |
Mixer (Inputs inputs, std::optional< Stages > masterEffects, bool mayThrow, const WarpOptions &warpOptions, double startTime, double stopTime, unsigned numOutChannels, size_t outBufferSize, bool outInterleaved, double outRate, sampleFormat outFormat, bool highQuality=true, MixerSpec *mixerSpec=nullptr, ApplyGain applyGain=ApplyGain::MapChannels) | |
Mixer (const Mixer &)=delete | |
Mixer & | operator= (const Mixer &)=delete |
virtual | ~Mixer () |
size_t | BufferSize () const |
size_t | Process (size_t maxSamples) |
size_t | Process () |
void | Reposition (double t, bool bSkipping=false) |
Reposition processing to absolute time next time Process() is called. More... | |
void | SetTimesAndSpeed (double t0, double t1, double speed, bool bSkipping=false) |
Used in scrubbing and other nonuniform playback policies. More... | |
void | SetSpeedForKeyboardScrubbing (double speed, double startTime) |
double | MixGetCurrentTime () |
Current time in seconds (unwarped, i.e. always between startTime and stopTime) More... | |
constSamplePtr | GetBuffer () |
Retrieve the main buffer or the interleaved buffer. More... | |
constSamplePtr | GetBuffer (int channel) |
Retrieve one of the non-interleaved buffers. More... | |
sampleFormat | EffectiveFormat () const |
Deduce the effective width of the output, which may be narrower than the stored format. More... | |
![]() | |
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 | Clear () |
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... | |
std::unique_ptr< EffectStage > & | RegisterEffectStage (AudioGraph::Source &upstream, const MixerOptions::StageSpecification &stage, double outRate) |
std::pair< bool, sampleFormat > | NeedsDither (bool needsDither, double rate) const |
Private Attributes | |
const unsigned | mNumChannels |
Inputs | mInputs |
const std::optional< Stages > | mMasterEffects |
const size_t | mBufferSize |
const ApplyGain | mApplyGain |
const bool | mHighQuality |
const sampleFormat | mFormat |
const bool | mInterleaved |
sampleFormat | mEffectiveFormat |
bool | mNeedsDither |
bool | mHasMixerSpec {false} |
const std::shared_ptr< TimesAndSpeed > | mTimesAndSpeed |
AudioGraph::Buffers | mFloatBuffers |
AudioGraph::Buffers | mTemp |
const std::vector< SampleBuffer > | mBuffer |
std::vector< MixerSource > | mSources |
std::vector< EffectSettings > | mSettings |
std::vector< AudioGraph::Buffers > | mStageBuffers |
std::vector< std::unique_ptr< EffectStage > > | mStages |
std::vector< AudioGraph::Source * > | mMasterStages |
std::vector< Source > | mDecoratedSources |
using Mixer::Inputs = std::vector<Input> |
using Mixer::Stages = std::vector<MixerOptions::StageSpecification> |
using Mixer::WarpOptions = MixerOptions::Warp |
|
strong |
Mixer::Mixer | ( | Inputs | inputs, |
std::optional< Stages > | masterEffects, | ||
bool | mayThrow, | ||
const WarpOptions & | warpOptions, | ||
double | startTime, | ||
double | stopTime, | ||
unsigned | numOutChannels, | ||
size_t | outBufferSize, | ||
bool | outInterleaved, | ||
double | outRate, | ||
sampleFormat | outFormat, | ||
bool | highQuality = true , |
||
MixerSpec * | mixerSpec = nullptr , |
||
ApplyGain | applyGain = ApplyGain::MapChannels |
||
) |
inputs
are non-null BufferSize() <= outBufferSize
(equality when no inputs have stages) mixerSpec | Null or else must have a lifetime enclosing this object's |
Definition at line 83 of file Mix.cpp.
References anonymous_namespace{ExportPCM.cpp}::format, and size.
|
delete |
|
virtualdefault |
|
overrideprivatevirtual |
Implements AudioGraph::Source.
Definition at line 413 of file Mix.cpp.
References BufferSize().
Referenced by AcceptsBuffers().
|
overrideprivatevirtual |
Implements AudioGraph::Source.
Definition at line 407 of file Mix.cpp.
References AcceptsBlockSize(), AudioGraph::Buffers::BlockSize(), AudioGraph::Buffers::Channels(), and mNumChannels.
|
overrideprivatevirtual |
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 432 of file Mix.cpp.
References AudioGraph::Buffers::Advance(), AudioGraph::Buffers::Channels(), AudioGraph::Buffers::ClearBuffer(), staffpad::vo::copy(), Discard, details::end(), AudioGraph::Buffers::GetReadPosition(), anonymous_namespace{StretchingSequenceIntegrationTest.cpp}::iChannel, AudioGraph::IsMono(), mApplyGain, mDecoratedSources, mFloatBuffers, mHasMixerSpec, MixBuffers(), Mixdown, mNumChannels, AudioGraph::Buffers::Rotate(), and stackAllocate.
Referenced by Process().
|
inline |
Definition at line 80 of file Mix.h.
Referenced by AcceptsBlockSize(), and Process().
|
private |
Definition at line 262 of file Mix.cpp.
References AudioGraph::Buffers::Channels(), AudioGraph::Buffers::ClearBuffer(), mBufferSize, and mTemp.
Referenced by Process().
sampleFormat Mixer::EffectiveFormat | ( | ) | const |
Deduce the effective width of the output, which may be narrower than the stored format.
Definition at line 347 of file Mix.cpp.
References mEffectiveFormat.
Referenced by MixAndRender().
constSamplePtr Mixer::GetBuffer | ( | ) |
Retrieve the main buffer or the interleaved buffer.
Definition at line 337 of file Mix.cpp.
References mBuffer.
Referenced by MixAndRender().
constSamplePtr Mixer::GetBuffer | ( | int | channel | ) |
double Mixer::MixGetCurrentTime | ( | ) |
Current time in seconds (unwarped, i.e. always between startTime and stopTime)
This value is not accurate, it's useful for progress bars and indicators, but nothing else.
Definition at line 352 of file Mix.cpp.
References mTimesAndSpeed.
Referenced by anonymous_namespace{ExportPluginHelpers.cpp}::EvalExportProgress(), and MixAndRender().
|
private |
TODO: more-than-two-channels
Definition at line 201 of file Mix.cpp.
References Discard, mApplyGain, mFormat, mHasMixerSpec, Mixdown, mNumChannels, mSources, narrowestSampleFormat, and MixerSource::VariableRates().
|
inline |
result <= BufferSize()
Definition at line 99 of file Mix.h.
References BufferSize, and Process().
Referenced by Process().
size_t Mixer::Process | ( | size_t | maxSamples | ) |
Process a maximum of 'maxSamples' samples and put them into the buffer, at GetBuffer().
maxSamples <= BufferSize()
result <= maxSamples
Definition at line 284 of file Mix.cpp.
References _, Acquire(), BufferSize(), Clear(), CopySamples(), floatSample, AudioGraph::Buffers::GetReadPosition(), gHighQualityDither, gLowQualityDither, mBuffer, mFormat, mHighQuality, mInterleaved, mMasterStages, mNeedsDither, mNumChannels, mTemp, mTimesAndSpeed, none, and SAMPLE_SIZE.
Referenced by MixAndRender().
|
private |
Definition at line 516 of file Mix.cpp.
References EffectStage::Create(), MixerOptions::StageSpecification::factory, factory, mBufferSize, mNumChannels, MixerOptions::StageSpecification::mpFirstInstance, mSettings, mStageBuffers, mStages, MixerOptions::StageSpecification::settings, and settings().
|
overrideprivatevirtual |
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 427 of file Mix.cpp.
|
overrideprivatevirtual |
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 418 of file Mix.cpp.
References mDecoratedSources.
void Mixer::Reposition | ( | double | t, |
bool | bSkipping = false |
||
) |
Reposition processing to absolute time next time Process() is called.
Definition at line 357 of file Mix.cpp.
References _, mSources, and mTimesAndSpeed.
Referenced by SetSpeedForKeyboardScrubbing(), and SetTimesAndSpeed().
void Mixer::SetSpeedForKeyboardScrubbing | ( | double | speed, |
double | startTime | ||
) |
Definition at line 382 of file Mix.cpp.
References _, mTimesAndSpeed, and Reposition().
void Mixer::SetTimesAndSpeed | ( | double | t0, |
double | t1, | ||
double | speed, | ||
bool | bSkipping = false |
||
) |
Used in scrubbing and other nonuniform playback policies.
Definition at line 372 of file Mix.cpp.
References _, mTimesAndSpeed, and Reposition().
|
private |
Definition at line 153 of file Mix.h.
Referenced by Acquire(), and NeedsDither().
|
private |
Definition at line 176 of file Mix.h.
Referenced by GetBuffer(), and Process().
|
private |
Definition at line 145 of file Mix.h.
Referenced by Clear(), and RegisterEffectStage().
|
private |
Definition at line 185 of file Mix.h.
Referenced by Acquire(), and Remaining().
|
private |
Definition at line 159 of file Mix.h.
Referenced by EffectiveFormat().
|
private |
|
private |
Definition at line 155 of file Mix.h.
Referenced by NeedsDither(), and Process().
|
private |
Definition at line 161 of file Mix.h.
Referenced by Acquire(), and NeedsDither().
|
private |
|
private |
|
private |
|
private |
Definition at line 140 of file Mix.h.
Referenced by AcceptsBuffers(), Acquire(), NeedsDither(), Process(), and RegisterEffectStage().
|
private |
Definition at line 179 of file Mix.h.
Referenced by RegisterEffectStage().
|
private |
Definition at line 178 of file Mix.h.
Referenced by NeedsDither(), and Reposition().
|
private |
Definition at line 180 of file Mix.h.
Referenced by RegisterEffectStage().
|
private |
Definition at line 181 of file Mix.h.
Referenced by RegisterEffectStage().
|
private |
|
private |
Definition at line 163 of file Mix.h.
Referenced by MixGetCurrentTime(), Process(), Reposition(), SetSpeedForKeyboardScrubbing(), and SetTimesAndSpeed().