hn.today

Why This Obscure Audio Codec Is a Perfect Fit for the N64

phoboslab.org263 points31 comments
Screenshot of Why This Obscure Audio Codec Is a Perfect Fit for the N64

The N64’s limited cartridge capacity and 93 MHz CPU made long recorded music difficult: its usual ADPCM compression was relatively space-hungry, while MP3 and Opus decoding demanded too much processing for continuous gameplay. Dominic Szablewski found a better fit in ULC, a compact transform codec originally created for the Game Boy Advance. Like MP3, it uses the MDCT to represent audio frequencies, but avoids multiple bands and Huffman decoding. Instead, each coefficient uses a simple four-bit code, with special values for zero runs, quantizer changes, and noise filling - a feature that helps represent percussion efficiently. This straightforward format supports useful quality at low bitrates and is easier to decode than conventional transform codecs.

To run ULC efficiently on the N64, Szablewski moved the inverse transform and related work to the RSP, whose tiny 4 KB data and instruction memories and fixed-point-only vectors posed major constraints. He adapted the decoder to 16-bit Q1.14 arithmetic and a 1024-sample block size, then ported and optimized the RSP code. The resulting decoder handles 44.1 kHz stereo while using about 4% of CPU time and 5% of RSP time; quality and bitrate approach Opus, at roughly four times ADPCM’s complexity. A sparse index enables quick seeking, and the decoder is integrated into Libdragon. Its practical value is illustrated by a Half-Life N64 port that uses ULC to fit thousands of sound effects and dozens of music tracks on a 64 MB cartridge.

Read on phoboslab.org31 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Hardware

MeccanicOS

MeccanicOS

MeccanicOS is a keyboard-driven NixOS distribution designed to run from USB or install with full-disk encryption. It includes offline apps and drivers, a command bar, reproducible atomic upgrades, and optional local AI tools. (meccanicos.com)

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.