321 Description The sound generator has four separately controlled synthesis channels. Each can sound at one of 16 amplitudes, including ‘off’. The audio output is the sum of the channel outputs. Channels 1-3 each generate a square wave with programmable frequency. Channel 0 can produce noise (unpitched sound of pseudo-random structure) or a pulse waveform. The frequency of the pulsewave or period of the noise can be set to one of the three fixed options, or to the frequency of channel 1. The BASIC program generates each sound by initiating one or more ‘requests’ each of which may take the form of a musical note or a single effect and is directed to a specific channel.
If the destination channel is idle when a request requires it, the sound starts playing immediately. If a previous request is still being handled the new one is placed on a queue, where it waits until the current event is over (or past a critical stage – see ENVELOPE ). If the queue is full, the program waits. Separate queues are provided for the four channels, each of which can hold up to four requests, not counting the one currently being executed. The program can look at the state of any queue and flush any queue, but cannot find out or alter the state of the current event, except for flushing the whole queue.
The SOUND keyword is followed by four parameters, the first of which consists of four hexadecimal digits. Thus SOUND &HSFC,A,P,D Range Function H 0 or 1 Continuation S 0 to 3 Synchronisation F 0 or 1 Flush C 0 to 3 Channel number A –15 to 4 Amplitude or envelope number P 0 to 255 Pitch D 1 to 255 Duration The ‘H’ parameter allows the previous event on that channel to continue and if this is 1 the amplitude and pitch parameters of SOUND have no effect.
Because the dummy note is queued in the normal way, it can be used to ensure that the release segment of sound, which occurs after the duration is over and would otherwise be truncated by the next sounding event on the same channel, is allowed to complete.