=====Playing an arpeggio=====
//by Richard Russell, December 2014//\\ \\ If you want to play a sequence of short, rising, notes (for example from the chromatic scale) the most obvious way is something like this:
ENVELOPE 1,1,0,0,0,0,0,0,126,-4,0,-1,126,0
pitch = 100
FOR note = 0 TO 19
SOUND 1, 1, pitch, 2
pitch += 4
NEXT
The problem with this technique is that when each note is sounded the previous one is suddenly truncated, even though an ENVELOPE was used to give it a long release time. This happens because all the notes are played on the same **channel**, and it gives the end result a 'staccato' effect.\\ \\ To reduce this effect you can take advantage of the multiple SOUND channels available, for example the first note can be played on channel 1, the second on channel 2 etc.:
ENVELOPE 1,1,0,0,0,0,0,0,126,-4,0,-1,126,0
SOUND 2,0,0,2
SOUND 3,0,0,4
pitch = 100
FOR note = 0 TO 19
SOUND (note MOD 3) + 1, 1, pitch, 2
IF note<17 SOUND (note MOD 3) + &1001, 0, 0, 4
pitch += 4
NEXT
Each note is played for two 'sound periods' (normally 1/20 second each) and then allowed to decay for 4 'sound periods'; this is achieved by setting the 'hold' bit (H). To ensure that the notes are correctly 'interleaved' an initial period of silence is played on channels two and three, of 2 and 4 'sound periods' respectively.\\ \\ If you want to improve the effect even further, you can switch SOUND channel 0 from its normal 'noise' functionality to become a fourth tone channel:
*TEMPO 133
ENVELOPE 1,1,0,0,0,0,0,0,126,-4,0,-1,126,0
SOUND 1,0,0,2
SOUND 2,0,0,4
SOUND 3,0,0,6
pitch = 100
FOR note = 0 TO 19
SOUND (note MOD 4), 1, pitch, 2
IF note<16 SOUND (note MOD 4) + &1000, 0, 0, 6
pitch += 4
NEXT
(//My apologies to musical purists who may not feel that this is an arpeggio in the strict sense.//)