EasyManua.ls Logo

Commodore 128 - The PLAY Statement

Commodore 128
448 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
where n is a digit between 0 and 255 (and 255 is the fastest
tempo). If you do not specify the TEMPO statement in your
program, the Commodore 128 automatically sets the tempo to 8.
Add this statement to your musical example program:
30 TEMPO 10
The PLAY Statement
Now its time to learn how to play the notes in your song. You
already know how the PRINT statement works. You play the
notes in your tune the same way as PRINTing a text string to the
screen, except you use the PLAY statement in place of PRINT.
PRINT outputs text, PLAY outputs musical notes.
Here’s the general format for the play statement:
PLAYstring of synthesizer control
characters and musical notes
The total number of characters (including musical notes and
synthesizer control characters) that can be put into a PLAY
command is 255. However, since this exceeds the maximum
number of characters (160) allowed for a single program line in
BASIC 7.0, you have to concatenate (that is, add together) at
least two strings to reach this length. You can avoid the need to
concatenate strings by making sure your PLAY commands do
not exceed 160 characters, i.e., one program line in length. (This
is equivalent to four screen lines in 40-column mode, and two
screen lines in 80-column mode.) By doing this, you will produce
PLAY command strings that are easier to understand and use.
To play musical notes, enclose the letter of the note you want to
play within quotes. For example, here’s how to play the musical
scale:
40 PLAY CDEFGAB
This plays the notes C, D, E, F, G, A and B in the piano envelope,
which is envelope 0. After each time you RUN this example
program you are creating, hold down the RUN/STOP key and
press the RESTORE key to reset the synthesizer chip.
7-16

Table of Contents

Other manuals for Commodore 128

Related product manuals