Defined in macros/scripts/audio.asm and audio/engine.asm:MusicCommands.
Note: Commands that are intended for the song channels (1-4) can be used by the sound effect channels (5-8) if the sound effect channel exits sound effect mode with the toggle_sfx
command.
Used at the start of each sound header to specify how many channels are used in the sound.
n
: Number of channels [1
, 4
]
Used for each channel in a sound header.
index
: Channel number [1
, 8
]
address
: Pointer to the sound data
Play a basic note. Used by channels 1-3.
pitch
: Pitch of note (see constants/audio_constants.asm)
length
: Length of note in "ticks" [1
, 16
]. The exact duration of a tick is dependant on the current "speed" (see note_type
and drum_speed
) and the current "tempo" (see tempo
).
Play a predefined drum note. Used by channel 4.
instrument
: Instrument ID [1
, 12
] (see toggle_noise
)
length
: Length of note [1
, 16
]
Basic rest. Used by channels 1-4.
length
: Length of rest [1
, 16
]
Sound effect square note. Used by channels 5-7.
length
: Length of note [0
, 255
]
volume
: Initial volume [0
, 15
]
fade
: Volume fade [-7
, 7
]
frequency
: Note frequency [0
, 65535
]
Sound effect noise note. Used by channel 8.
length
: Length of note [0
, 255
]
volume
: Initial volume [0
, 15
]
fade
: Volume fade [-7
, 7
]
frequency
: Note frequency [0
, 255
]
Set the octave for the notes played on the current channel. Used by channels 1-3.
n
: New octave [1
, 8
]
Set persistent note properties. Used by channels 1-3.
length
: Base note length [1
, 15
] (12
is often used for 4/4 common time because 12
is factorable by both 3
and 4
. Therefore it works very well for quarter notes, eighth notes, sixteenth notes, and triplets.)
volume
: Initial volume [0
, 15
] for channels 1-2, [0
, 3
] for channel 3 (see volume_envelope
)
fade
: Volume fade [-7
, 7
] (applies to channels 1-2)
wave_instrument
: Wave instrument ID (applies to channel 3) (see audio/wave_samples.asm)
Set persistent note properties. Used by channel 4.
length
: Base note length [1
, 15
] (use 12
for common time)
Transpose all notes played on the current channel. Used by channels 1-3.
num_octaves
: Number of octaves to subtract from each note
num_pitches
: Number of pitches to add to each note
Set the tempo for all playing channels. This should only be used by channel 1.
The formula to convert from this tempo to BPM is: BPM = 19200 / tempo
This formula also works backwards to convert BPM to tempo: tempo
= 19200 / BPM
Only set or change this value when all playing channels are triggering a note or rest at the same time, otherwise desyncs may happen.
Set the square duty (sound) for the current channel. Used by channels 1-2.
The only accepted values are 0-3.
- 0 = 12.5% waveform:
_______¯
- 1 = 25% waveform:
______¯¯
- 2 = 50% waveform:
____¯¯¯¯
- 3 = 75% waveform:
__¯¯¯¯¯¯
(sounds the same as 25%)
To change the sound for channel 3, use note_type
or volume_envelope
.
Set the volume envelope for the current channel. Used by channels 1-3.
volume
: Initial volume [0
, 15
] for channels 1-2, [0
, 3
] for channel 3
fade
: Volume fade [-7
, 7
] (applies to channels 1-2)
wave_instrument
: Wave instrument ID (applies to channel 3) (see audio/wave_samples.asm)
For channel 3, the only accepted volume
values are 0-3.
- 0 = Mute
- 1 = 100% volume
- 2 = 50% volume
- 3 = 25% volume
Note about fade
: A positive value means a decrease in volume; a negative value means an increase in volume. A small magnitude means a quick change; a large magnitude means a slow change. It is stored in signed magnitude representation, so a value of 8
is the same as (negative) 0
.
Set pitch sweep properties. Used by channel 5.
length
: Duration of effect [0
, 15
]
pitch_change
: Extent of effect [-7
, 8
] Note: 8
is used in place of 0
Set duty cycle pattern (ie, pulse width modulation). Used by channels 5-6.
This cycles the channel through 4 duty cycles, one per frame.
Each argument defines a duty cycle, same as the duty_cycle
command.
Toggle between pitch-based songs and frequency-based sound effects. Can be used by any channel.
Note: Similar to the pokered command execute_music
, however execute_music
can only be used on channels 5-8 and can not be disabled for the duration of the sound once it is enabled.
Bend the pitch of the next note played, and only that note. Used by channel 1.
duration
: Duration of the target note after slide effect
octave
: Target octave
pitch
: Target pitch (see constants/audio_constants.asm)
Apply vibrato to current channel. Used by channels 1-3.
delay
: Delay until vibrato effect begins for each note [0
, 255
]
extent
: Amplitude of vibrato [0
, 15
]
rate
: Frequency of vibrato [0
, 15
]
Set the "drum kit" to be used if it is currently unset. Mute the channel otherwise. Used by channel 4.
id
: Drum kit ID [0
, 5
] (see audio/drumkits.asm)
Note: The drum kit ID is initially unset at the start of a song. When muting the channel, the id
argument must not be present.
Set left/right stereo output for the current channel, regardless of user's stereo setting. Used by channels 1-4.
left_enable
: TRUE
/FALSE
right_enable
: TRUE
/FALSE
Set master volume for left/right speakers. Typically only used by channel 1.
left_volume
: Left speaker volume [0
, 7
]
right_volume
: Right speaker volume [0
, 7
]
Note: Minimum volume, 0
, is not muted.
Adjust the pitch of all notes on the current channel. Used by channels 1-3.
pitch_offset
: Frequency adjustment of each pitch
Note: Similar to the pokered command toggle_perfect_pitch
. toggle_perfect_pitch
can be replaced with a combination of pitch_offset 1
and pitch_offset 0
.
Set left/right stereo output for the current channel, if the user has stereo mode enabled. Used by channels 1-4.
left_enable
: TRUE
/FALSE
right_enable
: TRUE
/FALSE
Set the "drum kit" to be used if it is currently unset. Mute the channel otherwise. Used by channel 8.
id
: Drum kit ID [0
, 5
] (see audio/drumkits.asm)
Note: The drum kit ID is initially unset at the start of a song. When muting the channel, the id
argument must not be present.
Execute a branch of sound commands a total of count
times.
count
: Number of times to execute the loop (including the first execution) (use 0
for an infinite loop)
address
: Pointer to the start of the loop of sound commands
Execute a branch of sound commands, returning to the call point once a sound_ret
command is reached.
address
: Pointer to the branch of sound commands to call
Return to the caller (ie, sound_call
) if in a sub branch. End the sound otherwise.