Maestromike
Member
Hi, I've scripted samples to play when the sustain pedal is released, which works perfectly, but occasionally the samples play when sustain pedal is pressed, which is driving me potty!! Here is the pedal code I've used (some taken from Nils' script), any help much appreciated, thanks!
on note
$l := search(%ids, 0)
if ($l # -1)
%ids[$l] := $EVENT_ID
%notes[$l] := $EVENT_NOTE
else
ignore_event($EVENT_ID) { just a safety precaution in case the polyphony would reach 512 }
end if
end on
on release
disallow_group($ALL_GROUPS)
if (%CC[64] >= 64)
{ ignore note-off when sustain pedal is pressed }
ignore_event($EVENT_ID)
else
$l := 0
while ($l <= num_elements(%ids)-1)
if (%ids[$l] # $NONE and %notes[$l] = $EVENT_NOTE)
note_off(%ids[$l])
%ids[$l] := $NONE
end if
inc($l)
end while
end on
on controller
if (%CC_TOUCHED[64] # 0 and %CC[64] < 64 and ($ENGINE_UPTIME-$last_note_on_time <= 2000))
if ($pedalsqueeks = 1) {keyswitch to activate pedal noises}
$randomsqueek := random(84,97)
play_note($randomsqueek,100,0,0)
end if
end if
if (%CC_TOUCHED[64] # 0 and %CC[64] < 64)
$l := 0
while ($l <= num_elements(%ids)-1)
if (%ids[$l] # $NONE and %KEY_DOWN[%notes[$l]] = 0)
note_off(%ids[$l])
%ids[$l] := $NONE
end if
inc($l)
end while
end if
end on