Pulse 1
chip off
A TypeScript library that is the NES's audio chip — the 2A03's APU — register by register: writes in, samples out. Every game's music reaches the speaker as writes to these 24 registers, so this plays any of them. Below, the library runs live in your browser: every control is a bit of a real register.
The chip starts silent. Play any key with the mouse, or from your keyboard — A W S E D F T G Y H U J K O L P ; play the keys under the coloured bar, Z / X move it an octave. Each note writes the period and the high byte that starts it. Or pick a sound beside a channel.
chip off
chip off
No volume at all — it sounds or it does not. An octave below a pulse at the same period.
chip off
chip off
1-bit samples read from cartridge memory: every bit steps a 7-bit output up or down by 2. The samples below are made on this page — or load your own, and it is encoded for the DMC in your browser.
1 bytes = 0.00 s at this rate
chip off
The registers as they are now. Register writes in, a finished buffer out. What you last played here, as code — play it or save it as WAV, rendered by the library in your browser.
import { renderWrites } from '@xromdev/apu';
const { samples, sampleRate } = renderWrites(
[
{ time: 0, address: 0x4015, value: 0x0F }, // enable: P1 P2 TRI NOI
{ time: 0, address: 0x4000, value: 0xB8 }, // duty 50%, volume 8, halt
{ time: 0, address: 0x4001, value: 0x08 }, // sweep off
{ time: 0, address: 0x4002, value: 0xFD },
{ time: 0, address: 0x4003, value: 0x08 }, // length 254 — starts the note
{ time: 0, address: 0x4004, value: 0x78 }, // duty 25%, volume 8, halt
{ time: 0, address: 0x4005, value: 0x08 }, // sweep off
{ time: 0, address: 0x4006, value: 0xA9 },
{ time: 0, address: 0x4007, value: 0x09 }, // length 254 — starts the note
{ time: 0, address: 0x4008, value: 0xFF }, // triangle: sounds until stopped
{ time: 0, address: 0x400A, value: 0xFD },
{ time: 0, address: 0x400B, value: 0x08 }, // length 254 — starts the note
{ time: 0, address: 0x400C, value: 0x36 },
{ time: 0, address: 0x400E, value: 0x06 }, // noise long mode, rate 6
{ time: 0, address: 0x400F, value: 0x08 }, // length 254 — starts the note
{ time: 0, address: 0x4010, value: 0x0F }, // DMC rate 15
{ time: 0, address: 0x4012, value: 0x00 }, // sample at $C000
{ time: 0, address: 0x4013, value: 0x00 }, // 1 bytes long
],
2 // seconds
);