Author Topic: Sound / AKAO  (Read 5306 times)

G

  • *
  • Posts: 104
  • , kupo.
    • View Profile
Sound / AKAO
« on: 2007-06-24 19:25:48 »
Me and Zidane_2 were reverse-engeneering AKAO sequence format for ff7.

*******************************
**********SEQUENCE**********
*******************************
AKAO sequence format consists of following sections:
1. Header:
   struct AkaoHeader
   {
      uint8_t magic[4];   // string "AKAO"
      uint16_t id;            // AKAO frame ID
      uint16_t length;     // frame length - sizeof(header)
      uint16_t unused1; // unused data in AKAO parser code
      uint32_t unused2; // unused data in AKAO parser code
      uint8_t unused3;   // unused data in AKAO parser code
      uint8_t unused4;   // unused data in AKAO parser code
   };

2. Channels info:
uint32_t with used only 24-bit - mask for used SPU channels (example: 0x00000003 - 11b, 11b means that there is only channel 1 & channel 2)

3. Array of N uint16_t offsets to channel sequence data, where N is channel count. Every channel offset counts from position of this offset number in AKAO frame.

4. Sequence data:
After array of pointers there is sequence data for every enabled channel.
For any channel there is only one sample that are playing using 14 different tones and configuration.
Sequence data consists of SPU "configuration" section and "stream" section.
Configuration section consists of random 1-byte control bytes with parameters (we can say, that "control byte" is "sound opcode"). Every opcode has it's own number of parameters. Every opcode constant is > then A0. Processing of opcodes is finished, when AKAO parser finds byte < A0. This byte and following bytes to the end of channel data is "stream" section. Stream section format isn't fully understood for now, but we are working on it ;). There is timing, tone and length information for playing a sample. As we see later, all sample has 14 "tones" for playing. If any byte of the stream section is < 14 * 0x0b it selects length and tone for loaded sample, maybe something else.

Example:
***** MAIN INFO *****
Filename: sensui.snd
Frame ID: 0x59
Frame Length: 44 bytes
Unknown Data 1:0x04
Unknown Data 2:0x22181296
Unknown Data 3:0x46
Unknown Data 4:0x28
Channels count: 2

***** CHANNELS INFO *****
Channel 0:
Length: 0x13
e8 a8 66 [(?Tempo) Parameter: 0x66a8]

ea 00 50 [Parameter: 0x5000]
SPU Right Reverb depth: 0x5000
SPU Left  Reverb depth: 0x5000

a8 0d [Volume A8 modifier: 0x0d]
aa 40 [Volume AA modifier: 0x40]
SPU Right volume: 0x0339
SPU Left  volume: 0x032c

c2
a1 0c [sample number]
a5 03
c8
stream data:
66 96 ca

Channel 1:
Length: 0x11
aa 40 [Volume AA modifier: 0x40]
a8 11 [Volume A8 modifier: 0x11]
SPU Right volume: 0x0437
SPU Left  volume: 0x0426

c2
c6
a1 15 [sample number]
a5 05
c8
stream data:
66 96 ca 00 00 00

*******************************
**********INSTRx.DAT**********
*******************************
This file contains data for each sample in INSTRx.ALL
   struct SampleIndex
   {
      uint32_t attack_offset;       // offset to begin of "attack" part of sample (actually for INSTR.ALL real offset is: attack_offset - 0xff0)
      uint32_t loop_offset;          // offset to begin of "loop?" part of sample (actually for INSTR.ALL real offset is: loop_offset - 0xff0)
      uint16_t parameters[4];    // unknown for now
      uint32_t tones[12];           // possible "tone" constants for sample
   };


Also I want to welcome a new developer Zidane_2 to Q-Gears! He is a great help in reverse-engeneering of AKAO format. He is a fan of FF9, so maybe FF9 support in the future, hehe ;)

P.S. If anyone has a time - clean up this info and add it to the Wiki.

halkun

  • Global moderator
  • *
  • Posts: 2097
  • NicoNico :)
    • View Profile
    • Q-Gears Homepage
Re: Sound / AKAO
« Reply #1 on: 2007-06-25 01:20:13 »
I forgot to add Zadine to Sourceforge!!!!!

Sorry, PM me with his login name again and I'll add him.

Hades

  • *
  • Posts: 43
    • View Profile
Re: Sound / AKAO
« Reply #2 on: 2007-07-19 15:06:44 »
Has this been added to the wiki yet? I cant seem to find it there.

G

  • *
  • Posts: 104
  • , kupo.
    • View Profile
Re: Sound / AKAO
« Reply #3 on: 2007-07-22 15:54:58 »
No, this info isn't on the wiki yet. I need password and time to add this to wiki. :-D

halkun

  • Global moderator
  • *
  • Posts: 2097
  • NicoNico :)
    • View Profile
    • Q-Gears Homepage
Re: Sound / AKAO
« Reply #4 on: 2007-07-22 21:49:28 »
PM me if you need access to the Wiki

Lag.Com

  • *
  • Posts: 28
  • Nyan-te na!
    • View Profile
    • Lag.Website
Re: Sound / AKAO
« Reply #5 on: 2007-08-29 17:10:03 »
In an older topic, you mentioned you had a utility to decode the samples in .ALL files; could I take a peek at the source? I've tried writing something similar in Python, but the samples that come out are garbage. Yes, I ran them through the ADPCM decoder first. :)

I'm actually trying to grab the samples out of the FF9 PSF files, but evidently this will take similar techniques.

G

  • *
  • Posts: 104
  • , kupo.
    • View Profile
Re: Sound / AKAO
« Reply #6 on: 2007-08-29 18:04:02 »
Actually programming FF9 sound is on queue. We will work on it after finishing FF7 sound support in Q-Gears.

http://q-gears.svn.sourceforge.net/viewvc/q-gears/trunk/src/utils/akao/src/ - there is current AKAO sources with sample loading and other sound-related code, we are working on. Actually this is working player for FF7 AKAO frames, but it isn't ready yet...

For dumping you'll need to load instrument data, load sample to channel and dump sample from channel to file. For reference look in AkaoParser::AerisTest(), or contact me by ICQ or PM