Difference between revisions of "Music sequence"
(Add example melody script.) |
|||
| (8 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
dasdasdasdMusic in Super Mario 64 is controlled by sequence files. They are in .m64 format, which is similar to [[wikipedia:MIDI|MIDI]]. A sequence file has a sequence script, that can spawn channels, which have channel scripts, that can spawn layers (also known as tracks), which have layer scripts that can play notes. Each note is performed using an instrument from a sound bank. A sequence file can use multiple banks. The mapping from sequences to sound banks is described in '''sound/sequences.json'''. Channels can switch between banks using a command. However, in practice most sequences limit themselves to a single sound bank. The main exception is sequence 0, which is responsible for sound effects. | dasdasdasdMusic in Super Mario 64 is controlled by sequence files. They are in .m64 format, which is similar to [[wikipedia:MIDI|MIDI]]. A sequence file has a sequence script, that can spawn channels, which have channel scripts, that can spawn layers (also known as tracks), which have layer scripts that can play notes. Each note is performed using an instrument from a sound bank. A sequence file can use multiple banks. The mapping from sequences to sound banks is described in '''sound/sequences.json'''. Channels can switch between banks using a command. However, in practice most sequences limit themselves to a single sound bank. The main exception is sequence 0, which is responsible for sound effects. | ||
| − | A sequence may play up to 16 channels with up to 4 layers per channel. | + | A sequence may play up to 16 channels with up to 4 layers per channel. Several notes can be played simultaneously on a single layer. |
| + | |||
| + | A sequence is played as long as the sequence script is not ended. A channel (including layers) is active as long as the channel script is not ended. | ||
| + | |||
| + | == Note properties == | ||
| + | A note can be played by the commands <code>layer_note0</code>, <code>layer_note1</code> and <code>layer_note2</code> (only valid if <code>chan_largenoteson</code> has been called on the layer's channel) or <code>layer_smallnote0</code>, <code>layer_smallnote1</code> and <code>layer_smallnote2</code> (only valid if <code>chan_largenotesoff</code> has been called on the layer's channel; default state). A note is defined by the following properties: | ||
| + | |||
| + | === Pitch === | ||
| + | Also known as '''note'''. The pitch defines the frequency in which the instrument is to be played. See list of notes below for available pitches. | ||
| + | |||
| + | === Play percentage === | ||
| + | Also known as '''timestamp'''. This defines the note value, such as half or quarter note. This also implies a layer delay of the same amount. See note values below for possible values. | ||
| + | |||
| + | === Velocity === | ||
| + | This is the volume of the note. | ||
| + | |||
| + | === Duration === | ||
| + | Also known as '''gate''' or '''gate time'''. A value of 0 menas the note is heard during the whole percentage, 128 is half of the percentage and 255 almost none. | ||
| + | |||
| + | == List of notes == | ||
| + | This is a list of notes as used by the ''layer_note#'' and ''layer_smallnote#'' commands. | ||
| + | {| class="wikitable" | ||
| + | !Octave | ||
| + | !Note | ||
| + | !Decimal | ||
| + | !Hex (note0) | ||
| + | !Hex (note1) | ||
| + | !Hex (note2) | ||
| + | |- | ||
| + | ! rowspan="3" |0 | ||
| + | !A | ||
| + | |0 | ||
| + | |0x00 | ||
| + | |0x40 | ||
| + | |0x80 | ||
| + | |- | ||
| + | !A♯/B♭ | ||
| + | |1 | ||
| + | |0x01 | ||
| + | |0x41 | ||
| + | |0x81 | ||
| + | |- | ||
| + | !B | ||
| + | |2 | ||
| + | |0x02 | ||
| + | |0x42 | ||
| + | |0x82 | ||
| + | |- | ||
| + | ! rowspan="12" |1 | ||
| + | !C | ||
| + | |3 | ||
| + | |0x03 | ||
| + | |0x43 | ||
| + | |0x83 | ||
| + | |- | ||
| + | !C♯/D♭ | ||
| + | |4 | ||
| + | |0x04 | ||
| + | |0x44 | ||
| + | |0x84 | ||
| + | |- | ||
| + | !D | ||
| + | |5 | ||
| + | |0x05 | ||
| + | |0x45 | ||
| + | |0x85 | ||
| + | |- | ||
| + | !D♯/E♭ | ||
| + | |6 | ||
| + | |0x06 | ||
| + | |0x46 | ||
| + | |0x86 | ||
| + | |- | ||
| + | !E | ||
| + | |7 | ||
| + | |0x07 | ||
| + | |0x47 | ||
| + | |0x87 | ||
| + | |- | ||
| + | !F | ||
| + | |8 | ||
| + | |0x08 | ||
| + | |0x48 | ||
| + | |0x88 | ||
| + | |- | ||
| + | !F♯/G♭ | ||
| + | |9 | ||
| + | |0x09 | ||
| + | |0x49 | ||
| + | |0x89 | ||
| + | |- | ||
| + | !G | ||
| + | |10 | ||
| + | |0x0A | ||
| + | |0x4A | ||
| + | |0x8A | ||
| + | |- | ||
| + | !G♯/A♭ | ||
| + | |11 | ||
| + | |0x0B | ||
| + | |0x4B | ||
| + | |0x8B | ||
| + | |- | ||
| + | !A | ||
| + | |12 | ||
| + | |0x0C | ||
| + | |0x4C | ||
| + | |0x8C | ||
| + | |- | ||
| + | !A♯/B♭ | ||
| + | |13 | ||
| + | |0x0D | ||
| + | |0x4D | ||
| + | |0x8D | ||
| + | |- | ||
| + | !B | ||
| + | |14 | ||
| + | |0x0E | ||
| + | |0x4E | ||
| + | |0x8E | ||
| + | |- | ||
| + | ! rowspan="12" |2 | ||
| + | !C | ||
| + | |15 | ||
| + | |0x0F | ||
| + | |0x4F | ||
| + | |0x8F | ||
| + | |- | ||
| + | !C♯/D♭ | ||
| + | |16 | ||
| + | |0x10 | ||
| + | |0x50 | ||
| + | |0x90 | ||
| + | |- | ||
| + | !D | ||
| + | |17 | ||
| + | |0x11 | ||
| + | |0x51 | ||
| + | |0x91 | ||
| + | |- | ||
| + | !D♯/E♭ | ||
| + | |18 | ||
| + | |0x12 | ||
| + | |0x52 | ||
| + | |0x92 | ||
| + | |- | ||
| + | !E | ||
| + | |19 | ||
| + | |0x13 | ||
| + | |0x53 | ||
| + | |0x93 | ||
| + | |- | ||
| + | !F | ||
| + | |20 | ||
| + | |0x14 | ||
| + | |0x54 | ||
| + | |0x94 | ||
| + | |- | ||
| + | !F♯/G♭ | ||
| + | |21 | ||
| + | |0x15 | ||
| + | |0x55 | ||
| + | |0x95 | ||
| + | |- | ||
| + | !G | ||
| + | |22 | ||
| + | |0x16 | ||
| + | |0x56 | ||
| + | |0x96 | ||
| + | |- | ||
| + | !G♯/A♭ | ||
| + | |23 | ||
| + | |0x17 | ||
| + | |0x57 | ||
| + | |0x97 | ||
| + | |- | ||
| + | !A | ||
| + | |24 | ||
| + | |0x18 | ||
| + | |0x58 | ||
| + | |0x98 | ||
| + | |- | ||
| + | !A♯/B♭ | ||
| + | |25 | ||
| + | |0x19 | ||
| + | |0x59 | ||
| + | |0x99 | ||
| + | |- | ||
| + | !B | ||
| + | |26 | ||
| + | |0x1A | ||
| + | |0x5A | ||
| + | |0x9A | ||
| + | |- | ||
| + | ! rowspan="12" |3 | ||
| + | !C | ||
| + | |27 | ||
| + | |0x1B | ||
| + | |0x5B | ||
| + | |0x9B | ||
| + | |- | ||
| + | !C♯/D♭ | ||
| + | |28 | ||
| + | |0x1C | ||
| + | |0x5C | ||
| + | |0x9C | ||
| + | |- | ||
| + | !D | ||
| + | |29 | ||
| + | |0x1D | ||
| + | |0x5D | ||
| + | |0x9D | ||
| + | |- | ||
| + | !D♯/E♭ | ||
| + | |30 | ||
| + | |0x1E | ||
| + | |0x5E | ||
| + | |0x9E | ||
| + | |- | ||
| + | !E | ||
| + | |31 | ||
| + | |0x1F | ||
| + | |0x5F | ||
| + | |0x9F | ||
| + | |- | ||
| + | !F | ||
| + | |32 | ||
| + | |0x20 | ||
| + | |0x60 | ||
| + | |0xA0 | ||
| + | |- | ||
| + | !F♯/G♭ | ||
| + | |33 | ||
| + | |0x21 | ||
| + | |0x61 | ||
| + | |0xA1 | ||
| + | |- | ||
| + | !G | ||
| + | |34 | ||
| + | |0x22 | ||
| + | |0x62 | ||
| + | |0xA2 | ||
| + | |- | ||
| + | !G♯/A♭ | ||
| + | |35 | ||
| + | |0x23 | ||
| + | |0x63 | ||
| + | |0xA3 | ||
| + | |- | ||
| + | !A | ||
| + | |36 | ||
| + | |0x24 | ||
| + | |0x64 | ||
| + | |0xA4 | ||
| + | |- | ||
| + | !A♯/B♭ | ||
| + | |37 | ||
| + | |0x25 | ||
| + | |0x65 | ||
| + | |0xA5 | ||
| + | |- | ||
| + | !B | ||
| + | |38 | ||
| + | |0x26 | ||
| + | |0x66 | ||
| + | |0xA6 | ||
| + | |- | ||
| + | ! rowspan="12" |4 | ||
| + | !C | ||
| + | |39 | ||
| + | |0x27 | ||
| + | |0x67 | ||
| + | |0xA7 | ||
| + | |- | ||
| + | !C♯/D♭ | ||
| + | |40 | ||
| + | |0x28 | ||
| + | |0x68 | ||
| + | |0xA8 | ||
| + | |- | ||
| + | !D | ||
| + | |41 | ||
| + | |0x29 | ||
| + | |0x69 | ||
| + | |0xA9 | ||
| + | |- | ||
| + | !D♯/E♭ | ||
| + | |42 | ||
| + | |0x2A | ||
| + | |0x6A | ||
| + | |0xAA | ||
| + | |- | ||
| + | !E | ||
| + | |43 | ||
| + | |0x2B | ||
| + | |0x6B | ||
| + | |0xAB | ||
| + | |- | ||
| + | !F | ||
| + | |44 | ||
| + | |0x2C | ||
| + | |0x6C | ||
| + | |0xAC | ||
| + | |- | ||
| + | !F♯/G♭ | ||
| + | |45 | ||
| + | |0x2D | ||
| + | |0x6D | ||
| + | |0xAD | ||
| + | |- | ||
| + | !G | ||
| + | |46 | ||
| + | |0x2E | ||
| + | |0x6E | ||
| + | |0xAE | ||
| + | |- | ||
| + | !G♯/A♭ | ||
| + | |47 | ||
| + | |0x2F | ||
| + | |0x6F | ||
| + | |0xAF | ||
| + | |- | ||
| + | !A | ||
| + | |48 | ||
| + | |0x30 | ||
| + | |0x70 | ||
| + | |0xB0 | ||
| + | |- | ||
| + | !A♯/B♭ | ||
| + | |49 | ||
| + | |0x31 | ||
| + | |0x71 | ||
| + | |0xB1 | ||
| + | |- | ||
| + | !B | ||
| + | |50 | ||
| + | |0x32 | ||
| + | |0x72 | ||
| + | |0xB2 | ||
| + | |- | ||
| + | ! rowspan="12" |5 | ||
| + | !C | ||
| + | |51 | ||
| + | |0x33 | ||
| + | |0x73 | ||
| + | |0xB3 | ||
| + | |- | ||
| + | !C♯/D♭ | ||
| + | |52 | ||
| + | |0x34 | ||
| + | |0x74 | ||
| + | |0xB4 | ||
| + | |- | ||
| + | !D | ||
| + | |53 | ||
| + | |0x35 | ||
| + | |0x75 | ||
| + | |0xB5 | ||
| + | |- | ||
| + | !D♯/E♭ | ||
| + | |54 | ||
| + | |0x36 | ||
| + | |0x76 | ||
| + | |0xB6 | ||
| + | |- | ||
| + | !E | ||
| + | |55 | ||
| + | |0x37 | ||
| + | |0x77 | ||
| + | |0xB7 | ||
| + | |- | ||
| + | !F | ||
| + | |56 | ||
| + | |0x38 | ||
| + | |0x78 | ||
| + | |0xB8 | ||
| + | |- | ||
| + | !F♯/G♭ | ||
| + | |57 | ||
| + | |0x39 | ||
| + | |0x79 | ||
| + | |0xB9 | ||
| + | |- | ||
| + | !G | ||
| + | |58 | ||
| + | |0x3A | ||
| + | |0x7A | ||
| + | |0xBA | ||
| + | |- | ||
| + | !G♯/A♭ | ||
| + | |59 | ||
| + | |0x3B | ||
| + | |0x7B | ||
| + | |0xBB | ||
| + | |- | ||
| + | !A | ||
| + | |60 | ||
| + | |0x3C | ||
| + | |0x7C | ||
| + | |0xBC | ||
| + | |- | ||
| + | !A♯/B♭ | ||
| + | |61 | ||
| + | |0x3D | ||
| + | |0x7D | ||
| + | |0xBD | ||
| + | |- | ||
| + | !B | ||
| + | |62 | ||
| + | |0x3E | ||
| + | |0x7E | ||
| + | |0xBE | ||
| + | |- | ||
| + | !6 | ||
| + | !C | ||
| + | |63 | ||
| + | |0x3F | ||
| + | |0x7F | ||
| + | |0xBF | ||
| + | |} | ||
| + | |||
| + | == Note durations == | ||
| + | The effective duration of a note and the delay commands is based on the currently set sequence tempo. The duration of a single tick in seconds can be calculated using the following formula: <code>time = 1.25 / tempo</code>. | ||
| + | {| class="wikitable" | ||
| + | !Note | ||
| + | !Ticks | ||
| + | !Duration (120 BPM) | ||
| + | |- | ||
| + | |whole | ||
| + | |192 | ||
| + | |2s | ||
| + | |- | ||
| + | |half dotted (2nd + 4th) | ||
| + | |144 | ||
| + | |1.5s | ||
| + | |- | ||
| + | |half | ||
| + | |96 | ||
| + | |1s | ||
| + | |- | ||
| + | |quarter dottet (4th + 8th) | ||
| + | |72 | ||
| + | |0.75s | ||
| + | |- | ||
| + | |quarter (4th) | ||
| + | |48 | ||
| + | |0.5s | ||
| + | |- | ||
| + | |eighth dottet (8th + 16th) | ||
| + | |36 | ||
| + | |0.375s | ||
| + | |- | ||
| + | |quarter tuplet | ||
| + | |32 | ||
| + | |0.333s | ||
| + | |- | ||
| + | |eighth (8th) | ||
| + | |24 | ||
| + | |0.25s | ||
| + | |- | ||
| + | |sixteenth dottet (16th + 32th) | ||
| + | |18 | ||
| + | |0.1875s | ||
| + | |- | ||
| + | |eigthth tuplet | ||
| + | |16 | ||
| + | |0.1666s | ||
| + | |- | ||
| + | |sixteenth (16th) | ||
| + | |12 | ||
| + | |0.125s | ||
| + | |- | ||
| + | |32th dottet (32th + 64th) | ||
| + | |9 | ||
| + | |0.09375s | ||
| + | |- | ||
| + | |sixteenth tuplet (16th) | ||
| + | |8 | ||
| + | |0.08333s | ||
| + | |- | ||
| + | |32th | ||
| + | |6 | ||
| + | |0.0625s | ||
| + | |- | ||
| + | |32th tuplet | ||
| + | |4 | ||
| + | |0.041666s | ||
| + | |- | ||
| + | |64th | ||
| + | |3 | ||
| + | |0.03125s | ||
| + | |- | ||
| + | |64th tuplet | ||
| + | |2 | ||
| + | |0.0208333s | ||
| + | |} | ||
== Create sequences == | == Create sequences == | ||
| Line 12: | Line 507: | ||
=== Manually === | === Manually === | ||
| − | Sequence files can also be created manually in a textual format. Create a new assembly file in the sequences directory, for example '''sound/sequences/us/23_custom_sequence.s'''. This file should | + | Sequence files can also be created manually in a textual format. Create a new assembly file in the sequences directory, for example '''sound/sequences/us/23_custom_sequence.s'''. This file should have the following anatomy:<syntaxhighlight lang="asm" line="1"> |
| − | + | #include "seq_macros.inc" | |
.section .rodata | .section .rodata | ||
.align 0 | .align 0 | ||
| + | |||
| + | ################################################################################ | ||
| + | # This label is required at the beginning of the sequence. | ||
| + | sequence_start: | ||
| + | |||
| + | # Sequence commands like seq_settempo, seq_initchannels, seq_startchannel here | ||
| + | seq_startchannel 0, channel0 | ||
| + | |||
| + | # If your sequence loops, put this here | ||
| + | seq_jump sequence_start | ||
| + | |||
| + | # End of sequence script | ||
| + | seq_end | ||
| + | |||
| + | ################################################################################ | ||
| + | # Any label you want, so you can refer to this section when starting a channel. | ||
| + | channel0: | ||
| + | |||
| + | # Channel commands like chan_setvol, chan_setinstr, chan_setlayer here | ||
| + | chan_largenoteson | ||
| + | chan_setlayer 0, layer_melody | ||
| + | |||
| + | # End of channel script | ||
| + | chan_end | ||
| + | |||
| + | ################################################################################ | ||
| + | layer_melody: | ||
| + | |||
| + | # Layer commands here like layer_note0, layer_note1 etc. | ||
| + | |||
| + | # End of layer script | ||
| + | layer_end | ||
</syntaxhighlight>Next you can write down a series of commands. See '''include/seq_macros.inc''' or https://hackmd.io/opEB-OmxRa26P8h8pA-x7w for a list of available commands. | </syntaxhighlight>Next you can write down a series of commands. See '''include/seq_macros.inc''' or https://hackmd.io/opEB-OmxRa26P8h8pA-x7w for a list of available commands. | ||
| + | |||
| + | === Example melody "Transposition" === | ||
| + | The following example script plays a melody of 69 notes and repeats it over at varying transposition (hence the name).<syntaxhighlight lang="asm" line="1"> | ||
| + | #include "seq_macros.inc" | ||
| + | .section .rodata | ||
| + | .align 0 | ||
| + | |||
| + | .eqv EIGHTH, 24 | ||
| + | .eqv SEQ_LEN, EIGHTH * (9 + 11 + 10 + 12 + 12 + 7 + 8) | ||
| + | |||
| + | # This label is required at the beginning of the sequence. | ||
| + | sequence_start: | ||
| + | |||
| + | seq_setmutebhv 0x20 | ||
| + | seq_settempo 125 | ||
| + | seq_setvol 127 | ||
| + | |||
| + | seq_initchannels 0x01 | ||
| + | seq_startchannel 0, channel0 | ||
| + | |||
| + | # Note: the maximum delay is 32767 (0x7fff) ticks, so we just do multiple delays. | ||
| + | seq_delay SEQ_LEN * 5 | ||
| + | seq_delay SEQ_LEN * 5 | ||
| + | seq_delay SEQ_LEN * 5 | ||
| + | seq_delay SEQ_LEN * 5 | ||
| + | seq_delay SEQ_LEN * 5 | ||
| + | seq_jump sequence_start | ||
| + | |||
| + | seq_end | ||
| + | |||
| + | channel0: | ||
| + | chan_largenoteson | ||
| + | chan_setvol 127 | ||
| + | chan_setinstr 4 | ||
| + | chan_setreverb 127 | ||
| + | |||
| + | chan_setlayer 0, layer_melody | ||
| + | chan_delay SEQ_LEN | ||
| + | |||
| + | chan_transpose -11 | ||
| + | chan_setlayer 0, layer_melody | ||
| + | chan_delay SEQ_LEN | ||
| + | |||
| + | chan_transpose -8 | ||
| + | chan_setlayer 0, layer_melody | ||
| + | chan_delay SEQ_LEN | ||
| + | |||
| + | chan_transpose -2 | ||
| + | chan_setlayer 0, layer_melody | ||
| + | chan_delay SEQ_LEN | ||
| + | |||
| + | chan_transpose -6 | ||
| + | chan_setlayer 0, layer_melody | ||
| + | chan_delay SEQ_LEN | ||
| + | |||
| + | chan_transpose 9 | ||
| + | chan_setlayer 0, layer_melody | ||
| + | chan_delay SEQ_LEN | ||
| + | |||
| + | chan_transpose 1 | ||
| + | chan_setlayer 0, layer_melody | ||
| + | chan_delay SEQ_LEN | ||
| + | |||
| + | chan_transpose -7 | ||
| + | chan_setlayer 0, layer_melody | ||
| + | chan_delay SEQ_LEN | ||
| + | |||
| + | chan_transpose 10 | ||
| + | chan_setlayer 0, layer_melody | ||
| + | chan_delay SEQ_LEN | ||
| + | |||
| + | chan_transpose 12 | ||
| + | chan_setlayer 0, layer_melody | ||
| + | chan_delay SEQ_LEN | ||
| + | |||
| + | chan_transpose 2 | ||
| + | chan_setlayer 0, layer_melody | ||
| + | chan_delay SEQ_LEN | ||
| + | |||
| + | chan_transpose 4 | ||
| + | chan_setlayer 0, layer_melody | ||
| + | chan_delay SEQ_LEN | ||
| + | |||
| + | chan_transpose 5 | ||
| + | chan_setlayer 0, layer_melody | ||
| + | chan_delay SEQ_LEN | ||
| + | |||
| + | chan_transpose 3 | ||
| + | chan_setlayer 0, layer_melody | ||
| + | chan_delay SEQ_LEN | ||
| + | |||
| + | chan_transpose -5 | ||
| + | chan_setlayer 0, layer_melody | ||
| + | chan_delay SEQ_LEN | ||
| + | |||
| + | chan_transpose -12 | ||
| + | chan_setlayer 0, layer_melody | ||
| + | chan_delay SEQ_LEN | ||
| + | |||
| + | chan_transpose -9 | ||
| + | chan_setlayer 0, layer_melody | ||
| + | chan_delay SEQ_LEN | ||
| + | |||
| + | chan_transpose 7 | ||
| + | chan_setlayer 0, layer_melody | ||
| + | chan_delay SEQ_LEN | ||
| + | |||
| + | chan_transpose 6 | ||
| + | chan_setlayer 0, layer_melody | ||
| + | chan_delay SEQ_LEN | ||
| + | |||
| + | chan_transpose -10 | ||
| + | chan_setlayer 0, layer_melody | ||
| + | chan_delay SEQ_LEN | ||
| + | |||
| + | chan_transpose 11 | ||
| + | chan_setlayer 0, layer_melody | ||
| + | chan_delay SEQ_LEN | ||
| + | |||
| + | chan_transpose -4 | ||
| + | chan_setlayer 0, layer_melody | ||
| + | chan_delay SEQ_LEN | ||
| + | |||
| + | chan_transpose -1 | ||
| + | chan_setlayer 0, layer_melody | ||
| + | chan_delay SEQ_LEN | ||
| + | |||
| + | chan_transpose 8 | ||
| + | chan_setlayer 0, layer_melody | ||
| + | chan_delay SEQ_LEN | ||
| + | |||
| + | chan_transpose -3 | ||
| + | chan_setlayer 0, layer_melody | ||
| + | chan_delay SEQ_LEN | ||
| + | |||
| + | chan_end | ||
| + | |||
| + | layer_melody: | ||
| + | layer_note1 40, EIGHTH, 100 # c#4 | ||
| + | layer_note1 42, EIGHTH, 100 # d#4 | ||
| + | layer_note1 43, EIGHTH, 100 # e-4 | ||
| + | layer_note1 35, EIGHTH, 100 # ab3 | ||
| + | layer_note1 42, EIGHTH, 100 # d#4 | ||
| + | layer_note1 33, EIGHTH, 100 # gb3 | ||
| + | layer_note1 31, EIGHTH, 100 # e-3 | ||
| + | layer_note1 30, EIGHTH, 100 # d#3 | ||
| + | layer_note1 28, EIGHTH, 100 # c#3 | ||
| + | |||
| + | layer_note1 35, EIGHTH, 100 # ab3 | ||
| + | layer_note1 40, EIGHTH, 100 # c#4 | ||
| + | layer_note1 43, EIGHTH, 100 # e-4 | ||
| + | layer_note1 42, EIGHTH, 100 # d#4 | ||
| + | layer_note1 43, EIGHTH, 100 # e-4 | ||
| + | layer_note1 45, EIGHTH, 100 # gb4 | ||
| + | layer_note1 35, EIGHTH, 100 # ab3 | ||
| + | layer_note1 38, EIGHTH, 100 # b-3 | ||
| + | layer_note1 43, EIGHTH, 100 # e-4 | ||
| + | layer_note1 42, EIGHTH, 100 # d#4 | ||
| + | layer_note1 40, EIGHTH, 100 # c#4 | ||
| + | |||
| + | layer_note1 35, EIGHTH, 100 # ab3 | ||
| + | layer_note1 40, EIGHTH, 100 # c#4 | ||
| + | layer_note1 44, EIGHTH, 100 # f-4 | ||
| + | layer_note1 40, EIGHTH, 100 # c#4 | ||
| + | layer_note1 45, EIGHTH, 100 # gb4 | ||
| + | layer_note1 40, EIGHTH, 100 # c#4 | ||
| + | layer_note1 47, EIGHTH, 100 # ab4 | ||
| + | layer_note1 40, EIGHTH, 100 # c#4 | ||
| + | layer_note1 48, EIGHTH, 100 # a-4 | ||
| + | layer_note1 40, EIGHTH, 100 # c#4 | ||
| + | |||
| + | layer_note1 42, EIGHTH, 100 # d#4 | ||
| + | layer_note1 38, EIGHTH, 100 # b-3 | ||
| + | layer_note1 33, EIGHTH, 100 # gb3 | ||
| + | layer_note1 38, EIGHTH, 100 # b-3 | ||
| + | layer_note1 42, EIGHTH, 100 # d#4 | ||
| + | layer_note1 38, EIGHTH, 100 # b-3 | ||
| + | layer_note1 43, EIGHTH, 100 # e-4 | ||
| + | layer_note1 38, EIGHTH, 100 # b-3 | ||
| + | layer_note1 45, EIGHTH, 100 # gb4 | ||
| + | layer_note1 38, EIGHTH, 100 # b-3 | ||
| + | layer_note1 47, EIGHTH, 100 # ab4 | ||
| + | layer_note1 38, EIGHTH, 100 # b-3 | ||
| + | |||
| + | layer_note1 40, EIGHTH, 100 # c#4 | ||
| + | layer_note1 36, EIGHTH, 100 # a-3 | ||
| + | layer_note1 35, EIGHTH, 100 # ab3 | ||
| + | layer_note1 36, EIGHTH, 100 # a-3 | ||
| + | layer_note1 40, EIGHTH, 100 # c#4 | ||
| + | layer_note1 43, EIGHTH, 100 # e-4 | ||
| + | layer_note1 38, EIGHTH, 100 # b-3 | ||
| + | layer_note1 35, EIGHTH, 100 # ab3 | ||
| + | layer_note1 33, EIGHTH, 100 # gb3 | ||
| + | layer_note1 35, EIGHTH, 100 # ab3 | ||
| + | layer_note1 38, EIGHTH, 100 # b-3 | ||
| + | layer_note1 43, EIGHTH, 100 # e-4 | ||
| + | |||
| + | layer_note1 33, EIGHTH, 100 # gb3 | ||
| + | layer_note1 35, EIGHTH, 100 # ab3 | ||
| + | layer_note1 36, EIGHTH, 100 # a-3 | ||
| + | layer_note1 31, EIGHTH, 100 # e-3 | ||
| + | layer_note1 30, EIGHTH, 100 # d#3 | ||
| + | layer_note1 31, EIGHTH, 100 # e-3 | ||
| + | layer_note1 33, EIGHTH, 100 # gb3 | ||
| + | |||
| + | layer_note1 30, EIGHTH, 100 # d#3 | ||
| + | layer_note1 26, EIGHTH, 100 # b-2 | ||
| + | layer_note1 24, EIGHTH, 100 # a-2 | ||
| + | layer_note1 23, EIGHTH, 100 # ab2 | ||
| + | layer_note1 31, EIGHTH, 100 # e-3 | ||
| + | layer_note1 24, EIGHTH, 100 # a-2 | ||
| + | layer_note1 31, EIGHTH, 100 # e-3 | ||
| + | layer_note1 23, EIGHTH, 100 # ab2 | ||
| + | |||
| + | layer_end | ||
| + | </syntaxhighlight> | ||
== Commands == | == Commands == | ||
| Line 27: | Line 770: | ||
!Bytecode (US) | !Bytecode (US) | ||
!Description | !Description | ||
| − | |||
|- | |- | ||
!seq_end | !seq_end | ||
| Line 34: | Line 776: | ||
|0xff | |0xff | ||
|End of script, loop or function | |End of script, loop or function | ||
| − | |||
|- | |- | ||
!seq_delay1 | !seq_delay1 | ||
| Line 41: | Line 782: | ||
|0xfe | |0xfe | ||
|Delay for 1 tick | |Delay for 1 tick | ||
| − | |||
|- | |- | ||
!seq_delay | !seq_delay | ||
| Line 48: | Line 788: | ||
|0xfd, var | |0xfd, var | ||
|Delay for X ticks | |Delay for X ticks | ||
| − | |||
|- | |- | ||
!seq_call | !seq_call | ||
| Line 55: | Line 794: | ||
|0xfc, addr | |0xfc, addr | ||
|Call a function | |Call a function | ||
| − | |||
|- | |- | ||
!seq_jump | !seq_jump | ||
| Line 62: | Line 800: | ||
|0xfb, addr | |0xfb, addr | ||
|Jump to a point in the sequence script | |Jump to a point in the sequence script | ||
| − | |||
|- | |- | ||
!seq_beqz | !seq_beqz | ||
| Line 69: | Line 806: | ||
|0xfa, addr | |0xfa, addr | ||
|Jump if Q == 0, where Q is an s8 used to hold temporary sequence script state | |Jump if Q == 0, where Q is an s8 used to hold temporary sequence script state | ||
| − | |||
|- | |- | ||
!seq_bltz | !seq_bltz | ||
| Line 76: | Line 812: | ||
|0xf9, addr | |0xf9, addr | ||
|Jump if Q < 0 | |Jump if Q < 0 | ||
| − | |||
|- | |- | ||
!seq_loop | !seq_loop | ||
| Line 83: | Line 818: | ||
|0xf8, u8 | |0xf8, u8 | ||
|Repeat until <code>loopend</code> for X iterations (256 if X = 0) | |Repeat until <code>loopend</code> for X iterations (256 if X = 0) | ||
| − | |||
|- | |- | ||
!seq_loopend | !seq_loopend | ||
| Line 90: | Line 824: | ||
|0xf7 | |0xf7 | ||
|Loop end marker | |Loop end marker | ||
| − | |||
|- | |- | ||
!seq_bgez | !seq_bgez | ||
| Line 97: | Line 830: | ||
|0xf5, addr | |0xf5, addr | ||
|Jump if Q >= 0 | |Jump if Q >= 0 | ||
| − | |||
|- | |- | ||
!seq_reservenotes | !seq_reservenotes | ||
| Line 104: | Line 836: | ||
|0xf2, u8 | |0xf2, u8 | ||
|Reserve X notes for exclusive use by this sequence (dropping earlier reservations). A limited number of notes can be played at once (configurable per level, usually 16); if more than that are played, an existing one will be stopped and reused. This command can prevent that from happening across sequences. | |Reserve X notes for exclusive use by this sequence (dropping earlier reservations). A limited number of notes can be played at once (configurable per level, usually 16); if more than that are played, an existing one will be stopped and reused. This command can prevent that from happening across sequences. | ||
| − | |||
|- | |- | ||
!seq_unreservenotes | !seq_unreservenotes | ||
| Line 111: | Line 842: | ||
|0xf1 | |0xf1 | ||
|Drop all earlier reservations made by this sequence. | |Drop all earlier reservations made by this sequence. | ||
| − | |||
|- | |- | ||
!seq_transpose | !seq_transpose | ||
| Line 118: | Line 848: | ||
|0xdf, s8 | |0xdf, s8 | ||
|Set transposition in semitones. | |Set transposition in semitones. | ||
| − | |||
|- | |- | ||
!seq_transposerel | !seq_transposerel | ||
| Line 125: | Line 854: | ||
|0xde, s8 | |0xde, s8 | ||
|Change transposition by some delta. | |Change transposition by some delta. | ||
| − | |||
|- | |- | ||
!seq_settempo | !seq_settempo | ||
| Line 132: | Line 860: | ||
|0xdd, u8 | |0xdd, u8 | ||
|Set tempo in BPM. | |Set tempo in BPM. | ||
| − | |||
|- | |- | ||
!seq_addtempo | !seq_addtempo | ||
| Line 139: | Line 866: | ||
|0xdc, s8 | |0xdc, s8 | ||
|Change tempo by some delta. | |Change tempo by some delta. | ||
| − | |||
|- | |- | ||
!seq_setvol | !seq_setvol | ||
| Line 146: | Line 872: | ||
|0xdb, u8 | |0xdb, u8 | ||
|Set volume scale (0…255 = none to twice normal). | |Set volume scale (0…255 = none to twice normal). | ||
| − | |||
|- | |- | ||
!seq_changevol | !seq_changevol | ||
| Line 153: | Line 878: | ||
|0xda, s8 | |0xda, s8 | ||
|Change volume scale by some delta. | |Change volume scale by some delta. | ||
| − | |||
|- | |- | ||
!seq_initchannels | !seq_initchannels | ||
| Line 160: | Line 884: | ||
|0xd7, u16 | |0xd7, u16 | ||
|Initialize channels (bitmask). This copies mute behavior and note allocation policy. | |Initialize channels (bitmask). This copies mute behavior and note allocation policy. | ||
| − | |||
|- | |- | ||
!seq_disablechannels | !seq_disablechannels | ||
| Line 167: | Line 890: | ||
|0xd6, u16 | |0xd6, u16 | ||
|Uninitialize channels (bitmask). | |Uninitialize channels (bitmask). | ||
| − | |||
|- | |- | ||
!seq_setmutescale | !seq_setmutescale | ||
| Line 174: | Line 896: | ||
|0xd5, s8 | |0xd5, s8 | ||
|Set volume multiplier for muted mode (0…127). | |Set volume multiplier for muted mode (0…127). | ||
| − | |||
|- | |- | ||
!seq_mute | !seq_mute | ||
| Line 181: | Line 902: | ||
|0xd4 | |0xd4 | ||
|Set sequence to muted mode. Depending on what behavior has been set this will do different things; from lowering volume to not running scripts. | |Set sequence to muted mode. Depending on what behavior has been set this will do different things; from lowering volume to not running scripts. | ||
| − | |||
|- | |- | ||
!seq_setmutebhv | !seq_setmutebhv | ||
| Line 188: | Line 908: | ||
|0xd3, u8 | |0xd3, u8 | ||
|Set mute behavior (bitmask). Bit 0x20 lowers volume, bit 0x40 does something to layers, and bit 0x80 pauses the sequence script. Default mute behavior is to have all of those bits set. | |Set mute behavior (bitmask). Bit 0x20 lowers volume, bit 0x40 does something to layers, and bit 0x80 pauses the sequence script. Default mute behavior is to have all of those bits set. | ||
| − | |||
|- | |- | ||
!seq_setshortnotevelocitytable | !seq_setshortnotevelocitytable | ||
| Line 195: | Line 914: | ||
|0xd2, addr | |0xd2, addr | ||
|Set velocity table for short notes (see further down). Target should be an array of bytes in the sequence data of length 16. | |Set velocity table for short notes (see further down). Target should be an array of bytes in the sequence data of length 16. | ||
| − | |||
|- | |- | ||
!seq_setshortnotedurationtable | !seq_setshortnotedurationtable | ||
| Line 202: | Line 920: | ||
|0xd1, addr | |0xd1, addr | ||
|Set duration table for short notes (see further down). Target should be an array of bytes in the sequence data of length 16. | |Set duration table for short notes (see further down). Target should be an array of bytes in the sequence data of length 16. | ||
| − | |||
|- | |- | ||
!seq_setnoteallocationpolicy | !seq_setnoteallocationpolicy | ||
| Line 209: | Line 926: | ||
|0xd0, u8 | |0xd0, u8 | ||
|Set note allocation policy (bitmask). If bit 0x1 is set, it will try to steal notes back from what was previously played on the same layer. If bit 0x2 is set, notes will be allocated exclusively from the channel’s reserved notes, else if 0x4 is set, from the channel’s or sequence’s reserved notes, else if 0x8 is set, from unreserved notes, otherwise from all sources. Not used by the game. | |Set note allocation policy (bitmask). If bit 0x1 is set, it will try to steal notes back from what was previously played on the same layer. If bit 0x2 is set, notes will be allocated exclusively from the channel’s reserved notes, else if 0x4 is set, from the channel’s or sequence’s reserved notes, else if 0x8 is set, from unreserved notes, otherwise from all sources. Not used by the game. | ||
| − | |||
|- | |- | ||
!seq_setval | !seq_setval | ||
| Line 216: | Line 932: | ||
|0xcc, u8 | |0xcc, u8 | ||
|Set Q to a constant. | |Set Q to a constant. | ||
| − | |||
|- | |- | ||
!seq_bitand | !seq_bitand | ||
| Line 223: | Line 938: | ||
|0xc9, u8 | |0xc9, u8 | ||
|Bitand Q by a constant. | |Bitand Q by a constant. | ||
| − | |||
|- | |- | ||
!seq_subtract | !seq_subtract | ||
| Line 230: | Line 944: | ||
|0xc8, u8 | |0xc8, u8 | ||
|Subtract a constant from Q. | |Subtract a constant from Q. | ||
| − | |||
|- | |- | ||
!seq_startchannel | !seq_startchannel | ||
| Line 237: | Line 950: | ||
|0x90-0x9f, addr | |0x90-0x9f, addr | ||
|Start channel N, with a given channel script. | |Start channel N, with a given channel script. | ||
| − | |||
|- | |- | ||
!seq_getvariation | !seq_getvariation | ||
| Line 244: | Line 956: | ||
|0x80-0x8f | |0x80-0x8f | ||
|Set Q to the variation bit, which is initially either 0 or 0x80 (i.e. -128, since Q is s8). This bit comes from the sequence load command. For instance, to play the Koopa shell music, the game plays sequence 0x8E, which is the same as sequence 0xE but with the variation bit set. | |Set Q to the variation bit, which is initially either 0 or 0x80 (i.e. -128, since Q is s8). This bit comes from the sequence load command. For instance, to play the Koopa shell music, the game plays sequence 0x8E, which is the same as sequence 0xE but with the variation bit set. | ||
| − | |||
|- | |- | ||
!seq_setvariation | !seq_setvariation | ||
| Line 251: | Line 962: | ||
|0x70-0x7f | |0x70-0x7f | ||
|Set the variation bit to Q. | |Set the variation bit to Q. | ||
| − | |||
|- | |- | ||
!seq_subvariation | !seq_subvariation | ||
| Line 258: | Line 968: | ||
|0x50-0x5f | |0x50-0x5f | ||
|Subtract the variation bit from Q. | |Subtract the variation bit from Q. | ||
| − | |||
|- | |- | ||
!seq_testchdisabled | !seq_testchdisabled | ||
| Line 265: | Line 974: | ||
|0x00-0x0f | |0x00-0x0f | ||
|Set Q to 1 or 0, depending on whether channel N has been disabled by channel script. | |Set Q to 1 or 0, depending on whether channel N has been disabled by channel script. | ||
| − | |||
|} | |} | ||
=== Channel commands === | === Channel commands === | ||
{| class="wikitable" | {| class="wikitable" | ||
| − | |||
!Mnemonic | !Mnemonic | ||
!Param 1 | !Param 1 | ||
| Line 277: | Line 984: | ||
!Bytecode (US) | !Bytecode (US) | ||
!Description | !Description | ||
| − | |||
|- | |- | ||
!chan_end | !chan_end | ||
| Line 285: | Line 991: | ||
|0xff | |0xff | ||
|End of script, loop or function | |End of script, loop or function | ||
| − | |||
|- | |- | ||
!chan_delay1 | !chan_delay1 | ||
| Line 293: | Line 998: | ||
|0xfe | |0xfe | ||
|Delay for 1 tick | |Delay for 1 tick | ||
| − | |||
|- | |- | ||
!chan_delay | !chan_delay | ||
| Line 301: | Line 1,005: | ||
|0xfd, var | |0xfd, var | ||
|Delay for X ticks | |Delay for X ticks | ||
| − | |||
|- | |- | ||
!chan_call | !chan_call | ||
| Line 309: | Line 1,012: | ||
|0xfc, addr | |0xfc, addr | ||
|Call a function | |Call a function | ||
| − | |||
|- | |- | ||
!chan_jump | !chan_jump | ||
| Line 317: | Line 1,019: | ||
|0xfb, addr | |0xfb, addr | ||
|Jump to a point in the channel script | |Jump to a point in the channel script | ||
| − | |||
|- | |- | ||
!chan_beqz | !chan_beqz | ||
| Line 325: | Line 1,026: | ||
|0xfa, addr | |0xfa, addr | ||
|Jump if Q == 0, where Q is an s8 used to hold temporary channel script state | |Jump if Q == 0, where Q is an s8 used to hold temporary channel script state | ||
| − | |||
|- | |- | ||
!chan_bltz | !chan_bltz | ||
| Line 333: | Line 1,033: | ||
|0xf9, addr | |0xf9, addr | ||
|Jump if Q < 0 | |Jump if Q < 0 | ||
| − | |||
|- | |- | ||
!chan_loop | !chan_loop | ||
| Line 341: | Line 1,040: | ||
|0xf8, u8 | |0xf8, u8 | ||
|Repeat until <code>loopend</code> for X iterations (256 if X = 0) | |Repeat until <code>loopend</code> for X iterations (256 if X = 0) | ||
| − | |||
|- | |- | ||
!chan_loopend | !chan_loopend | ||
| Line 349: | Line 1,047: | ||
|0xf7 | |0xf7 | ||
|Loop end marker | |Loop end marker | ||
| − | |||
|- | |- | ||
!chan_break | !chan_break | ||
| Line 357: | Line 1,054: | ||
|0xf6 | |0xf6 | ||
|Decrease loop/function stack depth by 1. Combine with a jump to break out of a loop. | |Decrease loop/function stack depth by 1. Combine with a jump to break out of a loop. | ||
| − | |||
|- | |- | ||
!chan_bgez | !chan_bgez | ||
| Line 365: | Line 1,061: | ||
|0xf5, addr | |0xf5, addr | ||
|Jump if Q >= 0 | |Jump if Q >= 0 | ||
| − | |||
|- | |- | ||
!chan_hang | !chan_hang | ||
| Line 373: | Line 1,068: | ||
|0xf3 | |0xf3 | ||
|Infinite delay. | |Infinite delay. | ||
| − | |||
|- | |- | ||
!chan_reservenotes | !chan_reservenotes | ||
| Line 381: | Line 1,075: | ||
|0xf2, u8 | |0xf2, u8 | ||
|Reserve X notes for exclusive use by this channel (dropping earlier reservations). | |Reserve X notes for exclusive use by this channel (dropping earlier reservations). | ||
| − | |||
|- | |- | ||
!chan_unreservenotes | !chan_unreservenotes | ||
| Line 389: | Line 1,082: | ||
|0xf1 | |0xf1 | ||
|Drop all earlier reservations made by this channel. | |Drop all earlier reservations made by this channel. | ||
| − | |||
|- | |- | ||
!chan_dyncall | !chan_dyncall | ||
| Line 397: | Line 1,089: | ||
|0xe4 | |0xe4 | ||
|If Q != -1, make a function call to position dyntable[Q], where dyntable is a channel-specific u16 array which can set by <code>setdyntable</code>/<code>dynsetdyntable</code>. | |If Q != -1, make a function call to position dyntable[Q], where dyntable is a channel-specific u16 array which can set by <code>setdyntable</code>/<code>dynsetdyntable</code>. | ||
| − | |||
|- | |- | ||
!chan_setvibratodelay | !chan_setvibratodelay | ||
| Line 405: | Line 1,096: | ||
|0xe3, u8 | |0xe3, u8 | ||
|Set delay until vibrato starts for each note. | |Set delay until vibrato starts for each note. | ||
| − | |||
|- | |- | ||
!chan_setvibratoextentlinear | !chan_setvibratoextentlinear | ||
| Line 413: | Line 1,103: | ||
|0xe2, u8, u8, u8 | |0xe2, u8, u8, u8 | ||
|Set vibrato extent for each note as a function that starts at X, goes up linearly to Y over a time span given by Z, then stays there. | |Set vibrato extent for each note as a function that starts at X, goes up linearly to Y over a time span given by Z, then stays there. | ||
| − | |||
|- | |- | ||
!chan_setvibratoratelinear | !chan_setvibratoratelinear | ||
| Line 421: | Line 1,110: | ||
|0xe1, u8, u8, u8 | |0xe1, u8, u8, u8 | ||
|Like above except for vibrato rate. | |Like above except for vibrato rate. | ||
| − | |||
|- | |- | ||
!chan_setvolscale | !chan_setvolscale | ||
| Line 429: | Line 1,117: | ||
|0xe0, u8 | |0xe0, u8 | ||
|Set scale factor for volume (0…255 = none to twice normal). | |Set scale factor for volume (0…255 = none to twice normal). | ||
| − | |||
|- | |- | ||
!chan_setvol | !chan_setvol | ||
| Line 437: | Line 1,124: | ||
|0xdf, u8 | |0xdf, u8 | ||
|Set scale factor #2 for volume (0…255 = none to twice normal). The two scale factors are separately controlled by outer audio logic, e.g. when changing between rooms, when playing sound effects, etc. The game almost exclusively uses setvol, so that should probably be preferred, but setvolscale shows up in a few locations in the sound effect sequence. | |Set scale factor #2 for volume (0…255 = none to twice normal). The two scale factors are separately controlled by outer audio logic, e.g. when changing between rooms, when playing sound effects, etc. The game almost exclusively uses setvol, so that should probably be preferred, but setvolscale shows up in a few locations in the sound effect sequence. | ||
| − | |||
|- | |- | ||
!chan_freqscale | !chan_freqscale | ||
| Line 445: | Line 1,131: | ||
|0xde, u16 | |0xde, u16 | ||
|Pitch bend using a raw frequency multiplier X/2^15. | |Pitch bend using a raw frequency multiplier X/2^15. | ||
| − | |||
|- | |- | ||
!chan_setpan | !chan_setpan | ||
| Line 453: | Line 1,138: | ||
|0xdd, u8 | |0xdd, u8 | ||
|Set the pan for this channel (0…128) | |Set the pan for this channel (0…128) | ||
| − | |||
|- | |- | ||
!chan_setpanchanweight | !chan_setpanchanweight | ||
| Line 461: | Line 1,145: | ||
|0xdc, u8 | |0xdc, u8 | ||
|The pan for each note will be computed as W * channel pan + (1 - W) * note pan. This sets W (0…128 maps to 0…1). W defaults to 1.0. | |The pan for each note will be computed as W * channel pan + (1 - W) * note pan. This sets W (0…128 maps to 0…1). W defaults to 1.0. | ||
| − | |||
|- | |- | ||
!chan_transpose | !chan_transpose | ||
| Line 469: | Line 1,152: | ||
|0xdb, s8 | |0xdb, s8 | ||
|Set transposition in semitones. | |Set transposition in semitones. | ||
| − | |||
|- | |- | ||
!chan_setenvelope | !chan_setenvelope | ||
| Line 477: | Line 1,159: | ||
|0xda, addr | |0xda, addr | ||
|Set ADSR envelope. See below for format. | |Set ADSR envelope. See below for format. | ||
| − | |||
|- | |- | ||
!chan_setdecayrelease | !chan_setdecayrelease | ||
| Line 485: | Line 1,166: | ||
|0xd9, u8 | |0xd9, u8 | ||
|Set ADSR decay/release rate. | |Set ADSR decay/release rate. | ||
| − | |||
|- | |- | ||
!chan_setvibratoextent | !chan_setvibratoextent | ||
| Line 493: | Line 1,173: | ||
|0xd8, u8 | |0xd8, u8 | ||
|Set vibrato extent. | |Set vibrato extent. | ||
| − | |||
|- | |- | ||
!chan_setvibratorate | !chan_setvibratorate | ||
| Line 501: | Line 1,180: | ||
|0xd7, u8 | |0xd7, u8 | ||
|Set vibrato rate. | |Set vibrato rate. | ||
| − | |||
|- | |- | ||
!chan_setupdatesperframe | !chan_setupdatesperframe | ||
| Line 509: | Line 1,187: | ||
|0xd6, u8 | |0xd6, u8 | ||
|Seems like it was meant to set the number of updates per frame? But it doesn’t actually do anything. | |Seems like it was meant to set the number of updates per frame? But it doesn’t actually do anything. | ||
| − | |||
|- | |- | ||
!chan_setreverb | !chan_setreverb | ||
| Line 517: | Line 1,194: | ||
|0xd4, u8 | |0xd4, u8 | ||
|Set amount of reverb (or “dry/wet mix”?). | |Set amount of reverb (or “dry/wet mix”?). | ||
| − | |||
|- | |- | ||
!chan_pitchbend | !chan_pitchbend | ||
| Line 525: | Line 1,201: | ||
|0xd3, s8 | |0xd3, s8 | ||
|Pitch bend by <= 1 octave in either direction (-127…127). | |Pitch bend by <= 1 octave in either direction (-127…127). | ||
| − | |||
|- | |- | ||
!chan_setsustain | !chan_setsustain | ||
| Line 533: | Line 1,208: | ||
|0xd2, u8 | |0xd2, u8 | ||
|Set ADSR sustain volume. | |Set ADSR sustain volume. | ||
| − | |||
|- | |- | ||
!chan_setnoteallocationpolicy | !chan_setnoteallocationpolicy | ||
| Line 541: | Line 1,215: | ||
|0xd1, u8 | |0xd1, u8 | ||
|Set note allocation policy for channel. See the description for sequence scripts. | |Set note allocation policy for channel. See the description for sequence scripts. | ||
| − | |||
|- | |- | ||
!chan_stereoheadseteffects | !chan_stereoheadseteffects | ||
| Line 549: | Line 1,222: | ||
|0xd0, u8 | |0xd0, u8 | ||
|Enable (1) or disable (0) some pan/volume effects related to stereo/headset. I don’t know which ones precisely – pan ''is'' still taken into account even with this disabled. With this disabled, stereo/headset gets the same output. | |Enable (1) or disable (0) some pan/volume effects related to stereo/headset. I don’t know which ones precisely – pan ''is'' still taken into account even with this disabled. With this disabled, stereo/headset gets the same output. | ||
| − | |||
|- | |- | ||
!chan_setval | !chan_setval | ||
| Line 557: | Line 1,229: | ||
|0xcc, u8 | |0xcc, u8 | ||
|Set Q to a constant. | |Set Q to a constant. | ||
| − | |||
|- | |- | ||
!chan_readseq | !chan_readseq | ||
| Line 565: | Line 1,236: | ||
|0xcb, addr | |0xcb, addr | ||
|Set Q to sequenceData[X + Q]. | |Set Q to sequenceData[X + Q]. | ||
| − | |||
|- | |- | ||
!chan_setmutebhv | !chan_setmutebhv | ||
| Line 573: | Line 1,243: | ||
|0xca, u8 | |0xca, u8 | ||
|Set mute behavior for this channel. | |Set mute behavior for this channel. | ||
| − | |||
|- | |- | ||
!chan_bitand | !chan_bitand | ||
| Line 581: | Line 1,250: | ||
|0xc9, u8 | |0xc9, u8 | ||
|Bitand Q by a constant. | |Bitand Q by a constant. | ||
| − | |||
|- | |- | ||
!chan_subtract | !chan_subtract | ||
| Line 589: | Line 1,257: | ||
|0xc8, u8 | |0xc8, u8 | ||
|Subtract a constant from Q. | |Subtract a constant from Q. | ||
| − | |||
|- | |- | ||
!chan_writeseq | !chan_writeseq | ||
| Line 597: | Line 1,264: | ||
|0xc7, u8, addr | |0xc7, u8, addr | ||
|Overwrite the byte at the given position in the sequence script by (Q + X). | |Overwrite the byte at the given position in the sequence script by (Q + X). | ||
| − | |||
|- | |- | ||
!chan_setbank | !chan_setbank | ||
| Line 605: | Line 1,271: | ||
|0xc6, u8 | |0xc6, u8 | ||
|Switch bank within instrument bank sets, to the X’th bank, 0-indexed, counting from the end. | |Switch bank within instrument bank sets, to the X’th bank, 0-indexed, counting from the end. | ||
| − | |||
|- | |- | ||
!chan_dynsetdyntable | !chan_dynsetdyntable | ||
| Line 613: | Line 1,278: | ||
|0xc5 | |0xc5 | ||
|If Q != -1, set dyntable to point to position dyntable[Q] in the sequence data. | |If Q != -1, set dyntable to point to position dyntable[Q] in the sequence data. | ||
| − | |||
|- | |- | ||
!chan_largenoteson | !chan_largenoteson | ||
| Line 621: | Line 1,285: | ||
|0xc4 | |0xc4 | ||
|Set notes for this channel to use “large notes” format. SM64 does this for all channels. (See <code>note</code> vs. <code>shortnote</code> in the layer section below.) | |Set notes for this channel to use “large notes” format. SM64 does this for all channels. (See <code>note</code> vs. <code>shortnote</code> in the layer section below.) | ||
| − | |||
|- | |- | ||
!chan_largenotesoff | !chan_largenotesoff | ||
| Line 629: | Line 1,292: | ||
|0xc3 | |0xc3 | ||
|Set notes for this channel to use “short notes” format. | |Set notes for this channel to use “short notes” format. | ||
| − | |||
|- | |- | ||
!chan_setdyntable | !chan_setdyntable | ||
| Line 637: | Line 1,299: | ||
|0xc2, addr | |0xc2, addr | ||
|Set dyntable to point to a given u16 array from the sequence data. | |Set dyntable to point to a given u16 array from the sequence data. | ||
| − | |||
|- | |- | ||
!chan_setinstr | !chan_setinstr | ||
| Line 645: | Line 1,306: | ||
|0xc1, u8 | |0xc1, u8 | ||
|Set instrument (program?) within bank. 0x80-0x83 set raw waves (sawtooth, triangle, sine, square), 0x7f is special, otherwise 0-indexed. | |Set instrument (program?) within bank. 0x80-0x83 set raw waves (sawtooth, triangle, sine, square), 0x7f is special, otherwise 0-indexed. | ||
| − | |||
|- | |- | ||
!chan_dynsetlayer | !chan_dynsetlayer | ||
| Line 653: | Line 1,313: | ||
|0xb0-0xbf | |0xb0-0xbf | ||
|If Q != -1, start layer N, with layer script given by dyntable[Q]. | |If Q != -1, start layer N, with layer script given by dyntable[Q]. | ||
| − | |||
|- | |- | ||
!chan_freelayer | !chan_freelayer | ||
| Line 661: | Line 1,320: | ||
|0xa0-0xaf | |0xa0-0xaf | ||
|Stop layer N. | |Stop layer N. | ||
| − | |||
|- | |- | ||
!chan_setlayer | !chan_setlayer | ||
| Line 669: | Line 1,327: | ||
|0x90-0x9f, addr | |0x90-0x9f, addr | ||
|Start layer N, with layer script starting at address X. | |Start layer N, with layer script starting at address X. | ||
| − | |||
|- | |- | ||
!chan_ioreadval | !chan_ioreadval | ||
| Line 677: | Line 1,334: | ||
|0x80-0x8f | |0x80-0x8f | ||
|Set Q to IO[N], where IO is an array of bytes that can be read/written by both the game and the channel script. If N < 4, IO[N] is then set to -1. | |Set Q to IO[N], where IO is an array of bytes that can be read/written by both the game and the channel script. If N < 4, IO[N] is then set to -1. | ||
| − | |||
|- | |- | ||
!chan_iowriteval | !chan_iowriteval | ||
| Line 685: | Line 1,341: | ||
|0x70-0x7f | |0x70-0x7f | ||
|Set IO[N] to Q. | |Set IO[N] to Q. | ||
| − | |||
|- | |- | ||
!chan_setnotepriority | !chan_setnotepriority | ||
| Line 693: | Line 1,348: | ||
|0x60-0x6f | |0x60-0x6f | ||
|Set note priority for later notes played on this channel to N. When the game wants to play a note and there aren’t any free notes available, a note with smaller or equal priority is discarded. Should be >= 2; 0 and 1 have internal meaning. Defaults to 3. | |Set note priority for later notes played on this channel to N. When the game wants to play a note and there aren’t any free notes available, a note with smaller or equal priority is discarded. Should be >= 2; 0 and 1 have internal meaning. Defaults to 3. | ||
| − | |||
|- | |- | ||
!chan_ioreadvalsub | !chan_ioreadvalsub | ||
| Line 701: | Line 1,355: | ||
|0x50-0x5f | |0x50-0x5f | ||
|Decrease Q by IO[N]. | |Decrease Q by IO[N]. | ||
| − | |||
|- | |- | ||
!chan_ioreadval2 | !chan_ioreadval2 | ||
| Line 709: | Line 1,362: | ||
|0x40-0x4f, u8 | |0x40-0x4f, u8 | ||
|Set Q to IO2[X], where IO2 is the IO array for channel N. | |Set Q to IO2[X], where IO2 is the IO array for channel N. | ||
| − | |||
|- | |- | ||
!chan_iowriteval2 | !chan_iowriteval2 | ||
| Line 717: | Line 1,369: | ||
|0x30-0x3f, u8 | |0x30-0x3f, u8 | ||
|Set IO2[X] to Q, where IO2 is the IO array for channel N. | |Set IO2[X] to Q, where IO2 is the IO array for channel N. | ||
| − | |||
|- | |- | ||
!chan_disablechannel | !chan_disablechannel | ||
| Line 725: | Line 1,376: | ||
|0x20-0x2f | |0x20-0x2f | ||
|Disable channel N for the parent sequence. | |Disable channel N for the parent sequence. | ||
| − | |||
|- | |- | ||
!chan_startchannel | !chan_startchannel | ||
| Line 733: | Line 1,383: | ||
|0x10-0x1f, addr | |0x10-0x1f, addr | ||
|Start channel N for the parent sequence, with channel script starting at address X. | |Start channel N for the parent sequence, with channel script starting at address X. | ||
| − | |||
|- | |- | ||
!chan_testlayerfinished | !chan_testlayerfinished | ||
| Line 741: | Line 1,390: | ||
|0x00-0x0f | |0x00-0x0f | ||
|Set Q to 1 or 0, depending on whether layer N has been disabled (either forcibly or by finishing its script). | |Set Q to 1 or 0, depending on whether layer N has been disabled (either forcibly or by finishing its script). | ||
| − | |||
|} | |} | ||
=== Layer commands === | === Layer commands === | ||
{| class="wikitable" | {| class="wikitable" | ||
| − | |||
!Mnemonic | !Mnemonic | ||
!Param 1 | !Param 1 | ||
| Line 754: | Line 1,401: | ||
!Bytecode (US) | !Bytecode (US) | ||
!Description | !Description | ||
| − | |||
|- | |- | ||
!layer_end | !layer_end | ||
| Line 763: | Line 1,409: | ||
|0xff | |0xff | ||
|End of script, loop or function | |End of script, loop or function | ||
| − | |||
|- | |- | ||
!layer_call | !layer_call | ||
| Line 772: | Line 1,417: | ||
|0xfc, addr | |0xfc, addr | ||
|Call a function | |Call a function | ||
| − | |||
|- | |- | ||
!layer_jump | !layer_jump | ||
| Line 781: | Line 1,425: | ||
|0xfb, addr | |0xfb, addr | ||
|Jump to a point in the layer script | |Jump to a point in the layer script | ||
| − | |||
|- | |- | ||
!layer_loop | !layer_loop | ||
| Line 790: | Line 1,433: | ||
|0xf8, u8 | |0xf8, u8 | ||
|Repeat until <code>loopend</code> for X iterations (256 if X = 0) | |Repeat until <code>loopend</code> for X iterations (256 if X = 0) | ||
| − | |||
|- | |- | ||
!layer_loopend | !layer_loopend | ||
| Line 799: | Line 1,441: | ||
|0xf7 | |0xf7 | ||
|Loop end marker | |Loop end marker | ||
| − | |||
|- | |- | ||
!layer_setshortnotedurationfromtable | !layer_setshortnotedurationfromtable | ||
| Line 808: | Line 1,449: | ||
|0xe0-0xef | |0xe0-0xef | ||
|Set the duration for future short notes to table[N], where table defaults to <code>{229, 203, 177, 151, 139, 126, 113, 100, 87, 74, 61, 48, 36, 23, 10, 0}</code> and can be set by <code>setshortnotedurationtable</code>. | |Set the duration for future short notes to table[N], where table defaults to <code>{229, 203, 177, 151, 139, 126, 113, 100, 87, 74, 61, 48, 36, 23, 10, 0}</code> and can be set by <code>setshortnotedurationtable</code>. | ||
| − | |||
|- | |- | ||
!layer_setshortnotevelocityfromtable | !layer_setshortnotevelocityfromtable | ||
| Line 817: | Line 1,457: | ||
|0xd0-0xdf | |0xd0-0xdf | ||
|Set the velocity for future short notes to table[N], where table defaults to <code>{12, 25, 38, 51, 57, 64, 71, 76, 83, 89, 96, 102, 109, 115, 121, 127}</code> and can be set by <code>setshortnotevelocitytable</code>. | |Set the velocity for future short notes to table[N], where table defaults to <code>{12, 25, 38, 51, 57, 64, 71, 76, 83, 89, 96, 102, 109, 115, 121, 127}</code> and can be set by <code>setshortnotevelocitytable</code>. | ||
| − | |||
|- | |- | ||
!layer_setpan | !layer_setpan | ||
| Line 826: | Line 1,465: | ||
|0xca, u8 | |0xca, u8 | ||
|Set the pan for this layer (0…128). | |Set the pan for this layer (0…128). | ||
| − | |||
|- | |- | ||
!layer_setshortnoteduration | !layer_setshortnoteduration | ||
| Line 835: | Line 1,473: | ||
|0xc9, u8 | |0xc9, u8 | ||
|Set the duration for future short notes. | |Set the duration for future short notes. | ||
| − | |||
|- | |- | ||
!layer_disableportamento | !layer_disableportamento | ||
| Line 844: | Line 1,481: | ||
|0xc8 | |0xc8 | ||
|Disable portamento for later notes. | |Disable portamento for later notes. | ||
| − | |||
|- | |- | ||
!layer_portamento | !layer_portamento | ||
| Line 853: | Line 1,489: | ||
|0xc7, u8, u8, u8/var | |0xc7, u8, u8, u8/var | ||
|Enable portamento (aka glissando; continuously sliding pitch). X describes the mode of operation somehow using its 0x80 bit and a value 0-5 in its lower-order bits. Y describes the target pitch. Z gives the duration, and is a u8 if the 0x80 bit is set, otherwise a var. | |Enable portamento (aka glissando; continuously sliding pitch). X describes the mode of operation somehow using its 0x80 bit and a value 0-5 in its lower-order bits. Y describes the target pitch. Z gives the duration, and is a u8 if the 0x80 bit is set, otherwise a var. | ||
| − | |||
|- | |- | ||
!layer_setinstr | !layer_setinstr | ||
| Line 862: | Line 1,497: | ||
|0xc6, u8 | |0xc6, u8 | ||
|Set instrument/program. Similar to the channel command, except arguments 0x7f and above are not supported. | |Set instrument/program. Similar to the channel command, except arguments 0x7f and above are not supported. | ||
| − | |||
|- | |- | ||
!layer_somethingoff | !layer_somethingoff | ||
| Line 871: | Line 1,505: | ||
|0xc5 | |0xc5 | ||
|Turn off some bool related to how notes decay somehow? (This is the default.) | |Turn off some bool related to how notes decay somehow? (This is the default.) | ||
| − | |||
|- | |- | ||
!layer_somethingon | !layer_somethingon | ||
| Line 880: | Line 1,513: | ||
|0xc4 | |0xc4 | ||
|Turn on the same thing. | |Turn on the same thing. | ||
| − | |||
|- | |- | ||
!layer_setshortnotedefaultplaypercentage | !layer_setshortnotedefaultplaypercentage | ||
| Line 889: | Line 1,521: | ||
|0xc3, var | |0xc3, var | ||
|Set the default play percentage for short notes (see below). | |Set the default play percentage for short notes (see below). | ||
| − | |||
|- | |- | ||
!layer_transpose | !layer_transpose | ||
| Line 898: | Line 1,529: | ||
|0xc2, u8 | |0xc2, u8 | ||
|Set transposition in semitones. | |Set transposition in semitones. | ||
| − | |||
|- | |- | ||
!layer_setshortnotevelocity | !layer_setshortnotevelocity | ||
| Line 907: | Line 1,537: | ||
|0xc1, u8 | |0xc1, u8 | ||
|Set velocity for future short notes. | |Set velocity for future short notes. | ||
| − | |||
|- | |- | ||
!layer_delay | !layer_delay | ||
| Line 916: | Line 1,545: | ||
|0xc0, var | |0xc0, var | ||
|Delay for N ticks | |Delay for N ticks | ||
| − | |||
|- | |- | ||
!layer_note0 | !layer_note0 | ||
| Line 924: | Line 1,552: | ||
|duration | |duration | ||
|0x00-0x3f, var, u8, u8 | |0x00-0x3f, var, u8, u8 | ||
| − | |Play note with | + | |Play note with specified pitch, percentage, velocity and duration. Only valid if channel is set to “large notes”. |
| − | |||
|- | |- | ||
!layer_note1 | !layer_note1 | ||
| Line 933: | Line 1,560: | ||
| | | | ||
|0x40-0x7f, var, u8 | |0x40-0x7f, var, u8 | ||
| − | |Play note with | + | |Play note with specified pitch, percentage and velocity and duration of 0. Only valid if channel is set to “large notes”. |
| − | |||
|- | |- | ||
!layer_note2 | !layer_note2 | ||
| + | |pitch | ||
|velocity | |velocity | ||
|duration | |duration | ||
| − | |||
| | | | ||
|0x80-0xbf, u8, u8 | |0x80-0xbf, u8, u8 | ||
| − | |Play note with velocity | + | |Play note with specified pitch, velocity and duration. Only valid if channel is set to “large notes”. |
| − | |||
|- | |- | ||
!layer_smallnote0 | !layer_smallnote0 | ||
| Line 951: | Line 1,576: | ||
| | | | ||
|0x00-0x3f, var | |0x00-0x3f, var | ||
| − | |Play note with | + | |Play note with specified pitch and percentage and velocity and duration set with layer_setshortnotevelocity and layer_setshortnoteduration. Only valid if channel is set to “small notes”. |
| − | |||
|- | |- | ||
!layer_smallnote1 | !layer_smallnote1 | ||
| Line 960: | Line 1,584: | ||
| | | | ||
|0x40-0x7f | |0x40-0x7f | ||
| − | |Play note with pitch | + | |Play note with specified pitch and the default play percentage, as set by layer_setshortnotedefaultplaypercentage (there is no built-in default; using it without that command will read uninitialized memory). Velocity and duration is set like in layer_smallnote0. Only valid if channel is set to “small notes”. |
| − | |||
|- | |- | ||
!layer_smallnote2 | !layer_smallnote2 | ||
| Line 969: | Line 1,592: | ||
| | | | ||
|0x80-0xbf | |0x80-0xbf | ||
| − | |Play note with pitch | + | |Play note with specified pitch and the previous play percentage. Velocity and duration is set like in layer_smallnote0. Only valid if channel is set to “small notes”. |
| − | |||
|} | |} | ||
| Line 977: | Line 1,599: | ||
* [https://www.smwcentral.net/?p=section&s=sm64music Custom music] for SM64 on SMW Central | * [https://www.smwcentral.net/?p=section&s=sm64music Custom music] for SM64 on SMW Central | ||
* [https://hackmd.io/opEB-OmxRa26P8h8pA-x7w m64 format] posted on HackMD | * [https://hackmd.io/opEB-OmxRa26P8h8pA-x7w m64 format] posted on HackMD | ||
| + | [[Category:Audio]] | ||
Latest revision as of 19:08, 5 December 2025
dasdasdasdMusic in Super Mario 64 is controlled by sequence files. They are in .m64 format, which is similar to MIDI. A sequence file has a sequence script, that can spawn channels, which have channel scripts, that can spawn layers (also known as tracks), which have layer scripts that can play notes. Each note is performed using an instrument from a sound bank. A sequence file can use multiple banks. The mapping from sequences to sound banks is described in sound/sequences.json. Channels can switch between banks using a command. However, in practice most sequences limit themselves to a single sound bank. The main exception is sequence 0, which is responsible for sound effects.
A sequence may play up to 16 channels with up to 4 layers per channel. Several notes can be played simultaneously on a single layer.
A sequence is played as long as the sequence script is not ended. A channel (including layers) is active as long as the channel script is not ended.
Note properties
A note can be played by the commands layer_note0, layer_note1 and layer_note2 (only valid if chan_largenoteson has been called on the layer's channel) or layer_smallnote0, layer_smallnote1 and layer_smallnote2 (only valid if chan_largenotesoff has been called on the layer's channel; default state). A note is defined by the following properties:
Pitch
Also known as note. The pitch defines the frequency in which the instrument is to be played. See list of notes below for available pitches.
Play percentage
Also known as timestamp. This defines the note value, such as half or quarter note. This also implies a layer delay of the same amount. See note values below for possible values.
Velocity
This is the volume of the note.
Duration
Also known as gate or gate time. A value of 0 menas the note is heard during the whole percentage, 128 is half of the percentage and 255 almost none.
List of notes
This is a list of notes as used by the layer_note# and layer_smallnote# commands.
| Octave | Note | Decimal | Hex (note0) | Hex (note1) | Hex (note2) |
|---|---|---|---|---|---|
| 0 | A | 0 | 0x00 | 0x40 | 0x80 |
| A♯/B♭ | 1 | 0x01 | 0x41 | 0x81 | |
| B | 2 | 0x02 | 0x42 | 0x82 | |
| 1 | C | 3 | 0x03 | 0x43 | 0x83 |
| C♯/D♭ | 4 | 0x04 | 0x44 | 0x84 | |
| D | 5 | 0x05 | 0x45 | 0x85 | |
| D♯/E♭ | 6 | 0x06 | 0x46 | 0x86 | |
| E | 7 | 0x07 | 0x47 | 0x87 | |
| F | 8 | 0x08 | 0x48 | 0x88 | |
| F♯/G♭ | 9 | 0x09 | 0x49 | 0x89 | |
| G | 10 | 0x0A | 0x4A | 0x8A | |
| G♯/A♭ | 11 | 0x0B | 0x4B | 0x8B | |
| A | 12 | 0x0C | 0x4C | 0x8C | |
| A♯/B♭ | 13 | 0x0D | 0x4D | 0x8D | |
| B | 14 | 0x0E | 0x4E | 0x8E | |
| 2 | C | 15 | 0x0F | 0x4F | 0x8F |
| C♯/D♭ | 16 | 0x10 | 0x50 | 0x90 | |
| D | 17 | 0x11 | 0x51 | 0x91 | |
| D♯/E♭ | 18 | 0x12 | 0x52 | 0x92 | |
| E | 19 | 0x13 | 0x53 | 0x93 | |
| F | 20 | 0x14 | 0x54 | 0x94 | |
| F♯/G♭ | 21 | 0x15 | 0x55 | 0x95 | |
| G | 22 | 0x16 | 0x56 | 0x96 | |
| G♯/A♭ | 23 | 0x17 | 0x57 | 0x97 | |
| A | 24 | 0x18 | 0x58 | 0x98 | |
| A♯/B♭ | 25 | 0x19 | 0x59 | 0x99 | |
| B | 26 | 0x1A | 0x5A | 0x9A | |
| 3 | C | 27 | 0x1B | 0x5B | 0x9B |
| C♯/D♭ | 28 | 0x1C | 0x5C | 0x9C | |
| D | 29 | 0x1D | 0x5D | 0x9D | |
| D♯/E♭ | 30 | 0x1E | 0x5E | 0x9E | |
| E | 31 | 0x1F | 0x5F | 0x9F | |
| F | 32 | 0x20 | 0x60 | 0xA0 | |
| F♯/G♭ | 33 | 0x21 | 0x61 | 0xA1 | |
| G | 34 | 0x22 | 0x62 | 0xA2 | |
| G♯/A♭ | 35 | 0x23 | 0x63 | 0xA3 | |
| A | 36 | 0x24 | 0x64 | 0xA4 | |
| A♯/B♭ | 37 | 0x25 | 0x65 | 0xA5 | |
| B | 38 | 0x26 | 0x66 | 0xA6 | |
| 4 | C | 39 | 0x27 | 0x67 | 0xA7 |
| C♯/D♭ | 40 | 0x28 | 0x68 | 0xA8 | |
| D | 41 | 0x29 | 0x69 | 0xA9 | |
| D♯/E♭ | 42 | 0x2A | 0x6A | 0xAA | |
| E | 43 | 0x2B | 0x6B | 0xAB | |
| F | 44 | 0x2C | 0x6C | 0xAC | |
| F♯/G♭ | 45 | 0x2D | 0x6D | 0xAD | |
| G | 46 | 0x2E | 0x6E | 0xAE | |
| G♯/A♭ | 47 | 0x2F | 0x6F | 0xAF | |
| A | 48 | 0x30 | 0x70 | 0xB0 | |
| A♯/B♭ | 49 | 0x31 | 0x71 | 0xB1 | |
| B | 50 | 0x32 | 0x72 | 0xB2 | |
| 5 | C | 51 | 0x33 | 0x73 | 0xB3 |
| C♯/D♭ | 52 | 0x34 | 0x74 | 0xB4 | |
| D | 53 | 0x35 | 0x75 | 0xB5 | |
| D♯/E♭ | 54 | 0x36 | 0x76 | 0xB6 | |
| E | 55 | 0x37 | 0x77 | 0xB7 | |
| F | 56 | 0x38 | 0x78 | 0xB8 | |
| F♯/G♭ | 57 | 0x39 | 0x79 | 0xB9 | |
| G | 58 | 0x3A | 0x7A | 0xBA | |
| G♯/A♭ | 59 | 0x3B | 0x7B | 0xBB | |
| A | 60 | 0x3C | 0x7C | 0xBC | |
| A♯/B♭ | 61 | 0x3D | 0x7D | 0xBD | |
| B | 62 | 0x3E | 0x7E | 0xBE | |
| 6 | C | 63 | 0x3F | 0x7F | 0xBF |
Note durations
The effective duration of a note and the delay commands is based on the currently set sequence tempo. The duration of a single tick in seconds can be calculated using the following formula: time = 1.25 / tempo.
| Note | Ticks | Duration (120 BPM) |
|---|---|---|
| whole | 192 | 2s |
| half dotted (2nd + 4th) | 144 | 1.5s |
| half | 96 | 1s |
| quarter dottet (4th + 8th) | 72 | 0.75s |
| quarter (4th) | 48 | 0.5s |
| eighth dottet (8th + 16th) | 36 | 0.375s |
| quarter tuplet | 32 | 0.333s |
| eighth (8th) | 24 | 0.25s |
| sixteenth dottet (16th + 32th) | 18 | 0.1875s |
| eigthth tuplet | 16 | 0.1666s |
| sixteenth (16th) | 12 | 0.125s |
| 32th dottet (32th + 64th) | 9 | 0.09375s |
| sixteenth tuplet (16th) | 8 | 0.08333s |
| 32th | 6 | 0.0625s |
| 32th tuplet | 4 | 0.041666s |
| 64th | 3 | 0.03125s |
| 64th tuplet | 2 | 0.0208333s |
Create sequences
There are several ways for creating new sequence files.
Seq64
Seq64 is a GUI program for editing sequence files for Super Mario 64 and other Nintendo games. It also features full MIDI importing and exporting.
https://github.com/sauraen/seq64
Manually
Sequence files can also be created manually in a textual format. Create a new assembly file in the sequences directory, for example sound/sequences/us/23_custom_sequence.s. This file should have the following anatomy:
1 #include "seq_macros.inc"
2 .section .rodata
3 .align 0
4
5 ################################################################################
6 # This label is required at the beginning of the sequence.
7 sequence_start:
8
9 # Sequence commands like seq_settempo, seq_initchannels, seq_startchannel here
10 seq_startchannel 0, channel0
11
12 # If your sequence loops, put this here
13 seq_jump sequence_start
14
15 # End of sequence script
16 seq_end
17
18 ################################################################################
19 # Any label you want, so you can refer to this section when starting a channel.
20 channel0:
21
22 # Channel commands like chan_setvol, chan_setinstr, chan_setlayer here
23 chan_largenoteson
24 chan_setlayer 0, layer_melody
25
26 # End of channel script
27 chan_end
28
29 ################################################################################
30 layer_melody:
31
32 # Layer commands here like layer_note0, layer_note1 etc.
33
34 # End of layer script
35 layer_end
Next you can write down a series of commands. See include/seq_macros.inc or https://hackmd.io/opEB-OmxRa26P8h8pA-x7w for a list of available commands.
Example melody "Transposition"
The following example script plays a melody of 69 notes and repeats it over at varying transposition (hence the name).
1 #include "seq_macros.inc"
2 .section .rodata
3 .align 0
4
5 .eqv EIGHTH, 24
6 .eqv SEQ_LEN, EIGHTH * (9 + 11 + 10 + 12 + 12 + 7 + 8)
7
8 # This label is required at the beginning of the sequence.
9 sequence_start:
10
11 seq_setmutebhv 0x20
12 seq_settempo 125
13 seq_setvol 127
14
15 seq_initchannels 0x01
16 seq_startchannel 0, channel0
17
18 # Note: the maximum delay is 32767 (0x7fff) ticks, so we just do multiple delays.
19 seq_delay SEQ_LEN * 5
20 seq_delay SEQ_LEN * 5
21 seq_delay SEQ_LEN * 5
22 seq_delay SEQ_LEN * 5
23 seq_delay SEQ_LEN * 5
24 seq_jump sequence_start
25
26 seq_end
27
28 channel0:
29 chan_largenoteson
30 chan_setvol 127
31 chan_setinstr 4
32 chan_setreverb 127
33
34 chan_setlayer 0, layer_melody
35 chan_delay SEQ_LEN
36
37 chan_transpose -11
38 chan_setlayer 0, layer_melody
39 chan_delay SEQ_LEN
40
41 chan_transpose -8
42 chan_setlayer 0, layer_melody
43 chan_delay SEQ_LEN
44
45 chan_transpose -2
46 chan_setlayer 0, layer_melody
47 chan_delay SEQ_LEN
48
49 chan_transpose -6
50 chan_setlayer 0, layer_melody
51 chan_delay SEQ_LEN
52
53 chan_transpose 9
54 chan_setlayer 0, layer_melody
55 chan_delay SEQ_LEN
56
57 chan_transpose 1
58 chan_setlayer 0, layer_melody
59 chan_delay SEQ_LEN
60
61 chan_transpose -7
62 chan_setlayer 0, layer_melody
63 chan_delay SEQ_LEN
64
65 chan_transpose 10
66 chan_setlayer 0, layer_melody
67 chan_delay SEQ_LEN
68
69 chan_transpose 12
70 chan_setlayer 0, layer_melody
71 chan_delay SEQ_LEN
72
73 chan_transpose 2
74 chan_setlayer 0, layer_melody
75 chan_delay SEQ_LEN
76
77 chan_transpose 4
78 chan_setlayer 0, layer_melody
79 chan_delay SEQ_LEN
80
81 chan_transpose 5
82 chan_setlayer 0, layer_melody
83 chan_delay SEQ_LEN
84
85 chan_transpose 3
86 chan_setlayer 0, layer_melody
87 chan_delay SEQ_LEN
88
89 chan_transpose -5
90 chan_setlayer 0, layer_melody
91 chan_delay SEQ_LEN
92
93 chan_transpose -12
94 chan_setlayer 0, layer_melody
95 chan_delay SEQ_LEN
96
97 chan_transpose -9
98 chan_setlayer 0, layer_melody
99 chan_delay SEQ_LEN
100
101 chan_transpose 7
102 chan_setlayer 0, layer_melody
103 chan_delay SEQ_LEN
104
105 chan_transpose 6
106 chan_setlayer 0, layer_melody
107 chan_delay SEQ_LEN
108
109 chan_transpose -10
110 chan_setlayer 0, layer_melody
111 chan_delay SEQ_LEN
112
113 chan_transpose 11
114 chan_setlayer 0, layer_melody
115 chan_delay SEQ_LEN
116
117 chan_transpose -4
118 chan_setlayer 0, layer_melody
119 chan_delay SEQ_LEN
120
121 chan_transpose -1
122 chan_setlayer 0, layer_melody
123 chan_delay SEQ_LEN
124
125 chan_transpose 8
126 chan_setlayer 0, layer_melody
127 chan_delay SEQ_LEN
128
129 chan_transpose -3
130 chan_setlayer 0, layer_melody
131 chan_delay SEQ_LEN
132
133 chan_end
134
135 layer_melody:
136 layer_note1 40, EIGHTH, 100 # c#4
137 layer_note1 42, EIGHTH, 100 # d#4
138 layer_note1 43, EIGHTH, 100 # e-4
139 layer_note1 35, EIGHTH, 100 # ab3
140 layer_note1 42, EIGHTH, 100 # d#4
141 layer_note1 33, EIGHTH, 100 # gb3
142 layer_note1 31, EIGHTH, 100 # e-3
143 layer_note1 30, EIGHTH, 100 # d#3
144 layer_note1 28, EIGHTH, 100 # c#3
145
146 layer_note1 35, EIGHTH, 100 # ab3
147 layer_note1 40, EIGHTH, 100 # c#4
148 layer_note1 43, EIGHTH, 100 # e-4
149 layer_note1 42, EIGHTH, 100 # d#4
150 layer_note1 43, EIGHTH, 100 # e-4
151 layer_note1 45, EIGHTH, 100 # gb4
152 layer_note1 35, EIGHTH, 100 # ab3
153 layer_note1 38, EIGHTH, 100 # b-3
154 layer_note1 43, EIGHTH, 100 # e-4
155 layer_note1 42, EIGHTH, 100 # d#4
156 layer_note1 40, EIGHTH, 100 # c#4
157
158 layer_note1 35, EIGHTH, 100 # ab3
159 layer_note1 40, EIGHTH, 100 # c#4
160 layer_note1 44, EIGHTH, 100 # f-4
161 layer_note1 40, EIGHTH, 100 # c#4
162 layer_note1 45, EIGHTH, 100 # gb4
163 layer_note1 40, EIGHTH, 100 # c#4
164 layer_note1 47, EIGHTH, 100 # ab4
165 layer_note1 40, EIGHTH, 100 # c#4
166 layer_note1 48, EIGHTH, 100 # a-4
167 layer_note1 40, EIGHTH, 100 # c#4
168
169 layer_note1 42, EIGHTH, 100 # d#4
170 layer_note1 38, EIGHTH, 100 # b-3
171 layer_note1 33, EIGHTH, 100 # gb3
172 layer_note1 38, EIGHTH, 100 # b-3
173 layer_note1 42, EIGHTH, 100 # d#4
174 layer_note1 38, EIGHTH, 100 # b-3
175 layer_note1 43, EIGHTH, 100 # e-4
176 layer_note1 38, EIGHTH, 100 # b-3
177 layer_note1 45, EIGHTH, 100 # gb4
178 layer_note1 38, EIGHTH, 100 # b-3
179 layer_note1 47, EIGHTH, 100 # ab4
180 layer_note1 38, EIGHTH, 100 # b-3
181
182 layer_note1 40, EIGHTH, 100 # c#4
183 layer_note1 36, EIGHTH, 100 # a-3
184 layer_note1 35, EIGHTH, 100 # ab3
185 layer_note1 36, EIGHTH, 100 # a-3
186 layer_note1 40, EIGHTH, 100 # c#4
187 layer_note1 43, EIGHTH, 100 # e-4
188 layer_note1 38, EIGHTH, 100 # b-3
189 layer_note1 35, EIGHTH, 100 # ab3
190 layer_note1 33, EIGHTH, 100 # gb3
191 layer_note1 35, EIGHTH, 100 # ab3
192 layer_note1 38, EIGHTH, 100 # b-3
193 layer_note1 43, EIGHTH, 100 # e-4
194
195 layer_note1 33, EIGHTH, 100 # gb3
196 layer_note1 35, EIGHTH, 100 # ab3
197 layer_note1 36, EIGHTH, 100 # a-3
198 layer_note1 31, EIGHTH, 100 # e-3
199 layer_note1 30, EIGHTH, 100 # d#3
200 layer_note1 31, EIGHTH, 100 # e-3
201 layer_note1 33, EIGHTH, 100 # gb3
202
203 layer_note1 30, EIGHTH, 100 # d#3
204 layer_note1 26, EIGHTH, 100 # b-2
205 layer_note1 24, EIGHTH, 100 # a-2
206 layer_note1 23, EIGHTH, 100 # ab2
207 layer_note1 31, EIGHTH, 100 # e-3
208 layer_note1 24, EIGHTH, 100 # a-2
209 layer_note1 31, EIGHTH, 100 # e-3
210 layer_note1 23, EIGHTH, 100 # ab2
211
212 layer_end
Commands
Sequence commands
| Mnemonic | Param 1 | Param 2 | Bytecode (US) | Description |
|---|---|---|---|---|
| seq_end | 0xff | End of script, loop or function | ||
| seq_delay1 | 0xfe | Delay for 1 tick | ||
| seq_delay | ticks | 0xfd, var | Delay for X ticks | |
| seq_call | address | 0xfc, addr | Call a function | |
| seq_jump | address | 0xfb, addr | Jump to a point in the sequence script | |
| seq_beqz | address | 0xfa, addr | Jump if Q == 0, where Q is an s8 used to hold temporary sequence script state | |
| seq_bltz | address | 0xf9, addr | Jump if Q < 0 | |
| seq_loop | iterations | 0xf8, u8 | Repeat until loopend for X iterations (256 if X = 0)
| |
| seq_loopend | 0xf7 | Loop end marker | ||
| seq_bgez | address | 0xf5, addr | Jump if Q >= 0 | |
| seq_reservenotes | numNotes | 0xf2, u8 | Reserve X notes for exclusive use by this sequence (dropping earlier reservations). A limited number of notes can be played at once (configurable per level, usually 16); if more than that are played, an existing one will be stopped and reused. This command can prevent that from happening across sequences. | |
| seq_unreservenotes | 0xf1 | Drop all earlier reservations made by this sequence. | ||
| seq_transpose | semitones | 0xdf, s8 | Set transposition in semitones. | |
| seq_transposerel | semitones | 0xde, s8 | Change transposition by some delta. | |
| seq_settempo | tempo | 0xdd, u8 | Set tempo in BPM. | |
| seq_addtempo | tempo | 0xdc, s8 | Change tempo by some delta. | |
| seq_setvol | volume | 0xdb, u8 | Set volume scale (0…255 = none to twice normal). | |
| seq_changevol | volume | 0xda, s8 | Change volume scale by some delta. | |
| seq_initchannels | channelMask | 0xd7, u16 | Initialize channels (bitmask). This copies mute behavior and note allocation policy. | |
| seq_disablechannels | channelMask | 0xd6, u16 | Uninitialize channels (bitmask). | |
| seq_setmutescale | mulitplier | 0xd5, s8 | Set volume multiplier for muted mode (0…127). | |
| seq_mute | 0xd4 | Set sequence to muted mode. Depending on what behavior has been set this will do different things; from lowering volume to not running scripts. | ||
| seq_setmutebhv | bitmask | 0xd3, u8 | Set mute behavior (bitmask). Bit 0x20 lowers volume, bit 0x40 does something to layers, and bit 0x80 pauses the sequence script. Default mute behavior is to have all of those bits set. | |
| seq_setshortnotevelocitytable | address | 0xd2, addr | Set velocity table for short notes (see further down). Target should be an array of bytes in the sequence data of length 16. | |
| seq_setshortnotedurationtable | address | 0xd1, addr | Set duration table for short notes (see further down). Target should be an array of bytes in the sequence data of length 16. | |
| seq_setnoteallocationpolicy | policyMask | 0xd0, u8 | Set note allocation policy (bitmask). If bit 0x1 is set, it will try to steal notes back from what was previously played on the same layer. If bit 0x2 is set, notes will be allocated exclusively from the channel’s reserved notes, else if 0x4 is set, from the channel’s or sequence’s reserved notes, else if 0x8 is set, from unreserved notes, otherwise from all sources. Not used by the game. | |
| seq_setval | value | 0xcc, u8 | Set Q to a constant. | |
| seq_bitand | value | 0xc9, u8 | Bitand Q by a constant. | |
| seq_subtract | value | 0xc8, u8 | Subtract a constant from Q. | |
| seq_startchannel | channel | address | 0x90-0x9f, addr | Start channel N, with a given channel script. |
| seq_getvariation | 0x80-0x8f | Set Q to the variation bit, which is initially either 0 or 0x80 (i.e. -128, since Q is s8). This bit comes from the sequence load command. For instance, to play the Koopa shell music, the game plays sequence 0x8E, which is the same as sequence 0xE but with the variation bit set. | ||
| seq_setvariation | 0x70-0x7f | Set the variation bit to Q. | ||
| seq_subvariation | 0x50-0x5f | Subtract the variation bit from Q. | ||
| seq_testchdisabled | channel | 0x00-0x0f | Set Q to 1 or 0, depending on whether channel N has been disabled by channel script. |
Channel commands
| Mnemonic | Param 1 | Param 2 | Param 3 | Bytecode (US) | Description |
|---|---|---|---|---|---|
| chan_end | 0xff | End of script, loop or function | |||
| chan_delay1 | 0xfe | Delay for 1 tick | |||
| chan_delay | ticks | 0xfd, var | Delay for X ticks | ||
| chan_call | address | 0xfc, addr | Call a function | ||
| chan_jump | address | 0xfb, addr | Jump to a point in the channel script | ||
| chan_beqz | address | 0xfa, addr | Jump if Q == 0, where Q is an s8 used to hold temporary channel script state | ||
| chan_bltz | address | 0xf9, addr | Jump if Q < 0 | ||
| chan_loop | iterations | 0xf8, u8 | Repeat until loopend for X iterations (256 if X = 0)
| ||
| chan_loopend | 0xf7 | Loop end marker | |||
| chan_break | 0xf6 | Decrease loop/function stack depth by 1. Combine with a jump to break out of a loop. | |||
| chan_bgez | address | 0xf5, addr | Jump if Q >= 0 | ||
| chan_hang | 0xf3 | Infinite delay. | |||
| chan_reservenotes | numNotes | 0xf2, u8 | Reserve X notes for exclusive use by this channel (dropping earlier reservations). | ||
| chan_unreservenotes | numNotes | 0xf1 | Drop all earlier reservations made by this channel. | ||
| chan_dyncall | 0xe4 | If Q != -1, make a function call to position dyntable[Q], where dyntable is a channel-specific u16 array which can set by setdyntable/dynsetdyntable.
| |||
| chan_setvibratodelay | 0xe3, u8 | Set delay until vibrato starts for each note. | |||
| chan_setvibratoextentlinear | 0xe2, u8, u8, u8 | Set vibrato extent for each note as a function that starts at X, goes up linearly to Y over a time span given by Z, then stays there. | |||
| chan_setvibratoratelinear | 0xe1, u8, u8, u8 | Like above except for vibrato rate. | |||
| chan_setvolscale | volume | 0xe0, u8 | Set scale factor for volume (0…255 = none to twice normal). | ||
| chan_setvol | volume | 0xdf, u8 | Set scale factor #2 for volume (0…255 = none to twice normal). The two scale factors are separately controlled by outer audio logic, e.g. when changing between rooms, when playing sound effects, etc. The game almost exclusively uses setvol, so that should probably be preferred, but setvolscale shows up in a few locations in the sound effect sequence. | ||
| chan_freqscale | value | 0xde, u16 | Pitch bend using a raw frequency multiplier X/2^15. | ||
| chan_setpan | pan | 0xdd, u8 | Set the pan for this channel (0…128) | ||
| chan_setpanchanweight | 0xdc, u8 | The pan for each note will be computed as W * channel pan + (1 - W) * note pan. This sets W (0…128 maps to 0…1). W defaults to 1.0. | |||
| chan_transpose | semitones | 0xdb, s8 | Set transposition in semitones. | ||
| chan_setenvelope | address | 0xda, addr | Set ADSR envelope. See below for format. | ||
| chan_setdecayrelease | rate | 0xd9, u8 | Set ADSR decay/release rate. | ||
| chan_setvibratoextent | extent | 0xd8, u8 | Set vibrato extent. | ||
| chan_setvibratorate | rate | 0xd7, u8 | Set vibrato rate. | ||
| chan_setupdatesperframe | 0xd6, u8 | Seems like it was meant to set the number of updates per frame? But it doesn’t actually do anything. | |||
| chan_setreverb | reverb | 0xd4, u8 | Set amount of reverb (or “dry/wet mix”?). | ||
| chan_pitchbend | bend | 0xd3, s8 | Pitch bend by <= 1 octave in either direction (-127…127). | ||
| chan_setsustain | volume | 0xd2, u8 | Set ADSR sustain volume. | ||
| chan_setnoteallocationpolicy | policyMask | 0xd1, u8 | Set note allocation policy for channel. See the description for sequence scripts. | ||
| chan_stereoheadseteffects | enable | 0xd0, u8 | Enable (1) or disable (0) some pan/volume effects related to stereo/headset. I don’t know which ones precisely – pan is still taken into account even with this disabled. With this disabled, stereo/headset gets the same output. | ||
| chan_setval | value | 0xcc, u8 | Set Q to a constant. | ||
| chan_readseq | address | 0xcb, addr | Set Q to sequenceData[X + Q]. | ||
| chan_setmutebhv | 0xca, u8 | Set mute behavior for this channel. | |||
| chan_bitand | value | 0xc9, u8 | Bitand Q by a constant. | ||
| chan_subtract | value | 0xc8, u8 | Subtract a constant from Q. | ||
| chan_writeseq | address | 0xc7, u8, addr | Overwrite the byte at the given position in the sequence script by (Q + X). | ||
| chan_setbank | bank | 0xc6, u8 | Switch bank within instrument bank sets, to the X’th bank, 0-indexed, counting from the end. | ||
| chan_dynsetdyntable | 0xc5 | If Q != -1, set dyntable to point to position dyntable[Q] in the sequence data. | |||
| chan_largenoteson | 0xc4 | Set notes for this channel to use “large notes” format. SM64 does this for all channels. (See note vs. shortnote in the layer section below.)
| |||
| chan_largenotesoff | 0xc3 | Set notes for this channel to use “short notes” format. | |||
| chan_setdyntable | address | 0xc2, addr | Set dyntable to point to a given u16 array from the sequence data. | ||
| chan_setinstr | instrument | 0xc1, u8 | Set instrument (program?) within bank. 0x80-0x83 set raw waves (sawtooth, triangle, sine, square), 0x7f is special, otherwise 0-indexed. | ||
| chan_dynsetlayer | 0xb0-0xbf | If Q != -1, start layer N, with layer script given by dyntable[Q]. | |||
| chan_freelayer | layer | 0xa0-0xaf | Stop layer N. | ||
| chan_setlayer | layer | address | 0x90-0x9f, addr | Start layer N, with layer script starting at address X. | |
| chan_ioreadval | 0x80-0x8f | Set Q to IO[N], where IO is an array of bytes that can be read/written by both the game and the channel script. If N < 4, IO[N] is then set to -1. | |||
| chan_iowriteval | 0x70-0x7f | Set IO[N] to Q. | |||
| chan_setnotepriority | 0x60-0x6f | Set note priority for later notes played on this channel to N. When the game wants to play a note and there aren’t any free notes available, a note with smaller or equal priority is discarded. Should be >= 2; 0 and 1 have internal meaning. Defaults to 3. | |||
| chan_ioreadvalsub | 0x50-0x5f | Decrease Q by IO[N]. | |||
| chan_ioreadval2 | 0x40-0x4f, u8 | Set Q to IO2[X], where IO2 is the IO array for channel N. | |||
| chan_iowriteval2 | 0x30-0x3f, u8 | Set IO2[X] to Q, where IO2 is the IO array for channel N. | |||
| chan_disablechannel | channel | 0x20-0x2f | Disable channel N for the parent sequence. | ||
| chan_startchannel | channel | address | 0x10-0x1f, addr | Start channel N for the parent sequence, with channel script starting at address X. | |
| chan_testlayerfinished | layer | 0x00-0x0f | Set Q to 1 or 0, depending on whether layer N has been disabled (either forcibly or by finishing its script). |
Layer commands
| Mnemonic | Param 1 | Param 2 | Param 3 | Param 4 | Bytecode (US) | Description |
|---|---|---|---|---|---|---|
| layer_end | 0xff | End of script, loop or function | ||||
| layer_call | address | 0xfc, addr | Call a function | |||
| layer_jump | address | 0xfb, addr | Jump to a point in the layer script | |||
| layer_loop | iterations | 0xf8, u8 | Repeat until loopend for X iterations (256 if X = 0)
| |||
| layer_loopend | 0xf7 | Loop end marker | ||||
| layer_setshortnotedurationfromtable | 0xe0-0xef | Set the duration for future short notes to table[N], where table defaults to {229, 203, 177, 151, 139, 126, 113, 100, 87, 74, 61, 48, 36, 23, 10, 0} and can be set by setshortnotedurationtable.
| ||||
| layer_setshortnotevelocityfromtable | 0xd0-0xdf | Set the velocity for future short notes to table[N], where table defaults to {12, 25, 38, 51, 57, 64, 71, 76, 83, 89, 96, 102, 109, 115, 121, 127} and can be set by setshortnotevelocitytable.
| ||||
| layer_setpan | pan | 0xca, u8 | Set the pan for this layer (0…128). | |||
| layer_setshortnoteduration | duration | 0xc9, u8 | Set the duration for future short notes. | |||
| layer_disableportamento | 0xc8 | Disable portamento for later notes. | ||||
| layer_portamento | 0xc7, u8, u8, u8/var | Enable portamento (aka glissando; continuously sliding pitch). X describes the mode of operation somehow using its 0x80 bit and a value 0-5 in its lower-order bits. Y describes the target pitch. Z gives the duration, and is a u8 if the 0x80 bit is set, otherwise a var. | ||||
| layer_setinstr | instrument | 0xc6, u8 | Set instrument/program. Similar to the channel command, except arguments 0x7f and above are not supported. | |||
| layer_somethingoff | 0xc5 | Turn off some bool related to how notes decay somehow? (This is the default.) | ||||
| layer_somethingon | 0xc4 | Turn on the same thing. | ||||
| layer_setshortnotedefaultplaypercentage | percentage | 0xc3, var | Set the default play percentage for short notes (see below). | |||
| layer_transpose | semitones | 0xc2, u8 | Set transposition in semitones. | |||
| layer_setshortnotevelocity | velocity | 0xc1, u8 | Set velocity for future short notes. | |||
| layer_delay | ticks | 0xc0, var | Delay for N ticks | |||
| layer_note0 | pitch | percentage | velocity | duration | 0x00-0x3f, var, u8, u8 | Play note with specified pitch, percentage, velocity and duration. Only valid if channel is set to “large notes”. |
| layer_note1 | pitch | percentage | velocity | 0x40-0x7f, var, u8 | Play note with specified pitch, percentage and velocity and duration of 0. Only valid if channel is set to “large notes”. | |
| layer_note2 | pitch | velocity | duration | 0x80-0xbf, u8, u8 | Play note with specified pitch, velocity and duration. Only valid if channel is set to “large notes”. | |
| layer_smallnote0 | pitch | percentage | 0x00-0x3f, var | Play note with specified pitch and percentage and velocity and duration set with layer_setshortnotevelocity and layer_setshortnoteduration. Only valid if channel is set to “small notes”. | ||
| layer_smallnote1 | pitch | 0x40-0x7f | Play note with specified pitch and the default play percentage, as set by layer_setshortnotedefaultplaypercentage (there is no built-in default; using it without that command will read uninitialized memory). Velocity and duration is set like in layer_smallnote0. Only valid if channel is set to “small notes”. | |||
| layer_smallnote2 | pitch | 0x80-0xbf | Play note with specified pitch and the previous play percentage. Velocity and duration is set like in layer_smallnote0. Only valid if channel is set to “small notes”. |
See also
- Custom music for SM64 on SMW Central
- m64 format posted on HackMD