Skip to main content

Module

Struct Module 

Source
pub struct Module {
Show 18 fields pub name: String, pub comment: String, pub profile: CompatibilityProfile, pub frequency_type: FrequencyType, pub restart_position: usize, pub default_tempo: usize, pub default_bpm: usize, pub pattern_order: Vec<Vec<usize>>, pub pattern: Vec<Pattern>, pub pattern_names: Vec<String>, pub channel_names: Vec<String>, pub channel_defaults: Vec<ChannelDefault>, pub instrument: Vec<Instrument>, pub midi_macros: Option<MidiMacros>, pub pattern_highlight: PatternHighlight, pub mix_plugins: Option<MixPlugins>, pub pitch_wheel_depth: u8, pub mix_volume: Volume,
}
Expand description

SoundTracker Module with Steroid

Fields§

§name: String§comment: String§profile: CompatibilityProfile

The format this module was authored in, plus the playback quirks that match its authoring tracker. See crate::compatibility_profile::CompatibilityProfile for the named constructors importers use; editor-authored modules typically leave this at CompatibilityProfile::modern for clean, quirk-free playback.

§frequency_type: FrequencyType§restart_position: usize

Restart index in pattern_order

§default_tempo: usize§default_bpm: usize§pattern_order: Vec<Vec<usize>>

Defines the exact order for the patterns playback It is possible to have several music in the same Module

§pattern: Vec<Pattern>§pattern_names: Vec<String>§channel_names: Vec<String>§channel_defaults: Vec<ChannelDefault>

Per-channel initial state, applied at song start before any pattern row plays. Each entry bundles every property a format’s header can pre-set on a channel: panning, channel volume, mute, surround. Empty means “use defaults for every channel” (centre pan, full volume, unmuted, no surround).

Populated by formats whose header carries per-channel hints — currently S3M (channel_settings) and IT (initial channel pan/volume + surround sentinel). XM/MOD leave it empty: those formats centre every channel at song start, and any per-channel state that follows is encoded in the patterns.

§instrument: Vec<Instrument>§midi_macros: Option<MidiMacros>

Optional MIDI-macro table. Populated by the IT importer when the source file carries an embedded-macros flag; None for non-IT formats and for IT files without macros. Consumed by the replayer’s MIDI-macro interpreter (per-channel filter automation, MIDI-out, etc.).

§pattern_highlight: PatternHighlight

Pattern-grid display hint (rows per beat / rows per measure). Populated from the IT header; XM/S3M/MOD inherit the PatternHighlight::default() 4/16 cadence.

§mix_plugins: Option<MixPlugins>

Optional IT-style mix-plugin table (OpenMPT extension). None for non-IT formats and for IT files without an embedded plugin section.

§pitch_wheel_depth: u8

MIDI pitch-wheel depth declared by the module author, in semitones. The IT header carries this byte (ITTECH:94, “PWD: Pitch wheel depth for MIDI controllers”) so downstream MIDI- out code knows how to scale tracker pitch effects (Gxx/Fxx/ Exx) to MIDI 14-bit pitch-bend values when forwarding notes played through InstrMidi / InstrOpl / InstrSid instruments.

Not consumed by the core replayer. xmrsplayer renders only InstrumentType::Default (sampled) instruments natively; the synth / MIDI-out paths are the responsibility of code that wraps the player and observes its events. This field exists so such wrappers can read a single source of truth instead of carrying their own per-module config.

Macro-driven pitch bend (Zxx / SFx macros encoding En ll mm bytes) is unaffected — the macro author writes the absolute 14-bit value directly, and xmrsplayer’s MidiObserver emits it verbatim. PWD only matters when downstream code is generating pitch bend from a tracker semitone delta.

IT importer copies the header byte. Other formats default to 2 semitones — the General MIDI default a receiver would assume in the absence of an explicit RPN setup. Range per ITTECH is 0..=15.

§mix_volume: Volume

Song-level mix volume scalar (0..1). IT-specific: each IT file carries a “mix volume” register (0..128, default 48) which is a constant mixer-level headroom applied on top of the Vxx-animated global volume. It is NOT part of the Vxx effect chain — authors set it once to reserve dynamic range for resonant-filter peaks and multi-voice summing.

Mix master amplifier, Q1.15 in [0, 1]. Multiplies the final mixed audio. Was f32 — see Volume for the conversion convention.

IT-specific (the IT importer reads it from the file header). Non-IT formats leave this at Volume::FULL (identity). The player reads it once at construction and applies it as a final constant multiplier separate from both global_volume and user-facing amplification.

Implementations§

Source§

impl Module

Source

pub fn get_song_length(&self, song: usize) -> usize

get song length

Source

pub fn get_num_channels(&self) -> usize

get number of channels

Source

pub fn get_num_rows(&self, pat_idx: usize) -> usize

get number of rows

Source§

impl Module

Source

pub fn load_mod(source: &[u8]) -> Result<Self, DecodeError>

Try to import an Amiga ProTracker MOD file.

Source

pub fn load_xm(source: &[u8]) -> Result<Self, DecodeError>

Try to import a Fast Tracker II XM module file.

Source

pub fn load_s3m(source: &[u8]) -> Result<Self, DecodeError>

Try to import a ScreamTracker 3 S3M module file.

Source

pub fn load_it(source: &[u8]) -> Result<Self, DecodeError>

Try to import an Impulse Tracker IT module file.

Source

pub fn load(source: &[u8]) -> Result<Self, DecodeError>

Try to auto-detect and import any supported historical module file (MOD / XM / S3M / IT). Formats are tried in the order XM → S3M → IT → MOD; the Amiga format is tried last because it has the weakest header signature for detection. Only formats whose import_* feature is enabled are attempted.

SID is not auto-detected here — it has its own dedicated entry point via crate::import::sid::sid_module::SidModule::load.

Trait Implementations§

Source§

impl Debug for Module

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Module

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Module

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl ModuleDuration for Module

Source§

fn duration(&self, song: usize) -> Duration

Duration of one play-through of sub-song song, with default options. Returns Duration::ZERO for out-of-range / empty inputs. Read more
Source§

fn duration_with(&self, song: usize, opts: DurationOptions) -> Duration

Same as Self::duration but with explicit options. Useful to measure several consecutive plays (set stop_on_loop: false) or to tighten the runaway cap on memory-constrained targets. Read more
Source§

impl Serialize for Module

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,