Struct XMContext

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

The XM context.

Implementations§

Source§

impl XMContext

Source

pub fn new(mod_data: &[u8], rate: u32) -> Result<XMContext, XMError>

Creates an XM context.

§Parameters
  • mod_data - The contents of the module.
  • rate - The play rate in Hz. Recommended value is 48000.
Source

pub fn generate_samples(&mut self, output: &mut [f32])

Plays the module and puts the sound samples in the specified output buffer. The output is in stereo.

Source

pub fn set_max_loop_count(&mut self, loopcnt: u8)

Sets the maximum number of times a module can loop.

After the specified number of loops, calls to generate_samples() will generate silence.

Source

pub fn loop_count(&self) -> u8

Gets the loop count of the currently playing module.

This value is 0 when the module is still playing, 1 when the module has looped once, etc.

Source

pub fn module_name(&self) -> Option<&[u8]>

Gets the module name as a byte slice. The string encoding is unknown.

Returns None if the XM_STRINGS build setting is false.

Source

pub fn tracker_name(&self) -> Option<&[u8]>

Gets the tracker name as a byte slice. The string encoding is unknown.

Returns None if the XM_STRINGS build setting is false.

Source

pub fn number_of_channels(&self) -> u16

Gets the number of channels.

Source

pub fn module_length(&self) -> u16

Gets the module length (in patterns).

Source

pub fn number_of_patterns(&self) -> u16

Gets the number of patterns.

Source

pub fn number_of_rows(&self, pattern: u16) -> u16

Gets the number of rows in a pattern.

§Note

Pattern numbers go from 0 to get_number_of_patterns() - 1

Source

pub fn number_of_instruments(&self) -> u16

Gets the number of instruments.

Source

pub fn number_of_samples(&self, instrument: u16) -> u16

Gets the number of samples of an instrument.

§Note

Instrument numbers go from 1 to get_number_of_instruments()

Source

pub fn playing_speed(&self) -> PlayingSpeed

Gets the current module speed.

Source

pub fn position(&self) -> Position

Gets the current position in the module being played.

Source

pub fn latest_trigger_of_instrument(&self, instrument: u16) -> u64

Gets the latest time (in number of generated samples) when a particular instrument was triggered in any channel.

§Note

Instrument numbers go from 1 to get_number_of_instruments()

Source

pub fn latest_trigger_of_sample(&self, instrument: u16, sample: u16) -> u64

Get the latest time (in number of generated samples) when a particular sample was triggered in any channel.

§Note

Instrument numbers go from 1 to get_number_of_instruments()

Sample numbers go from 0 to get_number_of_samples(instrument) - 1

Source

pub fn latest_trigger_of_channel(&self, channel: u16) -> u64

Get the latest time (in number of generated samples) when any instrument was triggered in a given channel.

§Note

Channel numbers go from 1 to get_number_of_channels()

Trait Implementations§

Source§

impl Drop for XMContext

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for XMContext

Source§

impl Sync for XMContext

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.