Difference between revisions of "FF7/PSX/Sound/AKAO sequence"

From Final Fantasy Inside
< FF7
Jump to navigation Jump to search
(Cosmetic change for sound opcode list)
Line 101: Line 101:
  
 
== Sound Opcode list ==
 
== Sound Opcode list ==
[[FF7/PSX/Sound/Opcodes/0xa0|0xA0 (Finish Channel)]]
 
  
[[FF7/PSX/Sound/Opcodes/0xa1|0xA1 (Load Instrument)]]
+
{| class="wikitable"
 
+
! Opcode
[[FF7/PSX/Sound/Opcodes/0xa8aa|0xA3 (Volume Modifier)]]
+
! Summary
 
+
! Length
[[FF7/PSX/Sound/Opcodes/0xa5|0xA5 (Pitch Divider)]]
+
! Operands
 
+
|-
[[FF7/PSX/Sound/Opcodes/0xa8aa|0xA8 (Channel Volume)]]
+
|[[FF7/PSX/Sound/Opcodes/0xa0|0xA0]]
 
+
|Finish Channel
[[FF7/PSX/Sound/Opcodes/0xa8aa|0xAA (Channel Pan)]]
+
|1
 
+
|
[[FF7/PSX/Sound/Opcodes/0xc8|0xC8 (Loop Point)]]
+
|-
 
+
|[[FF7/PSX/Sound/Opcodes/0xa1|0xA1]]
[[FF7/PSX/Sound/Opcodes/0xca|0xCA (Return to Loop Point)]]
+
|Load Instrument
 
+
|2
[[FF7/PSX/Sound/Opcodes/0xe8|0xE8 (Tempo)]]
+
|u8 instrument
 
+
|-
[[FF7/PSX/Sound/Opcodes/0xea|0xEA (Reverb Depth)]]
+
|[[FF7/PSX/Sound/Opcodes/0xa8aa|0xA3]]
 
+
|Volume Modifier
[[FF7/PSX/Sound/Opcodes/0xc2|0xC2 (Turn On Reverb)]]
+
|2
 
+
|u8 volume
[[FF7/PSX/Sound/Opcodes/0xfd|0xFD (Unknown)]]
+
|-
 
+
|[[FF7/PSX/Sound/Opcodes/0xa5|0xA5]]
[[FF7/PSX/Sound/Opcodes/0xfe|0xFE (Unknown)]]
+
|Set Octave
 
+
|2
[[FF7/PSX/Sound/Opcodes/0xb4|0xB4 (Unknown)]]
+
|u8 octave
 
+
|-
[[FF7/PSX/Sound/Opcodes/0xa0|0xE0 (Unimplemented, code-referenced to 0xA0)]]
+
|[[FF7/PSX/Sound/Opcodes/0xa8aa|0xA8]]
 
+
|Channel Volume
[[FF7/PSX/Sound/Opcodes/0xa0|0xE1 (Unimplemented, code-referenced to 0xA0)]]
+
|2
 
+
|u8 volume
[[FF7/PSX/Sound/Opcodes/0xa0|0xE2 (Unimplemented, code-referenced to 0xA0)]]
+
|-
 
+
|[[FF7/PSX/Sound/Opcodes/0xa8aa|0xAA]]
[[FF7/PSX/Sound/Opcodes/0xa0|0xE3 (Unimplemented, code-referenced to 0xA0)]]
+
|Channel Pan
 
+
|2
[[FF7/PSX/Sound/Opcodes/0xa0|0xE4 (Unimplemented, code-referenced to 0xA0)]]
+
|u8 pan
 
+
|-
[[FF7/PSX/Sound/Opcodes/0xa0|0xE5 (Unimplemented, code-referenced to 0xA0)]]
+
|[[FF7/PSX/Sound/Opcodes/0xc8|0xC8]]
 
+
|Loop Point
[[FF7/PSX/Sound/Opcodes/0xa0|0xE6 (Unimplemented, code-referenced to 0xA0)]]
+
|1
 
+
|
[[FF7/PSX/Sound/Opcodes/0xa0|0xE7 (Unimplemented, code-referenced to 0xA0)]]
+
|-
 
+
|[[FF7/PSX/Sound/Opcodes/0xca|0xCA]]
[[FF7/PSX/Sound/Opcodes/0xa0|0xFA (Unimplemented, code-referenced to 0xA0)]]
+
|Return to Loop Point
 
+
|1
[[FF7/PSX/Sound/Opcodes/0xa0|0xFB (Unimplemented, code-referenced to 0xA0)]]
+
|
 
+
|-
[[FF7/PSX/Sound/Opcodes/0xa0|0xFC (Unimplemented, code-referenced to 0xA0)]]
+
|[[FF7/PSX/Sound/Opcodes/0xe8|0xE8]]
 
+
|Tempo
[[FF7/PSX/Sound/Opcodes/0xa0|0xFF (Unimplemented, code-referenced to 0xA0)]]
+
|3
 
+
|u16 tempo
[[FF7/PSX/Sound/Opcodes/0xcd|0xCD (Unimplemented)]]
+
|-
 
+
|[[FF7/PSX/Sound/Opcodes/0xea|0xEA]]
[[FF7/PSX/Sound/Opcodes/0xd1|0xD1 (Unimplemented)]]
+
|Reverb Depth
 +
|3
 +
|u16 depth
 +
|-
 +
|[[FF7/PSX/Sound/Opcodes/0xc2|0xC2]]
 +
|Turn On Reverb
 +
|1
 +
|
 +
|}

