SOUND EFFECTS10 LET a$="M8UX350W507(((C)))": PLAY a$ : PAUSE 25 Using the PLAY commandIn the examples above, you will see that each time the PLAY command appears, it is followed by up to three different letters, each followed by a $ sign in a statement like PLAY a$,b$,c$ Each of these is the name of a string (a series of characters) which you have already given to the computer earlier in the program. The strings tell the Spectrum 128 which sounds to make. PLAY controls three separate sound channels called A, B, and C and there can be up to three strings, one for each channel. In the MUSIC example given above, a$ tells channel A to play the melody line, b$ tells channel B to play a harmony, and c$ tells channel C to play a bass part. In the SOUND EFFECTS example, only one noise is used at a time (although up to three can be), so each one is in channel A and the command is simply PLAY a$. In fact any of the channels can produce either a musical tone or noise, so you can mix sound effects in with your music (see Channel selection). Constructing stringsComposing music and sound effects on the Spectrum 128 is simply a matter of creating strings containing the information you want. You can see how this works in the MUSIC example above. Each string is created with the LET command, followed by the name of the string, and its contents enclosed in "" marks. Try this example, which plays just one note - an A. LET a$="a": PLAY a$ Any music program using PLAY also uses LET to tell it what to play, as you can see by looking at the earlier examples. The reason why these programs look more complicated than the example above is that the strings enclosed in the "" marks contain many letters and numbers to define a longer tune or more complex sound. Any musical sound has a pitch and duration. It also has a volume and tone quality. The strings in the earlier examples contain information about all of these. The summary below lists each possible command, and they are explained in detail opposite.
|