AUDIO
Source snapshot · 11 November 2026

API reference / ravet_audio_file::MemoryPlayback

Struct MemoryPlayback 

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

pub fn new( samples: &[f32], channels: usize, sample_rate: u32, maximum_frames: usize, ) -> Result<Self, PlaybackError>

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)

Start from the current position; EOF without a loop remains stopped.

pub fn pause(&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>

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.

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> 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<F, T> IntoSample<T> for Fwhere T: FromSample<F>,

§

fn into_sample(self) -> T

§

impl<T> Same for T

§

type Output = T

Should always be Self
§

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.