Thealexbarney / VGAudio

A library for encoding, decoding, and manipulating audio files from video games.
MIT License
219 stars 37 forks source link

Update: ADX 010 Editor Template #132

Open Sewer56 opened 2 years ago

Sewer56 commented 2 years ago

Summary

Made a number of small changes to the ADX template.
These are based off my personal disassembly of the Windows port of Sonic Riders, a 2006 hoverboard racing game that uses CRI. These changes are based on my disassembly of the header parsing code.

I made this changes while working on ADX-ID3, a fun weekend project to add ID3 tag support to ADX.

Regarding AINF

I noticed the template had a mention of the 'AINF' and 'CINF' structures. While I couldn't find any test files using those headers (I've tried a fair bit), I did find the code that parses it while investigating the loop stuff.

It appears the logic is the following.

int loopOffset = version == 4 ? 32 : 20; // Start of loop header.
int ainfOffset = loopOffset + 4; // Start of loop data.
if (loopEnabled)
    ainfOffset += 20;

Game code specifically uses 32 and 20. There isn't anything to compensate for the channels and the official CRI encoding tools never supported >2 ch for ADX as far as I'm aware.

It comes after the Loop structure if the enable flag is set, and in place of the loop structure if the flag is not set.
No sample files to doublecheck, so didn't add that part in.

Thealexbarney commented 2 years ago
  • Removed LoopCount. It's a simple flag that only accepts a value of 1. Any other value is ignored.
  • First short of the Loop structure is ignored by the application. Probably reserved. Marked as such.

Sonic Riders might not use these values, but that doesn't mean they're not part of the ADX format or that no other applications use them

uint32 SampleRate;

This value is actually used as a signed value

Sewer56 commented 2 years ago

This value is actually used as a signed value

I didn't even notice I made this change when submitting the PR, seems that you are indeed correct, I doublechecked the parsing code, that is my mistake.


Regarding the rest, do you know any sample files or games that might interpret these values otherwise? The implementation in the Windows application I was looking up doesn't even read the short in question and it was pretty late in the lifespan of the original CRI Tools; so I can't imagine that stuff might have changed between different platforms.

Thealexbarney commented 2 years ago

Regarding the rest, do you know any sample files or games that might interpret these values otherwise?

I couldn't name any games that use multiple loops, but it was part of whatever spec CRI had for ADX. They did remove support for more than a single loop at some point, but I don't know when.