pub struct AudioRenderer { /* private fields */ }Expand description
Mixes a project’s audio tracks into one project-rate block.
Implementations§
Source§impl AudioRenderer
impl AudioRenderer
Sourcepub fn new(
snapshot: &EngineProject,
channels: usize,
max_block: usize,
) -> Result<Self, EngineError>
pub fn new( snapshot: &EngineProject, channels: usize, max_block: usize, ) -> Result<Self, EngineError>
Builds every track and master processor for a project snapshot. Clip processors are built when the clip is first mixed.
§Errors
Returns EngineError::InvalidAudioConfiguration for an unsupported
channel count, a zero sample rate, or an oversized block.
Sourcepub fn with_taps(
snapshot: &EngineProject,
channels: usize,
max_block: usize,
taps: &[AudioTap],
) -> Result<Self, EngineError>
pub fn with_taps( snapshot: &EngineProject, channels: usize, max_block: usize, taps: &[AudioTap], ) -> Result<Self, EngineError>
Self::new with taps to read beside the mix (Self::tap_channel).
§Errors
As Self::new, and EngineError::InvalidAudioConfiguration for a tap of a track or
bus the project lacks or for more than MAX_AUDIO_TAPS.
Sourcepub fn set_taps(
&mut self,
snapshot: &EngineProject,
taps: &[AudioTap],
) -> Result<(), EngineError>
pub fn set_taps( &mut self, snapshot: &EngineProject, taps: &[AudioTap], ) -> Result<(), EngineError>
Replaces the taps with taps of snapshot and resets the renderer: the next block is
what a renderer built with them mixes. Taps do not change the mix. An unmuted tapped
track or bus is mixed whatever is soloed, taking every unmuted input; a muted one taps
silence.
§Errors
Returns EngineError::InvalidAudioConfiguration for a tap of a track or bus the
project lacks or for more than MAX_AUDIO_TAPS, and leaves the renderer as it was.
Sourcepub fn tap_channel(&self, index: usize, channel: usize) -> &[f32]
pub fn tap_channel(&self, index: usize, channel: usize) -> &[f32]
One channel of tap index from the most recent render: its samples are those of the
mix’s samples at the same positions. Empty for a tap or channel the renderer lacks.
Sourcepub fn set_levels(&mut self, enabled: bool)
pub fn set_levels(&mut self, enabled: bool)
Turns the measuring of levels on or off. Levels do not change the mix.
Sourcepub fn levels(&self) -> &[NodeLevels]
pub fn levels(&self) -> &[NodeLevels]
The levels of the most recent render: every track and bus that is mixed, tracks first, then the master. Empty while levels are off, and for a block that missed a source.
Sourcepub const fn sample_rate(&self) -> u32
pub const fn sample_rate(&self) -> u32
Returns the project sample rate every block uses.
Sourcepub fn track_ids(&self) -> Vec<&TrackId>
pub fn track_ids(&self) -> Vec<&TrackId>
Returns the audio tracks this renderer mixes, in bus order.
Sourcepub fn channel(&self, index: usize) -> &[f32]
pub fn channel(&self, index: usize) -> &[f32]
Returns one mixed output channel from the most recent render.
Sourcepub fn required_lookahead_samples(&self) -> u32
pub fn required_lookahead_samples(&self) -> u32
How far ahead of a block, in samples, the renderer reads its sources.
The renderer reads each path’s input early by its latency to the output (for example a
compressor’s lookahead_ms), so the output lines up with the timeline. Use
Self::audio_needs for source supply, since a cold seek also needs settling history.
Sourcepub fn audio_needs(
&self,
snapshot: &EngineProject,
start_sample: i64,
frames: usize,
) -> Result<Vec<AudioNeed>, EngineError>
pub fn audio_needs( &self, snapshot: &EngineProject, start_sample: i64, frames: usize, ) -> Result<Vec<AudioNeed>, EngineError>
The source intervals rendering frames samples from start_sample reads, for a host to
decode first.
These are exactly what Self::render would read, including any settling replay, so a
host that holds them needs no margin. Overlapping or touching intervals of one source are
merged; disjoint ones stay separate.
§Errors
Returns EngineError::InvalidAudioConfiguration for a negative start, an empty or
oversized block, or a span that does not fit in ticks, and an evaluation error when the
snapshot cannot be evaluated over a block’s span.
Sourcepub const fn required_history_samples(&self) -> i64
pub const fn required_history_samples(&self) -> i64
Settling history replayed on discontinuities, in samples, excluding latency. At most
MAX_SETTLING_SECONDS.
Sourcepub fn set_continuity(&mut self, continuity: AudioContinuity)
pub fn set_continuity(&mut self, continuity: AudioContinuity)
Sets the AudioContinuity policy (default AudioContinuity::Exact). Changing it resets
the renderer.
Sourcepub const fn continuity(&self) -> AudioContinuity
pub const fn continuity(&self) -> AudioContinuity
The policy Self::set_continuity last chose.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Clears every processor history without changing authored parameters.
Self::render resets on its own at discontinuities. Call this only to start fresh exactly
where the last block ended, such as an export beginning where preview stopped.
Sourcepub fn render(
&mut self,
snapshot: &EngineProject,
start_sample: i64,
frames: usize,
provider: &dyn AudioBlockProvider,
transport: TransportState,
) -> Result<AudioRenderStatus, EngineError>
pub fn render( &mut self, snapshot: &EngineProject, start_sample: i64, frames: usize, provider: &dyn AudioBlockProvider, transport: TransportState, ) -> Result<AudioRenderStatus, EngineError>
Mixes frames samples starting at an absolute project-rate sample index.
A block that does not continue the previous one (see AudioContinuity) first resets
every processor and replays the settling history Self::audio_needs asks for, so its
output matches a fresh renderer’s regardless of block size.
Recursive effects settle over a finite horizon (32 exponential time constants plus
filter/feedback margins, capped at MAX_SETTLING_SECONDS), not bit-exactly. Each stage
joins the replay only at its own horizon, so a long reverb on one track replays only that
track.
§Errors
Returns EngineError::InvalidAudioConfiguration for a negative start, an oversized block,
or a span that does not fit in ticks, and an evaluation error when the snapshot cannot be
evaluated over the block’s span.
Sourcepub fn set_normalization_gain_db(
&mut self,
gain_db: f64,
) -> Result<(), EngineError>
pub fn set_normalization_gain_db( &mut self, gain_db: f64, ) -> Result<(), EngineError>
Sets the loudness normalization gain in dB, applied between the master gain and the
limiter. Zero removes it, as does Self::set_loudness_metering.
§Errors
Returns EngineError::InvalidNormalizationGain for a non-finite gain or one whose linear
factor is not a normal f32 (beyond about 760 dB either way).
Sourcepub const fn set_hold_incomplete_blocks(&mut self, hold: bool)
pub const fn set_hold_incomplete_blocks(&mut self, hold: bool)
Whether a block missing a source is held: output as silence with nothing advanced, so rendering it again after the host supplies the source matches an uninterrupted render. Off by default (live playback); exports turn it on.
Sourcepub fn set_loudness_metering(
&mut self,
enabled: bool,
) -> Result<(), EngineError>
pub fn set_loudness_metering( &mut self, enabled: bool, ) -> Result<(), EngineError>
Starts (or restarts from empty) measuring the loudness of what reaches the limiter; false
stops. Only complete requested blocks are measured, never replayed history.
Starting removes the normalization gain (Self::set_normalization_gain_db) so the
authored mix is measured; a gain set afterwards is included.
§Errors
Returns EngineError::InvalidAudioConfiguration for an unsupported layout or rate.
Sourcepub fn loudness_report(&self) -> Option<LoudnessReport>
pub fn loudness_report(&self) -> Option<LoudnessReport>
What the meter has measured, if metering is on.
Sourcepub fn limiter_threshold(&self) -> Option<f64>
pub fn limiter_threshold(&self) -> Option<f64>
The master limiter’s linear threshold, if any. Pass it to
alpha2_audio::LoudnessNormalization::plan so the planned gain stops short of the limiter.
Sourcepub fn set_output_loudness_metering(
&mut self,
enabled: bool,
) -> Result<(), EngineError>
pub fn set_output_loudness_metering( &mut self, enabled: bool, ) -> Result<(), EngineError>
Starts (or restarts from empty) measuring the loudness of the final output, after the
limiter and normalization gain; false stops. Unlike Self::set_loudness_metering it
leaves the gain unchanged.
§Errors
Returns EngineError::InvalidAudioConfiguration for an unsupported layout or rate.
Sourcepub fn output_loudness_report(&self) -> Option<LoudnessReport>
pub fn output_loudness_report(&self) -> Option<LoudnessReport>
What the output meter has measured, if output metering is on.
Sourcepub fn block(&self, status: &AudioRenderStatus) -> AudioBlock
pub fn block(&self, status: &AudioRenderStatus) -> AudioBlock
Copies the most recent render into an owned block for offline sinks.
Sourcepub fn tap_block(
&self,
index: usize,
status: &AudioRenderStatus,
) -> Option<AudioBlock>
pub fn tap_block( &self, index: usize, status: &AudioRenderStatus, ) -> Option<AudioBlock>
Copies tap index of the most recent render into an owned block, as Self::block
copies the mix; None for a tap the renderer lacks.
Auto Trait Implementations§
impl !RefUnwindSafe for AudioRenderer
impl !Sync for AudioRenderer
impl !UnwindSafe for AudioRenderer
impl Forget for AudioRenderer
impl Freeze for AudioRendererwhere
*const u8 is !null: Freeze,
PhantomData<MixNode>: Freeze,
PhantomData<Edge>: Freeze,
PhantomData<usize>: Freeze,
PhantomData<Input>: Freeze,
PhantomData<KeyInput>: Freeze,
PhantomData<(TrackId, usize)>: Freeze,
PhantomData<(ClipId, (usize, usize))>: Freeze,
PhantomData<Box<dyn Processor>>: Freeze,
PhantomData<Option<usize>>: Freeze,
PhantomData<f32>: Freeze,
PhantomData<RetunedNode>: Freeze,
PhantomData<ControlLane>: Freeze,
PhantomData<i64>: Freeze,
PhantomData<Keyframe<f32>>: Freeze,
PhantomData<Animated<f32>>: Freeze,
*const DataBinding is !null: Freeze,
PhantomData<DataBinding>: Freeze,
PhantomData<AudioEffect>: Freeze,
PhantomData<AudioBus>: Freeze,
PhantomData<Channel>: Freeze,
PhantomData<[f64; 12]>: Freeze,
PhantomData<Step>: Freeze,
*const [Bin] is !null: Freeze,
PhantomData<[Bin]>: Freeze,
PhantomData<(usize, usize)>: Freeze,
PhantomData<f64>: Freeze,
PhantomData<HostTap>: Freeze,
PhantomData<NodeLevels>: Freeze,
PhantomData<((ClipId, usize), StretchSlot)>: Freeze,
impl Move for AudioRenderer
impl Send for AudioRenderer
impl Unpin for AudioRenderer
impl UnsafeUnpin for AudioRendererwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<MixNode>: UnsafeUnpin,
PhantomData<Edge>: UnsafeUnpin,
PhantomData<usize>: UnsafeUnpin,
PhantomData<Input>: UnsafeUnpin,
PhantomData<KeyInput>: UnsafeUnpin,
PhantomData<(TrackId, usize)>: UnsafeUnpin,
PhantomData<(ClipId, (usize, usize))>: UnsafeUnpin,
PhantomData<Box<dyn Processor>>: UnsafeUnpin,
PhantomData<Option<usize>>: UnsafeUnpin,
PhantomData<f32>: UnsafeUnpin,
PhantomData<RetunedNode>: UnsafeUnpin,
PhantomData<ControlLane>: UnsafeUnpin,
PhantomData<i64>: UnsafeUnpin,
PhantomData<Keyframe<f32>>: UnsafeUnpin,
PhantomData<Animated<f32>>: UnsafeUnpin,
*const DataBinding is !null: UnsafeUnpin,
PhantomData<DataBinding>: UnsafeUnpin,
PhantomData<AudioEffect>: UnsafeUnpin,
PhantomData<AudioBus>: UnsafeUnpin,
PhantomData<Channel>: UnsafeUnpin,
PhantomData<[f64; 12]>: UnsafeUnpin,
PhantomData<Step>: UnsafeUnpin,
*const [Bin] is !null: UnsafeUnpin,
PhantomData<[Bin]>: UnsafeUnpin,
PhantomData<(usize, usize)>: UnsafeUnpin,
PhantomData<f64>: UnsafeUnpin,
PhantomData<HostTap>: UnsafeUnpin,
PhantomData<NodeLevels>: UnsafeUnpin,
PhantomData<((ClipId, usize), StretchSlot)>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more