Hi Guys,
I'm not an expert, but in this simplified code there is an array that saves the note numbers when press the key, than play a note - the note number is the last saved position in the array, than message out the played note number, than decrase the counter when releasing the key.
if i delete the play_note line the messages is what i expected, but with the play_note command the first message is ok, but after all is 0.
if i put the message command in the on release than "array index out of bounds..." I don't understand, someone could explan it? Thanks.
I'm not an expert, but in this simplified code there is an array that saves the note numbers when press the key, than play a note - the note number is the last saved position in the array, than message out the played note number, than decrase the counter when releasing the key.
if i delete the play_note line the messages is what i expected, but with the play_note command the first message is ok, but after all is 0.
if i put the message command in the on release than "array index out of bounds..." I don't understand, someone could explan it? Thanks.
Code:
on init
message("")
declare $note_id
declare $counter := -1
declare %notes[128]
end on
on note
ignore_event($EVENT_ID)
$counter := $counter+1
%notes[$counter] := $EVENT_NOTE
$note_id := play_note(%notes[$counter], $EVENT_VELOCITY, 0, -1)
message(%notes[$counter])
end on
on release
$counter := $counter-1
end on