Struct PcmTrack

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

A progressive PCM stream with one fixed source format.

Implementations§

Source§

impl PcmTrack

Source

pub fn open(path: &Path) -> Result<Self, Error>

Open a local audio file without decoding it in full.

Source

pub fn open_native(path: &Path) -> Result<Self, Error>

Native-only progressive decode for cooperative background extraction, without a child process.

Source

pub fn open_stereo(path: &Path) -> Result<Self, Box<dyn Error>>

Prepare stereo output for known multichannel material. Mono and stereo keep their original samples and channel positions.

Source

pub fn format(&self) -> PcmStreamFormat

The PCM format a sink must accept for this track.

Source

pub fn source_format(&self) -> PcmStreamFormat

Decoded source format before an optional stereo downmix.

Source

pub fn flac_md5_status(&self) -> Option<FlacMd5Status>

FLAC source verification for this run, before downmix, resampling or DSP.

Only a fully decoded source reaching EOF can be verified; another codec returns None. This status does not alter persisted integrity results.

Source

pub fn set_output_rate(&mut self, rate: u32) -> Result<(), RateError>

Choose the sink’s sample rate before seeking or reading the first block. When rates match, samples retain the exact decoded path.

Source

pub fn seek_from_start( &mut self, position: Duration, cancelled: impl FnMut() -> bool, ) -> Result<SeekResult, Error>

Position a newly opened track at the source frame at or before position.

Seeking progressively decodes and discards the prefix, without sending it through the source observer, downmix, resampler or caller’s DSP. It preserves the ordinary decoder’s delay, padding and error semantics and uses no whole-file buffer. Work grows with the requested position; cancellation is checked between bounded frame steps, though one decoder call may block on I/O. A position beyond EOF returns the actual frame count with reached_eof set, rather than trusting tag duration.

Call at most once, before reading PCM. Set the output rate first when needed. A backward or subsequent seek requires reopening the track and resetting the driver’s output and DSP session. After cancellation or a decode error, discard this track. Measurements of the suffix are not a full-track loudness result and must not be cached as one.

Source

pub fn read_block<E>( &mut self, process: impl FnOnce(&mut [f32]) -> Result<(), E>, ) -> Result<Option<PcmBlock<'_>>, StreamError<E>>

Read, optionally process, and encode the next block.

Returns None only at end of file. The processing function is called once for each nonempty block and may retain state between calls. The returned views are valid until the next call to read_block.

Source

pub fn read_block_observed<E>( &mut self, observe: impl FnMut(PcmStreamFormat, &[f32]), process: impl FnOnce(&mut [f32]) -> Result<(), E>, ) -> Result<Option<PcmBlock<'_>>, StreamError<E>>

Read a block while observing decoded source PCM before any downmix, rate conversion or caller-supplied processing.

The observer receives each nonempty source block exactly once with its original format. One output block may require several source blocks, or contain only a converter tail; the tail and EOF are never observed. Observers that perform optional measurements should retain their own errors without interrupting playback.

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.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

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.

§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

§

fn into_sample(self) -> T

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

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.
§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,