Overview
A web-based tool that allows users to create and modify soundtrack information from the game Kula Quest. Each soundtrack in the game is stored inside of .XA files, where each file contains 4 soundtracks interleaved together. Additionally, the duration of each soundtrack is hardcoded inside the game’s compiled executable, so my tool contains a feature that allows these durations to be adjusted to properly fit imported soundtracks.
The process for encoding a soundtrack into the an interleaved XA file goes as follows:
- FFmpeg WASM is used to transcode the uploaded soundtrack as a PCM 16-bit signed little endian WAV file, with a sample rate of 37800 Hz which is the highest supported frequency.
- The output from FFmpeg is then parsed as a raw PCM buffer, omitting the WAV header information and preparing it for conversion.
- The resulting buffer is then encoded into the XA format using the libpsxav library. Originally written in C, I compiled this library to Web Assembly.
- Once all of the soundtracks are encoded into this format, they’re interleaved into one .XA file sector by sector.
Patching the track durations is pretty simple, and are stored in a table near the end of the executable file. However, I have to store the offset to this table in each version of the game. A more robust approach would be to utilize signature detection to automatically find the table in every version of the game, so I may implement that in the future if possible.