Quick Chord

Date: 198x
Type: Program
Platform(s): TS 2068
Tags: Sound

Quick Chord is a subroutine library for the TS2068’s three-channel AY-3-8912 sound chip, providing ready-made GOSUB targets that program the chip’s tone registers to produce musical chords. Each subroutine uses a series of SOUND commands to set the coarse and fine pitch divider bytes for channels A, B, and C (registers 0–5), followed by a RETURN, so callers can drop the library into their own programs. Line 1000 initializes the AY chip’s mixer, envelope, and noise registers (registers 7–13) to enable all three tone channels, while line 1999 silences the chip by writing to registers 7–10. The library covers major, minor, diminished, and augmented chords across multiple octaves, including inversions and enharmonic equivalents such as D#/Eb. A lookup table in the REM at line 2 documents which register 7 mixer byte enables channel A, B, C, or combinations thereof.


Program Structure

The program is organized as a self-contained subroutine library with no main loop. Lines 1 and 2 are documentation only (a REM and a halting STOP with an embedded REM). The functional code begins at line 1000 and consists entirely of SOUND-register-programming sequences, each terminated by RETURN. A sentinel dummy chord at line 1900 and a silence routine at line 1999 bookend the chord definitions. Lines 9997–9998 provide a STOP guard and a SAVE command.

SOUND Register Mapping

The AY-3-8912 chip uses 14 registers (0–13). Each chord subroutine programs registers 0–5 as three pairs of coarse/fine tone divider bytes for channels A, B, and C respectively:

RegistersChannelRole
0, 1AFine (low byte), Coarse (high nibble) tone period
2, 3BFine, Coarse tone period
4, 5CFine, Coarse tone period

Line 1000 initializes the mixer and amplitude registers (7–13): register 7 sets the mixer byte to 56 (binary 00111000), enabling all three tone channels while disabling noise; registers 8–10 set channel amplitudes; registers 11–13 configure the envelope period and shape.

Chord Coverage

The library covers a wide range of chord types and roots:

  • Major chords: A, B, C, D, E, F, G, B♭ (lines 1005–1035, 1105)
  • Minor chords: A, B, C, D, E, F, G, F# (lines 1040–1065, 1110, 1115)
  • Diminished chords: B, D, E, F, D#/E♭ (lines 1070–1080, 1120–1122)
  • Augmented chords: D, F, G, C (lines 1085–1100)
  • Variants: C major inversion (1018), lower C major (1017), lower D# dim (1122), E♭ (1125), A♭ (1130)

Notable Techniques

The coarse byte for each channel is almost always 0 or 1, meaning all pitches fall within the lower two octaves of the AY chip’s range. The high byte (odd register) value of 1 indicates frequencies that require a 12-bit divider value greater than 255, pushing those notes into a lower register. Line 1017 and 1065 demonstrate this with coarse values of 1, producing notes roughly an octave below their counterparts.

The REM comment at line 2 documents the register 7 mixer byte values for enabling individual or combined channels: 62 (A only), 61 (B only), 59 (C only), 60 (A+B), 58 (A+C), 57 (B+C), and 56 (A+B+C). This is useful reference data for callers who wish to use fewer than three voices.

Line 1900 is an explicit dummy RETURN with no SOUND statements, intended as a no-op chord to provide timing or structural regularity in calling programs without producing any audio change.

Anomalies and Observations

  • Line 1045 (F minor) omits the final 5,0 argument present in all other subroutines, leaving register 5 (channel C coarse) at whatever value it held previously. This is a minor bug that could cause pitch inconsistency on channel C.
  • Line 1125 (E♭) uses identical register values to line 1018 (C major inversion), suggesting either a duplicate or an intentional enharmonic reuse.
  • The SOUND commands use semicolons as separators between register/value pairs on a single line, which is the correct multi-argument syntax for chaining register writes efficiently without re-invoking the keyword.
  • The program has no input handling or user interface; it is purely a library designed for inclusion in other programs via GOSUB.

