pub struct XMContext { /* private fields */ }
Expand description
The XM context.
Implementations§
Source§impl XMContext
impl XMContext
Sourcepub fn new(mod_data: &[u8], rate: u32) -> Result<XMContext, XMError>
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.
Sourcepub fn generate_samples(&mut self, output: &mut [f32])
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.
Sourcepub fn set_max_loop_count(&mut self, loopcnt: u8)
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.
Sourcepub fn loop_count(&self) -> u8
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.
Sourcepub fn module_name(&self) -> Option<&[u8]>
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.
Sourcepub fn tracker_name(&self) -> Option<&[u8]>
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.
Sourcepub fn number_of_channels(&self) -> u16
pub fn number_of_channels(&self) -> u16
Gets the number of channels.
Sourcepub fn module_length(&self) -> u16
pub fn module_length(&self) -> u16
Gets the module length (in patterns).
Sourcepub fn number_of_patterns(&self) -> u16
pub fn number_of_patterns(&self) -> u16
Gets the number of patterns.
Sourcepub fn number_of_rows(&self, pattern: u16) -> u16
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
Sourcepub fn number_of_instruments(&self) -> u16
pub fn number_of_instruments(&self) -> u16
Gets the number of instruments.
Sourcepub fn number_of_samples(&self, instrument: u16) -> u16
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()
Sourcepub fn playing_speed(&self) -> PlayingSpeed
pub fn playing_speed(&self) -> PlayingSpeed
Gets the current module speed.
Sourcepub fn latest_trigger_of_instrument(&self, instrument: u16) -> u64
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()
Sourcepub fn latest_trigger_of_sample(&self, instrument: u16, sample: u16) -> u64
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
Sourcepub fn latest_trigger_of_channel(&self, channel: u16) -> u64
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()