Skip to main content

SampleSource

Trait SampleSource 

Source
pub trait SampleSource {
    // Required methods
    fn len(&self) -> usize;
    fn loop_start(&self) -> usize;
    fn loop_end(&self) -> usize;
    fn loop_kind(&self) -> LoopKind;
    fn at(&self, idx: usize) -> f32;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

Read-only view into a tracker sample body.

Implementations must return samples in the range -1.0..=1.0. The caller (the MixerVoice) manages the fractional read position, so at takes an integer sample index.

Required Methods§

Source

fn len(&self) -> usize

Total number of PCM frames.

Source

fn loop_start(&self) -> usize

Loop start index (frames).

Source

fn loop_end(&self) -> usize

Loop end index (frames), exclusive.

Source

fn loop_kind(&self) -> LoopKind

Loop mode.

Source

fn at(&self, idx: usize) -> f32

Sample at integer index, normalised to -1.0..=1.0. Callers are responsible for ensuring idx < len(); implementations may return 0.0 for out-of-range indices defensively.

Provided Methods§

Source

fn is_empty(&self) -> bool

True if this sample has no PCM data.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§