AMSTRAD cpc 6128 User Instruction page 417

Integrated computer/disc system
Hide thumbs Also See for cpc 6128:
Table of Contents

Advertisement

The sounds that you might expect from these SOU N D commands are not produced
until the first RE LEA S E command which allows the sounds on channels A and B to
play. After the delay, the sound on channel C is RE LEA SEd.
There is yet another method by which more than one sound can be made to
rendezvous. When a sound is added to a queue that has the hold bit set (64 added),
then it is not just that sound which is held, but all subsequent sounds sent to that
queue. If more than four further sounds are sent to the held queue, then the machine
will pause until the queue is released, perhaps by using a sub-routine that is called
after a fixed period of time (using AFT E R or EVE RY). However this is not a
particularly good method for using the sound system, as the program that contains
the sound commands may pause from time to time as the sound queues fill up. This is
also true if a lot oflong sounds are added in quick succession. Try this:
10 FOR a=1 TO 8
20 SOUND 1,100*a,200
30 NEXT
40 PRINT "heLLo"
run
You will notice that the word 'h ell
0'
does not appear instantly, but only after the
first three sounds. This is because program execution cannot continue until there is a
free space in the queue.
The BASIC contains an interrupt mechanism, rather like that used in the AFT E R
and EVE R Y commands, and in 0 N B REA K G 0 SUB. This enables you to specify a
sound playing sub-routine that is only called when a free space appears in the
required queue. Try this:
10 a=0
20 ON SQ(1) GOSUB 1000
30 PRINT a;
40 GOTO 30
1000 a=a+10
1010 SOUND 1,a,200
1020 IF a<200 THEN ON SQ(1) GOSUB 1000
1030 RETURN
run
You will notice that the program never pauses. The SOU N D command is only called
when channel A's queue (number 1) has a free slot. This condition is detected by the
ON S Q ( 1) GO SUB command in line
20.
The command initialises an interrupt
mechanism that will call the sound sub-routine when a free .slot appears in the
specified queue. Once ON SQ GOSUB has been used, it must be re-initialised,
and this is done by line
1020
in the sound sub-routine. In this example, the sound
sub-routine only re-initialises itself while the value of' a' is less than 200.
Chapter 9 Page 44
At your leisure ....

Advertisement

Table of Contents
loading

Table of Contents