BEEP & SOUND Translator

Developer(s): Eric Boisvert
Date: 1987
Type: Program
Platform(s): TS 2068
Tags: Sound

This program will translate BEEP data to SOUND data and also SOUND data to BEEP data. It works on music data in the MUSIcomp format (MUSIcomp and MUSIcomp V1.1 from earlier Byte Power issues). You load the codes somewhere between 40000 and 65535, choose a direction, and give the start address, the length and the address for the translated data; the program reports the new length. BEEP data is one-third shorter than SOUND data. Two playback routines at lines 9000 (BEEP) and 9100 (SOUND) let you hear the result.

Written by Eric Boisvert, ©1987 Byte Power. Loading name TRANSL. Published on the Fall 1987 (Issue 8) tape of Byte Power. The magazine notes that it is in BASIC so it can be changed for data that is not MUSIcomp-compatible. The TAP file in this download also carries the 13,000-byte FIX IT code block that followed the program on the tape; it is the patch for “Just Another Spreadsheet!” described in the same issue, not part of the translator.

Program Analysis

Note table

Lines 70–120 build two 96-element arrays, f() and c(), from the frequencies of eight octaves of equal-tempered notes (32.703 Hz up to 7902.08 Hz). Each frequency becomes an AY tone period, 1750000/(16*f), split into fine (f) and coarse (c) bytes. The screen says “Sorting Data…” while this runs.

Data formats

  • SOUND data: three bytes per note, fine period, coarse period and duration; 254 is a rest and 255 ends the tune.
  • BEEP data: two bytes per note, a note number 1–96 and the duration, with the same 254 and 255 markers.
  • Sounds to beeps (lines 200–290) searches the table for a matching fine and coarse pair; beeps to sounds (lines 310–370) looks the note number up directly.

Playback

Line 9010 plays BEEP data with BEEP P/10,A-37, so note 37 (261.6 Hz) is middle C. Lines 9130–9140 play SOUND data by writing the AY registers directly through ports 245 and 246 (tone A period, volume 15, mixer 62), then silencing the channel after the duration.

Notable Techniques

  • Direct AY programming with OUT 245 (register select) and OUT 246 (data) instead of the TS2068 SOUND statement.
  • Long variable names such as START, LENGTH, ADDRESS and END used as plain variables.

Potential Issues

  • In sounds-to-beeps, a note whose period is not exactly in the table matches nothing; the loop at lines 230–240 then falls through and only the duration byte is written, leaving the note byte unset.
  • The playback routines always read from fixed addresses, 62000 for BEEP data and 55000 for SOUND data, not from the address just used for the translation.
  • The variable OC set in line 10 is never used.
  • The loops run two or three bytes past START+LENGTH, which is harmless when the data ends with the 255 marker.

Image Gallery

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