Skip to content

Latest commit

 

History

History
176 lines (137 loc) · 6.34 KB

AUDIO.md

File metadata and controls

176 lines (137 loc) · 6.34 KB

Audio

Mega Man 3, 4, 5 and 6 is used the same audio engine. So these commands can be used in common.

These commands are based on macros/audio.asm, constants/audio.asm and audio/audio.asm

Note: Mega Man 6 audio engine just little different from 3, 4 and 5 audio engine (Initial SFX and relocate octave table program, Other is same.)

Instrument

It includes 8 commands to use set an instrument. It must be set for every instruments fully.

INSTRUMENT_ATTACK n

Used for note from 0 to max volume rate.

n: rate [00, $1F]

INSTRUMENT_DECAY n

Used for note from max volume to sustain volume rate.

n: rate [00, $1F]

INSTRUMENT_SUSTAIN n

Used for note sustain volume subtract n from max volume

n: subtraction volume [0, $F]

INSTRUMENT_RELEASE n

Used for note from sustain volume to 0 rate.

n: rate [00, $1F]

INSTRUMENT_VIBRATO_RATE n

Used for note vibrato rate.

INSTRUMENT_PITCH_VIBRATO_RATE n

Used for note pitch vibrato rate.

INSTRUMENT_VIBRATO_VOLUME_RATE n

Used for note vibrato volume rate.

INSTRUMENT_NOISE_DUTY_CYCLE n

Used for set noise duty cycle.

n: [0, 1]

Note: Unlike square 1 and 2, noise duty cycle must be effected from instruments.

Music channel commands

These are available commands used from audio engine.

MUSIC_CHANNEL_POINTERS

Set playing music instead of SFX.

TRIPLET_SET

Set notes play with 2/3 length. Used by all music channels.

Usage:

Start at the first note, end of the last note after playing.

example: TRIPLET_SET, NOTE, NOTE, NOTE, TRIPLET_SET

Note: It also effected by NOTE_FLAGS and BREAK_n commands.

CONNECT_SET

Set connected notes are played. Used by all music channels.

Usage:

Start at the first note, end of the last note.

example: CONNECT_SET, NOTE, NOTE, CONNECT_SET, NOTE

Note: It also effected by NOTE_FLAGS and BREAK_n commands.

DOTTED_SET

Set a note play with 1.5 length. Used by all music channels. It only effects current note.

OCTAVE_JMP

Set notes play with increasing/decreasing 2 octaves. Used by square 1, 2 and triangle.

Once CMD_OCTAVE_JMP flag is set, it's playing with higher 2 octaves. Unless this flag is NOT set.

Note: It also effected by NOTE_FLAGS and BREAK_n commands.

NOTE_FLAGS n

Set notes playing flags. Used by square 1, 2 and triangle. see constants/audio.asm:audio cmd constants. to set n.

TEMPO a, b

Set tempo for playing all music channels. It only used by square 1.

The formula to convert from TEMPO to BPM: BPM = 75 * (a + b/256).

Also this formula could calculate them: a = floor (BPM / 75), b = ceil ((BPM mod 75) / 75) * 256.

NOTE_ADS_FRACTION n

Set attack, decay and sustain total rate. Used by all music channels.

MAX_VOLUME n

Set max volume for channel playing, it used by square 1, 2 and noise.

n: [0, $F]

INSTRUMENT n

Set playing note with n instrument. Used by all music channels.

BASE_OCTAVE n

Set playing note with base octave. Used by all music channels.

n: [0, 7]

GLOBAL_TRANSPOSE n

Set playing note with base global octave/note transpose. It only used by square 1.

Note: GLOBAL_TRANSPOSE is effected square 1, 2 and triangle.

CHANNEL_TRANSPOSE n

Set playing note with base global octave/note transpose. Used by square 1, 2 and triangle.

Note: Unlike GLOBAL_TRANSPOSE, CHANNEL_TRANSPOSE is only effected current channel if it's set.

PITCH_TUNE n

Adjust playing notes pitch. Used by square 1, 2 and triangle.

PITCH_SLIDE n

Set notes play with pitch slide mode. Used by square 1, 2 and triangle.

LOOP_n count, address

Loop a branch of audio playing address with count times. Used by all music channels.

LOOP_n's n is supproted [1, 4]

Note: count must be non zero. If count is zero, loop cannot be run well. Please use CHANNEL_JMP commands.

BREAK_n note_flags, address

Similar with LOOP_n count, address, after finishing same n, it jumps into the new address. Used by all music channels.

note_flags is same as NOTE_FLAGS's n.

CHANNEL_JMP, address

Jump to play address directly.

CHANNEL_END

End of channel playing.

DUTY_CYCLE n

Set duty cycle for square channels. Used by square 1 and 2.

n: [0, 3]

Note: unlike noise channel, noise channle must be set from instrument the last parameters.

NOTE note_name, length

Play a note. Used by all music channels.

note_name: see constants/audio.asm:note_table..

Note: NOISE_NOTE note_name is only played from 0 to $F.

length: Length of note be played, it only accept power of 2.

Accept length table: 1, 2, 4, 8, 16, 32, 64. Other is NOT accept.

REST and NOISE_NOTE length both common usage.

Note: note relocated value also effected by OCTAVE_JMP, NOTE_FLAGS, BASE_OCTAVE and BREAK_n.

SFX

Some of SFX commands are common with music channel commands, but it has different setup usage. It must be set under the rules.

SFX_PRIORITY n

Set SFX playing priority, it must be set n non zero.

SFX_CHANNEL_GLOBAL_FLAGS n

See constants/audio.asm:audio sfx constants. to set n.

  • bit0 = SFX_CHANNEL_LOOP
  • bit1 = SFX_ADS_FRACTION
  • bit2 = SFX_GLOBAL_TRANSPOSE

SFX_CHANNEL_LOOP count, address

Like LOOP_n count, address, but count is allowed to 0 use for infinity loop.

It must be SFX_CHANNEL_GLOBAL_FLAGS's n bit0 set to use.

SFX_ADS_FRACTION n

Same as NOTE_ADS_FRACTION n, must be SFX_CHANNEL_GLOBAL_FLAGS's n bit1 set to use.

SFX_GLOBAL_TRANSPOSE n

Same as GLOBAL_TRANSPOSE n, must be SFX_CHANNEL_GLOBAL_FLAGS's n bit2 set to use.

SFX_FRAMES n

Set SFX segment playing n frames.

SFX_CHANNEL_USE_TOTAL channel

Set SFX playing channel.

  • bit0 = square 1
  • bit1 = square 2
  • bit2 = triangle
  • bit3 = noise

SFX_channel_FLAGS commands_bits

Set channel commands_bits total usage.

  • bit0 = instrument
  • bit1 = duty_cycle
  • bit2 = max_volume
  • bit3 = pitch_slide
  • bit4 = pitch_tune

SFX_channel_NOTE note_name

Like NOTE note_name, but directly.

Note: Some of original game use it by accident, use SKIP_SFX_NOTE ignore it.

SFX_CHANNEL_CONTINUE_PLAYING

If not set SFX_channel_NOTE n to replace a note use this command, it continues playing on current segment.

SFX_CHANNEL_END

End of SFX playing.