Skip to main content

StmPlayerState

Struct StmPlayerState 

Source
pub struct StmPlayerState {
Show 16 fields pub samples: Vec<StmSampleBody>, pub patterns: Vec<StmPattern>, pub order: Vec<u8>, pub n_patterns: u8, pub channels: [StmChannel; 4], pub speed: u8, pub tempo: u8, pub sample_rate: u32, pub order_index: usize, pub row: u8, pub tick: u8, pub tick_sample_cursor: u32, pub ended: bool, pub global_volume: u8, pub pending_order_jump: Option<u8>, pub pending_break_row: Option<u8>,
}
Expand description

STM player — owns decoded patterns / samples and a row/tick/BPM-style state machine.

Fields§

§samples: Vec<StmSampleBody>§patterns: Vec<StmPattern>§order: Vec<u8>§n_patterns: u8§channels: [StmChannel; 4]§speed: u8§tempo: u8§sample_rate: u32§order_index: usize§row: u8§tick: u8§tick_sample_cursor: u32§ended: bool§global_volume: u8§pending_order_jump: Option<u8>

Pending pattern jump (Bxy): set on tick 0 of a row, consumed by next_row.

§pending_break_row: Option<u8>

Pending pattern-break row (Dxy): set on tick 0, consumed by next_row.

Implementations§

Source§

impl StmPlayerState

Source

pub fn new( header: &StmHeader, samples: Vec<StmSampleBody>, patterns: Vec<StmPattern>, sample_rate: u32, ) -> Self

Source

pub fn samples_per_tick(&self) -> u32

Samples-per-tick using the MOD-style formula, with tempo treated as a BPM-ish equivalent. Scream Tracker v1’s tempo register is historically tempo * 2 compared to the S3M / MOD scale; we approximate with bpm_equiv = tempo * 125 / 0x60, matching the estimate_duration_micros heuristic in crate::stm.

Source

pub fn render(&mut self, dst: &mut [i16]) -> usize

Render interleaved stereo S16 PCM into dst (length must be even). STM uses hard-pan LRRL like MOD.

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.

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.

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.