Skip to main content

StreamSource

Struct StreamSource 

Source
pub struct StreamSource { /* private fields */ }
Expand description

An AudioSource over the stateful streaming renderer: streams a doc’s graph indefinitely — mono duplicated to stereo. Returns None for docs outside the streamable subset (the caller falls back to a buffer-backed Player/instance). This is how a game feeds the streaming renderer straight to a cpal / AudioWorklet callback for continuous generative content.

fill is allocation-free for blocks up to 8192 frames (the scratch is pre-allocated at construction); a larger block grows it once, on the first such call. Caveats past the document’s duration: a seq yields silence past its pre-rendered buffer (only oscillators/noise truly run forever), and the baked peak-limit gain was measured over the document only — free-running output past duration is un-limited and can clip where the finite bounce could not.

Byte-identity: the offline bounce ends in a transparent sample-peak safety limit, a whole-buffer gain that cannot be computed causally. StreamSource::from_doc therefore measures the finite render’s peak with one throwaway pass of the same deterministic graph (O(duration) time, O(1) memory) and bakes the identical constant gain, so the stream matches the bounce bit-for-bit over the document’s duration.

Implementations§

Source§

impl StreamSource

Source

pub fn from_doc(doc: &SoundDoc) -> Option<Self>

Build a streaming source for doc, or None if it isn’t streamable.

Trait Implementations§

Source§

impl AudioSource for StreamSource

Source§

fn fill(&mut self, out: &mut [f32]) -> usize

Fill out with the next block of interleaved-stereo audio.
Source§

fn reset(&mut self)

Rewind the source to its start (playback position / phase to zero). Defaults to a no-op; a looping source overrides it so a transport can restart it from the top. AdaptiveMusic::reset calls this on each layer.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more