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§
Trait Implementations§
Source§impl AudioSource for StreamSource
impl AudioSource for StreamSource
Source§fn fill(&mut self, out: &mut [f32]) -> usize
fn fill(&mut self, out: &mut [f32]) -> usize
out with the next block of interleaved-stereo audio.Source§fn reset(&mut self)
fn reset(&mut self)
AdaptiveMusic::reset
calls this on each layer.