Why an obscure audio codec is a perfect fit for the N64
The Ultra Low Complexity Codec (ULC), a little-known transform codec created by Aikku93, plays 44100 Hz stereo at near-Opus bitrates while using about 4% of the N64's CPU time. The console's original options for stored audio were dire: cartridge space was scarce, time on the 93 MHz CPU was limited, and Nintendo long guarded the RSP[1], the vector co-processor it reserved for its own graphics and sound tasks. Libultra transparently played back audio compressed with ADPCM[2], cutting the space for a sample by a factor of 4, yet a 5-minute stereo track at 44100 Hz still lands at about 12MB — more than the 8MB Mario 64 ROM, when the biggest N64 games were 64MB — so games sequenced short samples like a tracker; when Nintendo later let a few developers write RSP code directly, Conker's Bad Fur Day decoded MP3 for its many speech samples, but the cost hurt the frame rate and ruled out continuous music during gameplay.
The open source Libdragon library decodes ADPCM on the RSP in real time, and Giovanni Bajo built a real-time RSP-accelerated Opus decoder for it, but Opus remains too slow for gameplay; the author's game Xibalba 64 fills about 31MB of its 32MB ROM with just 15 minutes of ADPCM music. QOA would improve on ADPCM only slightly, since each sample depends on the previous decoded sample and vectorizes poorly, but a Game Boy Advance demo that plays recorded music at 70kbps — less than a typical MP3, at comparable quality — on a 16 MHz ARM CPU with no vector instructions led the author to ULC; Aikku93 wrote its decoder in ARM assembly and has steadily improved the codec since 2019, all under a permissive license. Like MP3, ULC transforms slices of PCM data into the frequency domain with the Modified Discrete Cosine Transform (MDCT[3]), but it is full-band and replaces Huffman entropy coding with a nibble-based syntax in which each coefficient fits in 4 bits and reserved values signal zero runs, quantizer changes and noise fill. Unpacking a block of coefficients takes about 150 lines of C, noise fill benefits cymbals, hi-hats and snare drums that MP3 must encode as quasi-random coefficients, and ULC stays usable down to 16kbps.
The author compiled the ULC reference decoder for the N64 as a proof of concept, but it kept the CPU busy since nothing ran on the RSP, so the IMDCT has to move there — yet the RSP has only 4096 bytes of data memory and 4096 bytes of instruction memory, with vector math in 16-bit or 32-bit fixed point and no floats. ULC's default 2048-sample block, the size the codec was optimized for, does not fit, and the two workable options both arrive at 3072 bytes: 32-bit values with a 512-sample block, or 16-bit values with a 1024-sample block. The author refactored the decoder to 16-bit fixed point (Q1.14[4]) for less DMA traffic and faster RSP computation, accepting a higher noise floor.
Read the original phoboslab.orgDiscussion
Sources
-
phoboslab.org
The ULC Audio Codec is a Perfect Fit for the N64