Source Code

    1 REM to add to program for  chording beeps;GOSUB CHORD AFTERGOSUB 1000(SOUND ON);THEN BEEP; GOSUB NEXT CHORD OR 1999 TO OFF THE SOUND.
    2 STOP :REM to enable Channel A:}7,62;B-SOUND 7,61;C-SOUND 7,59;A & B-SOUND 7,60;A & C-SOUND 7,58;B & C-SOUND 7,57;A,B,C--\{20}\{1}SOUND 7,56 MOST FREQUENT\{20}\{0}
 1000 SOUND 7,56;8,12;9,12;10,16;11,5;12,5;13,13:RETURN :REM ON
 1005 SOUND 0,248;1,0;2,197;3,0;4,165;5,0:RETURN :REM A MAJ
 1010 SOUND 0,221;1,0;2,175;3,0;4,147;5,0:RETURN :REM B MAJ
 1015 SOUND 0,209;1,0;2,165;3,0;4,139;5,0:RETURN :REM C MAJ
 1017 SOUND 0,162;1,1;2,75;3,1;4,23;5,1:RETURN :REM LOWER C MAJ
 1018 SOUND 0,165;1,0;2,139;3,0;4,104;5,0:RETURN :REM C MAJ chord inversion egc--hi & sweet
 1020 SOUND 0,186;1,0;2,147;3,0;4,124;5,0:RETURN :REM D MAJ
 1025 SOUND 0,165;1,0;2,131;3,0;4,110;5,0:RETURN :REM E MAJ
 1030 SOUND 0,156;1,0;2,124;3,0;4,104;5,0:RETURN :REM F MAJ
 1035 SOUND 0,139;1,0;2,110;3,0;4,93;5,0:RETURN :REM G MAJ 
 1040 SOUND 0,209;1,0;2,175;3,0;4,139;5,0:RETURN :REM C MINOR (FLAT THE 3RD ANY MINOR)
 1045 SOUND 0,156;1,0;2,131;3,0;4,104:RETURN :REM F MINOR 
 1050 SOUND 0,186;1,0;2,156;3,0;4,124;5,0:RETURN :REM D MINOR D FNATURAL A
 1055 SOUND 0,248;1,0;2,209;3,0;4,165;5,0:RETURN :REM A MIN
 1060 SOUND 0,165;1,0;2,139;3,0;4,110;5,0:RETURN :REM E MIN
 1065 SOUND 0,23;1,1;2,234;3,0;4,186;5,0:RETURN :REM G MIN
 1070 SOUND 0,221;1,0;2,186;3,0;4,156;5,0:RETURN :REM B DIMINISHED FLAT 3RD & 5TH
 1075 SOUND 0,165;1,0;2,139;3,0;4,117;5,0:RETURN :REM E DIM
 1080 SOUND 0,186;1,0;2,156;3,0;4,131;5,0:RETURN :REM D DIM
 1085 SOUND 0,156;1,0;2,124;3,0;4,98;5,0:RETURN :REM F AUGMENTED(MAJOR SHARP THE 5TH)
 1090 SOUND 0,186;1,0;2,147;3,0;4,117;5,0:RETURN :REM D AUG
 1095 SOUND 0,23;1,1;2,221;3,0;4,175;5,0:RETURN :REM G AUG
 1100 SOUND 0,209;1,0;2,165;3,0;4,131;5,0:RETURN :REM C AUG
 1105 SOUND 0,234;1,0;2,186;3,0;4,156;5,0:RETURN :REM B FLAT MAJ
 1110 SOUND 0,221;1,0;2,186;3,0;4,147;5,0:RETURN :REM B MIN
 1115 SOUND 0,147;1,0;2,124;3,0;4,98;5,0:RETURN :REM F# MIN
 1120 SOUND 0,175;1,0;2,117;3,0;4,124;5,0:RETURN :REM D# DIM OR Eb DIM
 1122 SOUND 0,95;1,1;2,39;3,1;4,248;5,0:RETURN :REM D# DIM(D#F#A)lower version
 1125 SOUND 0,165;1,0;2,139;3,0;4,117;5,0:RETURN :REM Eb
 1130 SOUND 0,7;1,1;2,209;3,0;4,175;5,0:RETURN :REM Ab
 1900 RETURN :REM DUMMY CHORD TO REGULATE DATA
 1999 SOUND 7,63;8,0;9,0;10,0:RETURN :REM OFF
 9997 STOP 
 9998 SAVE "QUIKCORD" LINE 1

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.