An 8-bit sound chip emulated from scratch, playing a procedurally composed song.
The chip has two pulse voices (an 8-step sequencer at 12.5, 25, 50 or 75 percent duty), a triangle stepping through a 32-step 4-bit staircase, and noise from a 15-bit linear feedback shift register with a long mode and a short metallic one, all clocked at 1.789773 MHz. Each output sample is the exact average of every channel's level over that sample's CPU cycles, then mixed through the chip's non-linear DAC curves and its 90 Hz and 440 Hz high-pass and 14 kHz low-pass filters. The tracker drives it the way real ones did: sixty times a second it reads the pattern, runs instrument envelopes and effects (0xy arpeggio, slides, vibrato, volume slide, duty and speed) and writes new register values, which are shown live. The song is composed from a seed: a chord progression, a triangle bass line, noise drums, arpeggiated chords and a motif-based lead with an echo voice.
Try it. Space plays or stops. With the cursor in a note column the keyboard is a piano (Z to M and Q to U, [ and ] change octave); in the other columns type hex digits, and Delete clears. Arrow keys and Tab move the cursor, click a cell to jump to it. Click a scope to mute its channel (Shift-click solos), click the duty icons to force a pulse duty cycle, and press F5 or NEW SONG for a different composition. Click once for sound.
Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.
Build a small chiptune tracker with JavaScript, the HTML canvas element and the Web Audio API. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.
Start simple:
- Write a tiny sound chip yourself in a ScriptProcessorNode or AudioWorklet that starts on the first click: two pulse wave voices with a selectable duty cycle (12.5, 25, 50 or 75 percent), a triangle voice that steps through 16 volume levels instead of being smooth, and a noise voice made from a 15-bit linear feedback shift register.
- Store a song as a pattern of 32 rows by 4 channels. Each cell holds a note (or nothing) and a volume. Advance one row every 6 ticks of a 60 Hz clock that you count in audio samples, so the music stays in time.
- Give each note a simple volume envelope that decays tick by tick, and make the noise voice play kick, snare and hi-hat sounds by changing its period and envelope.
- Draw the pattern as scrolling columns of text (like C-4 01 F) in a pixel font, with the playing row highlighted in the middle.
Once that works, make it beautiful:
- Add a small oscilloscope for each channel (record each voice's output into a ring buffer and trigger on a rising edge) and chunky pixel VU meters.
- Add the classic arpeggio effect: cycle the note through the root, +x and +y semitones on every tick to fake a chord on one channel.
- Let me edit cells with the keyboard (the bottom two letter rows as a piano), mute channels by clicking their scopes, and compose a short song procedurally from a chord progression so there is music right away.
Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as band-limited synthesis to remove aliasing, slides and vibrato, or exporting the song as a WAV file.