API Reference
AudioStreamOpenMPT
Main resource class for tracker modules. Extends Godot’s AudioStream class.
Properties
- data: PackedByteArray
The raw module file data. Setting this property will attempt to load the module.
- mix_rate: int
Sample rate for playback in Hz. Default is 48000.
Methods
Loading
- load_from_file(path: String) Error
Load a module from a file path.
- Parameters:
path – Path to the module file (e.g., “res://music/song.mod”)
- Returns:
OK on success, or an error code
- Return type:
Error
Example:
var stream = AudioStreamOpenMPT.new() var error = stream.load_from_file("res://music/song.mod") if error == OK: print("Module loaded successfully!")
- load_from_data(data: PackedByteArray) Error
Load a module from raw byte data.
- Parameters:
data – Module file data as PackedByteArray
- Returns:
OK on success, ERR_INVALID_DATA if the data is invalid
- Return type:
Error
Metadata
- get_title() String
Get the module title from metadata.
- Returns:
Module title, or empty string if not available
- get_artist() String
Get the artist/author name from metadata.
- Returns:
Artist name, or empty string if not available
- get_message() String
Get the module message/comments.
- Returns:
Module message, or empty string if not available
- get_length() float
Get the module duration in seconds.
- Returns:
Duration in seconds
- get_bpm() float
Get the current tempo (beats per minute).
- Returns:
BPM value
Module Structure
- get_num_channels() int
Get the number of channels in the module.
- Returns:
Number of channels
- get_num_orders() int
Get the number of orders in the sequence.
- Returns:
Number of orders
- get_num_patterns() int
Get the number of patterns.
- Returns:
Number of patterns
- get_num_instruments() int
Get the number of instruments.
- Returns:
Number of instruments
- get_num_samples() int
Get the number of samples.
- Returns:
Number of samples
Names and Lists
- get_channel_names() PackedStringArray
Get all channel names.
- Returns:
Array of channel names
- get_instrument_names() PackedStringArray
Get all instrument names.
- Returns:
Array of instrument names
Example:
var instruments = stream.get_instrument_names() for i in range(instruments.size()): print("Instrument ", i, ": ", instruments[i])
- get_sample_names() PackedStringArray
Get all sample names.
- Returns:
Array of sample names
AudioStreamPlaybackOpenMPT
Playback control class. Extends Godot’s AudioStreamPlayback class. Access this via AudioStreamPlayer.get_stream_playback().
Methods
Playback Control
- set_position(position: float) void
Seek to a specific position in seconds.
- Parameters:
position – Position in seconds
- get_position() float
Get the current playback position in seconds.
- Returns:
Current position
- set_repeat_count(count: int) void
Set the loop count.
- Parameters:
count – Number of times to repeat (-1 for infinite loop, 0 for no repeat)
- get_repeat_count() int
Get the current loop count setting.
- Returns:
Loop count
Real-time Effects
- set_tempo_factor(factor: float) void
Change the playback speed without affecting pitch.
- Parameters:
factor – Tempo multiplier (1.0 = normal, 2.0 = double speed, 0.5 = half speed)
Example:
var playback = player.get_stream_playback() as AudioStreamPlaybackOpenMPT playback.set_tempo_factor(1.5) # Play 50% faster
- get_tempo_factor() float
Get the current tempo factor.
- Returns:
Current tempo multiplier
- set_pitch_factor(factor: float) void
Change the pitch without affecting tempo.
- Parameters:
factor – Pitch multiplier (1.0 = normal, 2.0 = one octave up, 0.5 = one octave down)
- get_pitch_factor() float
Get the current pitch factor.
- Returns:
Current pitch multiplier
Inherited Methods
From AudioStreamPlayback:
_start(from_pos: float)- Start playback_stop()- Stop playback_is_playing()- Check if playing_get_loop_count()- Get number of loops completed_seek(time: float)- Seek to time position