Introduction
AKAO sequence is the most complicated part of the FF7 sound system. (“AKAO” is the signature string, which implies that the sound format has developed by Square Enix sound programmer Minoru Akao.)
AKAO sequence is similar to MIDI sequence - it’s custom tracker format for playing sequence sound, well tuned specially for PSX.
The sequence data can be found in all FF7 game modules: Field, Battle, Worldmap and in minigames.
All files with exension *.SND are AKAO.
- MINI/ASERI2.SND - Battle Arena theme
- MINI/SENSUI.SND - used in Submarine minigame
- ENEMY6/OVER2.SND - game over sequence
- ENEMY6/FAN2.SND - battle win “fanfare” sequence
- MOVIE/OVER2.SND - same game over sequence, don’t know, why to duplicate data
Other AKAO sequences are hard-wired in other files.
File Structure
Header (size: 16 bytes)
struct AkaoSeqHeader
{
static const uint8_t magic[4]; // "AKAO" C-string
uint16_t id; // song ID, used for playing sequence
uint16_t length; // data length - sizeof(header)
uint16_t reverb_type; // reverb type (range from 0 to 9)
struct AkaoTimeStamp timestamp; // creation time
};
struct AkaoTimeStamp
{
uint8_t year_bcd; // year (in binary coded decimal)
uint8_t month_bcd; // month (in binary coded decimal, between 0x01 - 0x12)
uint8_t day_bcd; // day (in binary coded decimal, between 0x01 - 0x31)
uint8_t hours_bcd; // hours (in binary coded decimal, between 0x00 - 0x23)
uint8_t minutes_bcd; // minutes (in binary coded decimal, between 0x00 - 0x59)
uint8_t seconds_bcd; // seconds (in binary coded decimal, between 0x00 - 0x59)
};
Channel Info (size: 4 bytes + 2 bytes * )
struct AkaoChannelInfo
{
uint32_t mask; // represents bitmask of used channels in this song
uint16_t start_offsets[num_channels]; // offsets to channel opcode data
};
int num_channels = 0;
while (int bit = 0; bit < 24; bit++)
if ((info.mask & 0xFFFFFF) & (1 << bit)) != 0)
num_channels++;
First there is 32-bit number (offset 0x10), which represents bitmask of used channels in this song.
After this bitmask, there is
Channel Commands [AKAO Opcodes]
For every channels in an AKAO sequence, there is a set of commands to perform. This is similar to Field opcodes. Here I will call this sound commands “opcodes”. Every opcode has its own number of arguments (from no-arguments, to 3 arguments).
Drum Instrument Map Table
When a song uses a drum kit with opcode 0xEC, a drum instrument map table will be placed at the end of the sequence. The table determines the instrument, channel volume and pan for each keys.
The table consists of a repetition of 5-byte items.
struct AkaoDrumKeyAttr
{
uint8_t instrument; // corresponding to opcode 0xA1
uint8_t key; // note number when playing the drum note
uint16_t volume; // corresponding to opcode 0xA8 (lower 8bit is a fractional part of the volume)
uint8_t pan; // corresponding to opcode 0xAA
}
Example (Home-Created AKAO Sequence):
Header
41 4b 41 4f - AKAO string
34 12 - song ID: 0x1234
16 00 - data length 0x16 in hex or 22 in decimal
04 00 - reverb type: 4 (large studio)
96 12 18 22 46 28 - created at 1996-12-18 22:46:28
Channel Info
01 00 00 00 - this indicates, that used only one channel
00 00 - offset to first channel opcodes: in our example 0x00 means that next to this offset is opcodes for first channel
Channel Commands
e8 a8 66 - sets tempo, parameter 0x66a8
ea 00 50 - sets reverb depth
a8 55 - load sample 0x55 from INSTR.ALL to channel
aa 40 - sets channel volume
c2 - turns on reverb effect
a1 0c - sets volume pan
c8 - sets loop point
66 - 0x66 % 11 = 3 (3 means to take 3rd number from play length table), 0x66 / 11 = 9 (9 means to take pitch[9] from loaded instrument record index)
ca - returns to saved loop point with opcode c8
This example plays Chocobo “Whoo-Hoo” (instrument number 0x55) repeatedly.
Sound Opcode List
Opcode | Summary | Length | Operands | Note |
---|---|---|---|---|
Note, Tie, Rest | 1 | The opcode indicates the note key and length. The note will be keyed off 2 ticks before the next note. | ||
0x9A-0x9F | Unimplemented | 1 | Should not be used. | |
Finish Channel | 1 | |||
Load Instrument | 2 | instrument: byte (0-127) | ||
Overwrite Next Note Length | 2 | length: byte | Ignores the regular length (delta-time) of the next note and overwrites it with the specified length. | |
Channel Master Volume | 2 | volume: byte (0-127) | ||
Pitch Bend Slide | 3 | length: byte, semitones: signed byte | When | |
Set Octave | 2 | octave: byte (0-15) | ||
Increase Octave | 1 | |||
Decrease Octave | 1 | |||
Channel Volume | 2 | volume: byte (0-127) | ||
Channel Volume Slide | 3 | length: byte, volume: byte (0-127) | When | |
Channel Pan | 2 | pan: byte (0-127) | 64 is the center. | |
Channel Pan Slide | 3 | length: byte, pan: byte (0-127) | When | |
Noise Clock Frequency | 2 | clock: byte (0x00-0x3f) | ||
ADSR: Attack Rate | 2 | attack_rate: byte (0x00-0x7f) | ||
ADSR: Decay Rate | 2 | decay_rate: byte (0x00-0x0f) | ||
ADSR: Sustain Level | 2 | sustain_level: byte (0x00-0x0f) | ||
ADSR: Decay Rate & Sustain Level | 3 | decay_rate: byte (0x00-0x0f), sustain_level: byte (0x00-0x0f) | ||
ADSR: Sustain Rate | 2 | sustain_rate: byte (0x00-0x7f) | ||
ADSR: Release Rate | 2 | release_rate: byte (0x00-0x1f) | ||
ADSR: Reset ADSR | 1 | |||
Vibrato (Channel Pitch LFO) | 4 | delay: byte, rate: byte, type: byte (0-15) | When | |
Vibrato Depth | 2 | depth: byte | The most significant bit of the When it is 0, the range is up to about ± 50 cents (amplitude is 15/256 compared with range type 1). When it is 1, the range is up to about ± 700 cents. | |
Turn Off Vibrato | 1 | |||
ADSR: Attack Mode | 2 | attack_mode: byte (1 or 5) | ||
Tremolo (Channel Volume LFO) | 4 | delay: byte, rate: byte, type: byte (0-15) | When | |
Tremolo Depth | 2 | depth: byte | ||
Turn Off Tremolo | 1 | |||
ADSR: Sustain Mode | 2 | sustain_mode: byte (1, 3, 5 or 7) | ||
Channel Pan LFO | 3 | rate: byte, type: byte (0-15) | When | |
Channel Pan LFO Depth | 2 | depth: byte | ||
Turn Off Channel Pan LFO | 1 | |||
ADSR: Release Mode | 2 | release_mode: byte (3 or 7) | ||
Channel Transpose (Absolute) | 2 | semitones: signed byte | ||
Channel Transpose (Relative) | 2 | semitones: signed byte | ||
Turn On Reverb | 1 | |||
Turn Off Reverb | 1 | |||
Turn On Noise | 1 | |||
Turn Off Noise | 1 | |||
Turn On Frequency Modulation | 1 | |||
Turn Off Frequency Modulation | 1 | |||
Loop Point | 1 | Remember the current offset as a loop point and increase the nesting level of the loop. | ||
Return to Loop Point Up to N Times | 2 | times: byte | On the Nth repeat, this instruction will end the current loop by decrementing the nesting level of the loop. Otherwise, it will increment the loop counter and return to the loop point. When | |
Return to Loop Point | 1 | This instruction will increment the loop counter. | ||
Reset Sound Effects | 1 | Reset sound effects such as noise, frequency modulation, reverb, overlay voice and alternate voice. | ||
Turn On Legato | 1 | This instruction will stop the regular key on and key off performance of the subsequent notes and update the pitch only. | ||
Turn Off Legato | 1 | |||
Turn On Noise and Toggle Noise On/Off after a Period of Time | 2 | delay: byte | When | |
Toggle Noise On/Off after a Period of Time | 2 | delay: byte | When | |
Turn On Full-Length Note Mode | 1 | This instruction will stop the regular key off performance of the subsequent notes. | ||
Turn Off Full-Length Note Mode | 1 | |||
Turn On Frequency Modulation and Toggle Frequency Modulation On/Off after a Period of Time | 2 | delay: byte | When | |
Toggle Frequency Modulation On/Off after a Period of Time | 2 | delay: byte | When | |
Turn On Playback Rate Side Chain | 1 | Duplicate and use the playback frequency of the previous voice channel. | ||
Turn Off Playback Rate Side Chain | 1 | |||
Turn On Pitch-Volume Side Chain | 1 | Multiply the playback frequency of the previous voice channel to the output volume. Lower pitch will make the volume smaller. | ||
Turn Off Pitch-Volume Side Chain | 1 | |||
Channel Fine Tuning (Absolute) | 2 | amount: signed byte | The pitch can be changed in the range of one octave above and below. The | |
Channel Fine Tuning (Relative) | 2 | amount: signed byte | The | |
Turn On Portamento | 2 | speed: byte | When | |
Turn Off Portamento | 1 | |||
Fix Note Length | 2 | length_to_add: signed byte | Ignore the regular length (delta-time) of subsequent notes and set to the fixed length. The | |
Vibrato Depth Slide | 3 | length: byte, depth: byte | When | |
Tremolo Depth Slide | 3 | length: byte, depth: byte | When | |
Channel Pan LFO Depth Slide | 3 | length: byte, depth: byte | When | |
Unimplemented | 1 | Code-referenced to 0xA0. Should not be used. | ||
Tempo | 3 | tempo: uint16 | bpm = tempo / 214.998204 (approximate) More strictly, Note that this coefficient is different from other games with PlayStation AKAO. | |
Tempo Slide | 4 | length: byte, tempo: uint16 | When | |
Reverb Depth | 3 | depth: uint16 | ||
Reverb Depth Slide | 4 | length: byte, depth: uint16 | When | |
Turn On Drum Mode | 3 | drum_map_offset: signed int16 | The | |
Turn Off Drum Mode | 1 | |||
Unconditional Jump | 3 | destination_offset: signed int16 | This instruction can be used to make an infinite loop. | |
CPU-Conditional Jump | 4 | condition: byte, destination_offset: signed int16 | Jump if the condition variable matches | |
Jump on the Nth Repeat | 4 | times: byte, destination_offset: signed int16 | When | |
Break the Loop on the Nth Repeat | 4 | times: byte, destination_offset: signed int16 | Unlike 0xF0, this instruction will end the current loop by decrementing the nesting level of the loop. When | |
Load Instrument (No Attack Sample) | 2 | instrument: byte | Unlike 0xA1, the sample before the loop point is replaced by a short, silence sample. | |
Unknown | 1 | There is no actual use in music. | ||
Turn On Overlay Voice | 3 | instrument: byte, instrument2: byte | Play the same melody by different instruments on two voice channels. A free voice channel is required to work. Note that the two channels share the playback rate, and the pitch is not calculated for each instruments. Used in the song "Anxious Heart". | |
Turn Off Overlay Voice | 1 | |||
Overlay Volume Balance | 2 | balance: byte (0-127) | When the balance is 0, the volume of the primary voice will be 100% (127/128) of original and that of the secondary voice will be 0%. 127 is the opposite. | |
Overlay Volume Balance Slide | 3 | length: byte, balance: byte (0-127) | When | |
Turn On Alternate Voice | 2 | release_rate: byte (0x00-0x1f) | This instruction allows subsequent notes to be played on two alternating channels. At the same time, the ADSR release rate will be set to the specified value. A free voice channel is required to work. Check "Opening - Bombing Mission", "Tifa's Theme" and "Fortress of the Condor" for actual usage. | |
Turn Off Alternate Voice | 1 | |||
Unimplemented | 1 | Code-referenced to 0xA0. Should not be used. | ||
Time Signature | 3 | ticks_per_beat: byte, beats_per_measure: byte | Note that two parameters can be 0. This pattern is used for initialization. | |
Measure Number | 3 | measure: short | ||
Unimplemented | 1 | Code-referenced to 0xA0. Should not be used. |