--- title: "OUAH! Sound Example" id: 63151 type: "computer_media" slug: "ouah-sound-example" url: "http://localhost/computer_media/ouah-sound-example/" markdown_url: "http://localhost/computer_media/ouah-sound-example.md" published_at: "2026-01-30T17:36:44+00:00" modified_at: "2026-04-03T07:57:58+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2026/01/ouah.png" excerpt: "A Byte Power demo fires up the AY sound chip with a single SOUND statement, then silences it on a keypress — minimal code, maximum bark." category: - name: "Archived Media" slug: "archived-media" taxonomy: "category" url: "http://localhost/category/archived-media/" post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" indiv: - name: "Kristian Boisvert" slug: "boisvert-kristian" taxonomy: "indiv" url: "http://localhost/indiv/boisvert-kristian/" genre: - name: "Sound" slug: "sound" taxonomy: "genre" url: "http://localhost/type/sound/" media_contents: - id: 63045 title: "Byte Power September 1986" type: "computer_media" url: "http://localhost/computer_media/byte-power-september-1986/" media_type: "Program" programmers: - name: "Kristian Boisvert" slug: "boisvert-kristian" taxonomy: "indiv" url: "http://localhost/indiv/boisvert-kristian/" mediadate: "1986" producer_company: - id: 25181 title: "Byte Power" type: "company" url: "http://localhost/company/byte-power/" images: - url: "http://localhost/wp-content/uploads/2026/01/ouah.png" article_media: - id: 63031 title: "Better Programming" type: "article" url: "http://localhost/article/better-programming-4/" media_type_tags: "Sound" --- # OUAH! Sound Example This program plays a short musical or sound effect using the AY-3-8912 sound chip, then waits for a keypress before silencing all sound generators. The SOUND command sequences configure the AY chip’s registers directly: registers 8–10 set channel volumes, register 7 controls the mixer (enabling tone/noise), registers 12–13 set the noise/envelope period, and registers 0–1 set channel A’s tone period. The REM statement on line 0 contains the title “OUAH!” and credits K. Boisvert and Byte Power (1986). The program uses PAUSE 0 to hold the sound until any key is pressed, after which register 13 is reset to stop the envelope generator. *** ## Program Structure The program is extremely compact, consisting of just four lines: 1. `0 REM` — Title and copyright banner embedded in a REM statement on line 0, a common technique to store metadata without affecting execution. 2. `10 SOUND` — Configures multiple AY-3-8912 registers in a single statement to produce a sound effect. 3. `20 PAUSE 0` — Halts execution indefinitely until a key is pressed, allowing the sound to play out. 4. `30 SOUND 13,0` — Resets envelope register 13 to silence the AY chip. ## AY-3-8912 Register Usage The `SOUND` statement on line 10 programs the following AY chip registers in sequence: | Register | Value | Function | | --- | --- | --- | | 8 | 0 | Channel A amplitude — set to 0 initially (envelope mode not yet active) | | 9 | 0 | Channel B amplitude — off | | 10 | 0 | Channel C amplitude — off | | 8 | 16 | Channel A amplitude — bit 4 set, enabling envelope generator control | | 7 | 62 | Mixer register — value 62 (0b00111110): Channel A tone enabled, others off | | 12 | 2 | Envelope period fine (low byte) | | 13 | 14 | Envelope shape — value 14 (0b1110): attack, alternate, hold; produces rising then sustaining envelope (“woof” shape) | | 0 | 200 | Channel A tone period fine (low byte) — sets a low-pitched tone | | 1 | 1 | Channel A tone period coarse (high byte) — combined with reg 0: period = 200 + 256 = 456, giving ~240 Hz | ## Notable Techniques - The paired `SOUND` register writes in a single statement exploit the TS2068’s ability to write multiple register/value pairs, avoiding multiple lines and saving memory. - Register 8 is written twice: first to 0 to reset it, then to 16 to engage envelope mode. This double-write within one `SOUND` call ensures a clean envelope trigger. - `PAUSE 0` without a subsequent `INKEY$` check is used purely to suspend the program while the AY chip’s envelope hardware plays autonomously — no CPU intervention needed during playback. - Line 0 for the REM is a well-known trick: line 0 is always the first line executed but also stores metadata conveniently at the top of the listing. - The title “OUAH!” is French onomatopoeia for a dog’s bark (“woof”), which matches the envelope shape chosen (register 13 = 14 produces a sharp attack with sustain). ## Source Code ``` 0 REM OUAH! WRITTEN BY K. BOISVERT ©1986 BYTE POWER 10 SOUND 8,0;9,0;10,0;8,16;7,62;12,2;13,14;0,200;1,1 20 PAUSE 0 30 SOUND 13,0 ```