PLAY
Statement/Command
PLAY outputs multi-channel sound effects and music using the 128k Spectrum's AY-3-8912 sound chip. PLAY is a 128k command and as such introduces certain limitations to the BASIC you can use.
How to use PLAY
PLAY may be used as a direct command but is normally used to form a statement in a program. It is commonly followed by one to three string values, and up to eight if being used to control a MIDI device, for example
10 PLAY "ccc","ⅇ","&&g;"
The values following PLAY must equate to strings, and must contain specific characters. Musical notes are represented by their alphabetical names, with the current octave in lower-case, with upper-case representing one octave higher.
Note lengths are measured in crotchets, and may range from 1 to 9. Notes to be played in triplets (three notes played in the time of two) are preceded by 10, 11 and 12 for triplets in semi-quavers, quavers, and crotchets.
Command characters in a PLAY string
Music performed by the PLAY command can be interspersed with command characters which are single upper-case letters usually followed by a number. A command character will affect all music in that channel from that point onwards.
The following table summarises the Command Characters.
String | Function |
a..g, A..G | Specifies the pitch of the note within the current octave range. |
$ | Specifies that the note which follows must be flattened. |
# | Specifies that the note which follows must be sharpened. |
O | Specifies the octave number to be used (followed by 0 to 8). |
1..12 | Specifies the length of notes to be used. |
& | Specifies that a rest is to be played. |
_ | Specifies that a tied note is to be played. |
N | Separates two numbers. |
V | Specifies the volume to be used (followed by 0 to 15). |
W | Specifies the volume effect to be used (followed by 0 to 7). |
U | Specifies that volume effects are to be used in the string. |
X | Specifies the duration of the volume effect (followed by 0 to 65535). |
T | Specifies the tempo of the music (followed by 60 to 240). |
( ) | Specifies that the enclosed phrase is to be repeated. |
! ! | Specifies that the enclosed text is to be skipped over. |
H | Specifies that the PLAY command must stop. |
M | Specifies the channel(s) to be used (followed by 0 to 63). |
Y | Specifies that a MIDI channel is to be used (followed by 1 to 16). |
Z | Specifies MIDI programming code (followed by code number). |
For further details, see also Chapter 19 of the Sinclair BASIC manual.
Format
- PLAY str-expr [,str-expr] [,str-expr]
See also