| Hi people, I was wondering if anyone can help me. I am trying to play through an array of numbers (which are changing the pitch of the sin oscillator) using the down arrow key on the qwerty keyboard. Each time the key is pressed i want it to play the next number in the array and keep repeating through them each time the key is pressed. Below I have attempted this but it only seems to be playing the first number in the array and not the ones after it. Can anyone shed some light on this? Thanks Ben Code: ( var pitch; d = [62, 45, 66, 78, 78, 98, 45]; pitch = d.next.asFloat.midicps; Document.current.keyDownAction_({arg doc, key, modifiers, num; var mykey; mykey = num; num.postln; if(mykey == 63233,{ {EnvGen.kr(Env.perc(0.05, 0.2, 1, -4), doneAction:2) * SinOsc.ar(pitch, 0, 0.5)}.play; }) }) ) ( Document.current.keyDownAction_(nil); ) |