BBC BASIC for Windows
Programming >> BBC BASIC language >> basic sound http://bb4w.conforums.com/index.cgi?board=language&action=display&num=1268600524 basic sound
Post by leslie griffin on Mar 14th, 2010, 9:02pm
is there a way to get a program to flow normally while executing a sound command. Im getting quite good at moving my sprites arround the screen and detecting collisions but must keep the final parameter of the sound command very small because everything stops until it completes........thx Re: basic sound
Post by admin on Mar 14th, 2010, 10:17pm
is there a way to get a program to flow normally while executing a sound command.
Of course. Sounds are played asynchronously and sound 'events' are queued so that you can play (for example) music to accompany a program without it pausing.
The only time a SOUND statement will stall a program is if the queue for that channel is already full; you can test for that condition using ADVAL. If you only ever issue a SOUND statement when there is space in the queue for that channel, it won't stall. Conceptually you can do that using code such as the following:
Code:
IF ADVAL(-6) THEN SOUND 1,level,pitch,dur
For example suppose you were reading the sound parameters from DATA statements, you could then do:
Code:
IF ADVAL(-6) THEN
READ level,pitch,dur
SOUND 1,level,pitch,dur
ENDIF
It gets a little more complicated if you're using more than one channel, but hopefully you get the idea.