Struct Memory Playback
pub struct MemoryPlayback { /* private fields */ }Expand description
Owned interleaved f32 clip with a sample-counted transport. Preparation copies 1..=16,777,216 finite samples (at most 64 MiB), validates 1..64 channels, 1..768,000 Hz metadata and 1..65,536 maximum render frames. Empty clips reject. All subsequent operations are bounded, allocation-free, exclusively borrowed and perform no I/O. Drop frees the owned clip off audio.
Playback has no resampling, crossfade, smoothing or device-clock mapping. Consumers must run at the clip rate and serialize commands on the owning audio thread; the API supplies no cross-thread command queue. Pause retains position. Seek permits EOF and preserves play/pause. A loop is half-open, nonempty and within the clip; enabling it moves a position outside its range to its start. Boundary transitions can click. End stops playback at EOF.
Implementations§
§impl MemoryPlayback
impl MemoryPlayback
pub fn new( samples: &[f32], channels: usize, sample_rate: u32, maximum_frames: usize, ) -> Result<Self, PlaybackError>
pub fn maximum_render_frames(&self) -> usize
pub fn maximum_render_frames(&self) -> usize
Fixed callback bound prepared with the clip; configuration must not exceed it.
pub fn channels(&self) -> usize
pub fn sample_rate(&self) -> u32
pub fn frames(&self) -> usize
pub fn position(&self) -> usize
pub fn is_playing(&self) -> bool
pub fn loop_range(&self) -> Option<Range<usize>>
pub fn play(&mut self)
pub fn play(&mut self)
Start from the current position; EOF without a loop remains stopped.
pub fn pause(&mut self)
pub fn stop(&mut self)
pub fn stop(&mut self)
Pause and return to frame zero, or the configured loop’s start.
pub fn seek(&mut self, frame: usize) -> Result<(), PlaybackError>
pub fn set_loop( &mut self, range: Option<Range<usize>>, ) -> Result<(), PlaybackError>
pub fn render(
&mut self,
output: &mut [f32],
) -> Result<PlaybackProgress, PlaybackError>
pub fn render( &mut self, output: &mut [f32], ) -> Result<PlaybackProgress, PlaybackError>
Render complete interleaved frames, filling every supplied sample. Reject malformed/oversized buffers before advancing; zero-frame renders preserve play/pause and report current EOF. Paused/end suffixes are zero.