Tuesday, April 03, 2007

18X: three examples


So finally, i have had a chance to unpack and muck around with my 18x starter pack. You can watch a quick video of three really basic little things i made just then. These examples are of:
  • a pitched sequencer, where the pot changes the pitch of certain notes in a little loop
  • direct pitch control
  • and tempo control, where the pot is controlling the note length on a minor arpeggio
It's only one minute long.
http://www.youtube.com/watch?v=-zBaQ2rVlNc

Here is the code for the three examples:


' ************************************************************
' * simple adc example to map a pot to sound pitch *
' ************************************************************

let b1 = 1 ' set length of sound / sampling interval

main:
readadc 0,b0 ' read value from pin 0
sound 7,(b0,b1) ' play a sound with length 10ms and pitch from pin 0
goto main ' loop forever


' ************************************************************
' simple adc to control the speed of an arpeggio *
' ************************************************************

let b1 = 1 ' set length of sound / sampling interval

main:
readadc 0,b0 ' read the value of pin 0
let b0 = b0 / 3 min 1 ' set b0 for an appropriate value for note length
let b1 = b0 * 3 / 2 max 255 ' another appropriate note length value
sound 7,(32,b0,48,b0,64,b1) ' play a minor arpeggio whose note lengths are determined by the input
goto main ' loop forever


' ************************************************************
' * simple adc with sequencer where a pot controls pitch *
' ************************************************************


main:
readadc 0,b0 ' read the value of pin 0 and set variable b0 to it
let b1 = b0 + 7 ' create a second variable related to the pin
sound 7,(200,50,b0,25,128,25,b1,50,b0,50,150,25,b1,25) ' play sequence
goto main ' loop forever