PLAY

BASin

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.

StringFunction
a..g, A..GSpecifies 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.
OSpecifies the octave number to be used (followed by 0 to 8).
1..12Specifies the length of notes to be used.
&Specifies that a rest is to be played.
_Specifies that a tied note is to be played.
NSeparates two numbers.
VSpecifies the volume to be used (followed by 0 to 15).
WSpecifies the volume effect to be used (followed by 0 to 7).
USpecifies that volume effects are to be used in the string.
XSpecifies the duration of the volume effect (followed by 0 to 65535).
TSpecifies 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.
HSpecifies that the PLAY command must stop.
MSpecifies the channel(s) to be used (followed by 0 to 63).
YSpecifies that a MIDI channel is to be used (followed by 1 to 16).
ZSpecifies 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

Chapter 19.