Revision as of 17:39, 30 May 2020

Introduction

AKAO frames are most complicated frames in FF7 sound system. ("AKAO" is frame magic, probably developed by Minoru Akao, Square Enix sound programmer :) )

Frame is similar to MIDI sequence - it's custom tracker format for playing sequence sound, well tuned specially for PSX.

This frames are 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 frames are hard-wired in other files.


AKAO frame structure

Header (size: 16 bytes)

struct AkaoHeader
{
  static const uint8_t magic[4];  // "AKAO" C-string aka frame *MAGIC*
  uint16_t id;                    // frame ID, used for playing sequence
  uint16_t length;                // frame length - sizeof(header)
  uint16_t reverb_type;           // reverb type (range from 0 to 9)
  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)
  } timestamp;
};

Channel info (size: 4 bytes + 2 bytes * <channels count>)

struct AkaoChannelInfo
{
  uint32_t mask;                         // represents bitmask of used channels in this frame
  uint32_t start_offsets[num_channels];  // offsets to channel opcode data
};
int num_channels = 0;
while (int bit = 0; ((info.mask & 0xFFFFFF) & (1 << bit)) != 0; bit++)
  num_channels++;

First there is 32-bit number (offset 0x10), which represents bitmask of used channels in this frame.

After this frame, there is <channels count> offsets to channel opcode data counting from current offset. Each offsets is a relative offset based on the address *next to* the offset itself. (This is a general rule for early versions of AKAO to interpret relative offsets.)


Channel Commands [AKAO Opcodes]

Most complicated part.

For every channel in AKAO frame there is set of commands to perform. This is similar to Field opcodes. Here I'll call this sound commands "opcodes". Every opcode has it's own number of arguments (from no-arguments, to 3 arguments).

Example (home-created AKAO frame):

Header

41 4b 41 4f - AKAO string

34 12 - frame ID: 0x1234

16 00 - frame length 0x16 in hex or 22 in decimal

04 00 - reverb type: 4 (large studio)

96 12 18 22 46 28 - unknown data


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
0xA0 Finish Channel 1
0xA1 Load Instrument 2 u8 instrument
0xA3 Volume Modifier 2 u8 volume
0xA5 Set Octave 2 u8 octave
0xA8 Channel Volume 2 u8 volume
0xAA Channel Pan 2 u8 pan
0xC8 Loop Point 1
0xCA Return to Loop Point 1
0xE8 Tempo 3 u16 tempo
0xEA Reverb Depth 3 u16 depth
0xC2 Turn On Reverb 1