Skip to content
Techniques & Technology

Audio Programming

Sound from code

Audio programming on vintage hardware demanded intimate knowledge of sound chips, precise timing, and clever techniques to achieve musical results.

commodore-64sinclair-zx-spectrumcommodore-amiganintendo-entertainment-system soundprogrammingmusic 1977–present

Overview

Audio programming on 8-bit and 16-bit systems wasn't about calling playSound() — it meant directly manipulating sound chip registers. Programmers set frequencies, waveforms, and envelopes register-by-register. The SID chip wanted specific register sequences with precise gate timing; the AY-3-8910 had different demands; the NES's APU another approach entirely; Paula's DMA-driven sample playback yet another. Understanding the hardware was essential.

This entry is the umbrella overview. For the driver software that orchestrates audio, see Sound Drivers; for interrupt timing, Interrupt-Driven Music; for specific techniques, the linked technique entries below.

Fast facts

  • Level: Direct hardware register manipulation (no abstractions).
  • Timing: Almost always interrupt-driven, frame-synchronised at 50/60 Hz.
  • Chips: SID (C64), AY-3-8910/12 (Spectrum 128K, MSX, Amstrad), Paula (Amiga), APU (NES), YM2612+SN76489 (Mega Drive), TIA (Atari 2600), POKEY (Atari 8-bit).
  • Techniques: Arpeggios, envelopes, filter sweeps, PWM, sample playback.
  • Output: Music, sound effects, digitised samples, voice synthesis.

Platform approaches

PlatformChipProgramming style
C64SID 6581 / 8580Three-voice synth: pulse / triangle / saw / noise / ring-mod / sync; built-in filter; ADSR per voice
ZX Spectrum 128KAY-3-8912Three square + noise; hardware envelope; software arpeggios for chords
NES2A03 APUTwo pulse + triangle + noise + DPCM (samples); sweep unit on pulse channels
AmigaPaulaFour 8-bit DMA samples; no synth — sample-based; software pitch shift; LED low-pass filter
Mega DriveYM2612 + SN764896 FM channels + 4 PSG; DAC mode for sample percussion
SNESSPC700 + DSP8-channel BRR-encoded samples; on-board DSP coprocessor
Atari 2600TIATwo square channels; 5-bit period control; few melodic options
Atari 8-bit / 5200POKEYFour channels; quirky distortion modes; 16-bit mode possible

Common techniques

Direct-hardware audio programming relies on a small toolkit of techniques shared across platforms:

TechniquePurposePlatforms
ArpeggioFake chords by rapid note cyclingAll — see Arpeggio
Volume envelopesSoftware ADSR or per-frame volume scalingAll non-SID platforms; SID has hardware ADSR
Pulse-width modulationVary square-wave duty for timbral motionSID, NES (limited to 4 presets)
Filter sweepsAnimate cutoff for evolving timbresSID only — others lack filters
Vibrato / pitch modulationLFO-style frequency variationAll
Sample playbackDigitised sound bytes streamed at variable ratePaula, NES DPCM, MD DAC, all 16-bit+
Software mixingMultiple voices on a single channelNES DPCM, Atari 2600 (rare)
Hardware-envelope tricksAY's envelope generator used as sound sourceAY chips

Per-frame structure

The standard pattern: a music driver runs in a 50/60 Hz timer interrupt:

each interrupt tick (50 Hz on PAL):
    update_music_driver()         # advance pattern position
    for each channel:
        apply_envelope()           # ADSR, volume curves
        apply_pitch_modulation()   # vibrato, slides, arpeggio
        write_to_chip_registers()  # actually program the hardware
    handle_sound_effects()         # SFX overlay; may interrupt music channels

Per-frame rates of 50 or 60 Hz become the music's tick rate — most C64 / NES songs run at one row per ~6 ticks (~8 Hz row rate at 50 Hz IRQ), giving a typical tempo around 120 BPM.

Composing for hardware

Composers worked in two main idioms:

Tracker workflow

Visual grid of rows × channels with hex-encoded note + effect data per cell. Each row triggers a tick of changes. Standard on Amiga (ProTracker), modern C64 / NES homebrew (GoatTracker, FamiTracker).

MML (Music Macro Language)

Text-based note entry — c4 d4 e4 f4 g4 a4 b4 >c4 etc. Common in Japanese 8-bit and 16-bit development; PC-88, MSX, Famicom dev tools all had MML toolchains.

Direct programming

The composer is also the programmer; music is hand-written in assembly with calls to set chip registers. Common in early arcade games and early home games before tracker tools matured.

Specific technique pages

For deep dives on the major audio techniques:

See also