Summary
Highlights
The Mario 64 sound engine is incredibly advanced, capable of running complex sequences like an entire Tetris game as a sound effect. The engine, originally over 10,000 lines of code, plays audio at 240 frames per second, eight times faster than the game itself. This robust engine and its soundbank format were universally adopted across nearly all official N64 games, allowing for extensive sound manipulation and editing. Although its full capabilities were largely underutilized in Mario 64, it laid the groundwork for dynamic audio experiences.
Mario 64's sound effects function like mini-music sequences, utilizing the same playback code as the game's music. The game can play up to three sequences simultaneously: level music, jingles, and sound effects. Sound effects are not merely audio files but composed single-channel music sequences, allowing for adjustments in volume, panning, and tempo. This innovative approach significantly reduces storage space on the cartridge, as sound effects account for 26.5% of the game's storage. Many complex sound effects are built from simpler sounds, saving memory by sharing instruments.
The sound engine employs self-modifying code to achieve dynamic audio effects, such as the increasing pitch of red coins. This involves the sound effect file manipulating its own pitch-shifting parameters based on game events. Similar techniques are used for room echoes, secret-revealing sounds, and even bird calls. Charles Martinet, Mario's voice actor, voiced multiple characters beyond Mario by having his voice clips remixed and reused for various in-game entities like Bowser, the Bully, and even certain sound effects. This creative reuse further optimized cartridge space.
The rare and eerie 'Boo-Loth' sound in Big Boo's Haunt is actually a bug related to the wind sound effect. The wind sound has multiple layers, one of which gets permanently assigned to a continuous note. When exiting the mansion, the game's sound function stops, but a two-frame delay before fully disabling the sound causes the first layer to incorrectly play the 'Boo-Loth' instrument at a lower pitch, creating the creepy effect. This highlights how complex interactions within the sound engine can lead to unexpected, yet memorable, glitches.
The intricate sound playback system allows for sophisticated dynamic music, as demonstrated by Sauron's credits theme remix that adapts to different levels. To overcome the 16-channel limit of the tracker format, a clever trick is employed where the sequence has synchronization points, allowing only two of eight themes to run at any given time. This also explains why jingles play when skipping sections or falling: they cover up the technical limitation of not having a sequence in a ready state. The sound I/O system, essentially a simplistic programming language, enables this complex scripting. While technically 'Turing complete', allowing for complete programs like Tetris to be implemented, its simplicity makes such tasks unreasonable.
The video creator successfully rewrote the Mario 64 sound engine, reducing its size from 56 kilobytes to under 12 kilobytes for improved memory and performance in their mods. This rewrite prioritizes essential music playback functionality over the complex programming language capabilities of the original engine. The creator aims to replace all of Nintendo's original code in Mario 64 to develop a fully custom engine, offering significant memory and performance benefits and the ability to pivot to their own intellectual property if necessary.