Building Web-Based Audio Player for Obscure Audio Format

By Kenrick

Elevator Pitch

How hard could it be? Spoiler: It is hard.

This talk is about a journey of doing something that has never been done before. It involves project restarts, reverse engineering, and many eureka moments.

It is a web-based BRSTM audio player.

Description

BRSTM is an audio file format that are used on Nintendo Wii games and many others. This file format supports loop point in its metadata, but to properly play and loop, you need to download a special program.

What if there is a web-based audio player for this file format?

This is what the project is about.

The final player decodes the BRSTM file entirely on browser and plays it back using Web Audio API.

This talk will cover the journey in building this player, which involves project restarts, reverse engineering other open source projects, and lots of eureka moments.

Notes

The final project is basically an audio player of this “BRSTM” format on the web, which consists of two parts: decoding “BRSTM” into raw pulse-code modulation streams (“PCM”), and feeding that streams into Web Audio API to be outputted to the computer’s audio output device. The difficulty is also two fold: first is because there are so few information out there on how to decode BRSTM format (most articles out there just describe what a BRSTM file looks like, but no information on how to decode it), and second is on how to use Web Audio API when you already have the raw PCM streams (most tutorials out there didn’t cover this use case).

After piecing both solutions together, I got a working player, but to make it usable for everyday use, I have to implement basic audio player controls like play/pause button, time seeking, displaying current time, etc. And it is a difficult challenge to implement those using Web Audio API.

Takeaways include but not limited to:

  • Define the project scope before starting anything
  • Do research, lots of research
  • Don’t be afraid to read other’s codes, especially if theirs are open source
  • Web Audio API is difficult to use :(

References: