Skip to content

SID Note Trigger

Play a single note on the SID chip with gate control. The foundation of all SID audio.

Taught in Game 1, Unit 1 sidaudiomusicsound

Overview

Trigger a note by setting frequency, waveform, and ADSR envelope, then toggling the gate bit. The gate-on starts the attack phase; gate-off triggers release. This is the core technique for all SID sound — music and effects both build on this foundation.

Code

; =============================================================================
; SID NOTE TRIGGER
; Play a single note on voice 1
; Taught: Game 1 (SID Symphony), Unit 1
; CPU: ~50 cycles | Memory: ~60 bytes
; =============================================================================

SID_BASE    = $D400

; Voice 1 registers
SID_V1_FREQ_LO  = SID_BASE + $00
SID_V1_FREQ_HI  = SID_BASE + $01
SID_V1_PW_LO    = SID_BASE + $02
SID_V1_PW_HI    = SID_BASE + $03
SID_V1_CTRL     = SID_BASE + $04
SID_V1_AD       = SID_BASE + $05
SID_V1_SR       = SID_BASE + $06

SID_VOLUME      = SID_BASE + $18

; Control register bits
GATE_ON     = %00000001
GATE_OFF    = %00000000
WAVE_PULSE  = %01000000
WAVE_SAW    = %00100000
WAVE_TRI    = %00010000
WAVE_NOISE  = %10000000

; Initialise SID for playing notes
init_sid:
    lda #$0F            ; Max volume
    sta SID_VOLUME

    lda #$08            ; Pulse width 50%
    sta SID_V1_PW_HI
    lda #$00
    sta SID_V1_PW_LO

    lda #$00            ; Attack=0, Decay=0 (instant)
    sta SID_V1_AD
    lda #$F9            ; Sustain=15, Release=9
    sta SID_V1_SR
    rts

; Play a note
; Input: A = frequency high byte, X = frequency low byte
play_note:
    stx SID_V1_FREQ_LO
    sta SID_V1_FREQ_HI
    lda #WAVE_PULSE | GATE_ON
    sta SID_V1_CTRL     ; Gate on - note starts
    rts

; Release the note (start release phase)
release_note:
    lda #WAVE_PULSE | GATE_OFF
    sta SID_V1_CTRL     ; Gate off - release begins
    rts

Usage:

    jsr init_sid

    ; Play middle C (approx)
    lda #$11            ; Frequency high
    ldx #$25            ; Frequency low
    jsr play_note

    ; ... wait for note duration ...

    jsr release_note    ; Let note fade out

Trade-offs

AspectCost
CPU~50 cycles to trigger
Memory~60 bytes
LimitationSingle voice; no music sequencing

When to use: Sound effects, learning SID basics, simple audio feedback.

When to avoid: Full music playback (use a music driver instead).

Vault: The SID Chip | Commodore 64

Evolution: Note Trigger → Envelope ShapesMusic Driver