# Skill: SID 6581 Sound Programming ## Use this skill when The task involves music, sound effects, SID registers, waveforms, ADSR envelopes, filters, volume, or paddles. ## SID base SID base: `$D400` / `54272`. Each of the three voices uses 7 registers: | Voice | Base decimal | Base hex | |---|---:|---:| | Voice 1 | 54272 | `$D400` | | Voice 2 | 54279 | `$D407` | | Voice 3 | 54286 | `$D40E` | Per voice: | Offset | Purpose | |---:|---| | +0 | Frequency low | | +1 | Frequency high | | +2 | Pulse width low | | +3 | Pulse width high nybble | | +4 | Control: gate, sync, ring, test, waveform | | +5 | Attack/decay | | +6 | Sustain/release | Global/filter registers: | Decimal | Hex | Purpose | |---:|---:|---| | 54293 | `$D415` | Filter cutoff low bits | | 54294 | `$D416` | Filter cutoff high bits | | 54295 | `$D417` | Resonance/filter voice routing | | 54296 | `$D418` | Filter mode and master volume | | 54297 | `$D419` | Paddle X / ADC 1 | | 54298 | `$D41A` | Paddle Y / ADC 2 | | 54299 | `$D41B` | Voice 3 oscillator output | | 54300 | `$D41C` | Voice 3 envelope output | ## Waveform bits in control register | Bit/mask | Meaning | |---:|---| | `$01` | Gate | | `$02` | Sync | | `$04` | Ring modulation | | `$08` | Test | | `$10` | Triangle | | `$20` | Sawtooth | | `$40` | Pulse | | `$80` | Noise | ## Simple BASIC tone ```basic 10 S=54272 20 POKE S+24,15:REM VOLUME 30 POKE S+5,9*16+0:REM ATTACK/DECAY 40 POKE S+6,15*16+8:REM SUSTAIN/RELEASE 50 POKE S,37:POKE S+1,17:REM FREQUENCY 60 POKE S+4,17:REM TRIANGLE + GATE 70 FOR T=1 TO 500:NEXT 80 POKE S+4,16:REM GATE OFF ``` ## Agent checklist 1. Initialize volume at `$D418`. 2. Set frequency before opening gate. 3. Set ADSR before gate-on. 4. Clear gate for release. 5. Avoid leaving `TEST` bit set accidentally. 6. Mention SID 6581 vs 8580 sound differences when relevant.