AUDIO
Source snapshot · 12 October 2026

API reference / ravet_graph::AlignmentPolicy

Enum AlignmentPolicy 

pub enum AlignmentPolicy {
    None,
    DelayLower {
        maximum_difference: usize,
    },
}
Expand description

Optional latency alignment between the outgoing and incoming engines (see convolution_transition_with_continuity).

Under AlignmentPolicy::DelayLower the audio endpoint keeps two delay lines of maximum_difference + maximum_frames frames per channel, prepared at construction; each records its engine’s raw output. When a transition from latency a to latency b starts, the lower-latency path is delayed by |a - b| frames for the whole fade, so both paths are aligned at max(a, b):

  • b > a: the old path is delayed from the fade start; the output latency changes from a to b at the start frame (the old path repeats its last b - a output frames while its gain is near one).
  • b < a: the new path is delayed during the fade; the output latency stays a and changes to b at the frame where the fade completes (the delay is released while only the new path is audible, skipping a - b of its output frames).
  • a cut (frames == 0) changes the output latency at the start frame, with no delay (an unaligned jump).

Without PrimingPolicy::History the incoming engine has no output from before the fade start, so when b < a its delayed path reads zeros for the first a - b fade frames: it stays silent while its gain rises, and if a - b is at least the fade length it contributes nothing before the release, deepening the level dip. Priming fills those frames.

Each change is reported through TransitionStatus::output_latency_change and TransitionEvent::OutputLatencyChanged, and ConvolutionTransition::output_latency_samples gives the current value. Outside fades no delay is applied. A proposal whose latency differs from the current engine’s by more than maximum_difference is refused at the block boundary where it would start (only the audio endpoint knows the current engine): it is returned unused as ReturnReason::Refused with TransitionEvent::AlignmentRefused, through a reserved returned slot; if none is free it stays where it is and the boundary reports retirement_blocked. Under LatencyPolicy::RequireEqual no difference can arise and the policy has no effect.

Cost: every block copies each engine’s output through its line, proportional to the block. The boundary that takes a proposal forgets the incoming line and ConvolutionTransition::reset forgets both in constant time: each line tracks how many frames were written since it was forgotten and reads older positions as zero, so no clear proportional to the prepared size (channels * (maximum_difference + maximum_frames) samples) is performed. No allocation is performed.

Variants§

§

None

No alignment (the default behaviour): the fade mixes both latencies.

§

DelayLower

Delay the lower-latency path by the latency difference during the fade.

Fields

§maximum_difference: usize

Largest accepted latency difference and delay in frames, 0..=TRANSITION_MAXIMUM_ALIGNMENT_FRAMES.

Trait Implementations§

§

impl Clone for AlignmentPolicy

§

fn clone(&self) -> AlignmentPolicy

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · §

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Copy for AlignmentPolicy

§

impl Debug for AlignmentPolicy

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl Eq for AlignmentPolicy

§

impl PartialEq for AlignmentPolicy

§

fn eq(&self, other: &AlignmentPolicy) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · §

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
§

impl StructuralPartialEq for AlignmentPolicy

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.