on init declare const $INACTIVE := 0 declare const $KEYSWITCH := 1 declare const $MIDICC := 2 declare const $VELOCITY := 3 declare const $SPEED := 4 declare const $LEGATO := 5 declare const $NOTLEGATO := 6 declare const $REPETITION := 7 declare const $NOTREPETITION := 8 declare const $PEDALDOWN := 10 declare const $PEDALUP := 11 declare const $TOGGLE := 12 declare const $KEYRANGE := 13 declare const $LOGIC_LASTOR := 0 declare const $LOGIC_ALLAND := 1 declare const $LOGIC_MIDDLEOR := 2 declare const $NLOGIC := 3 declare ui_label $label1(1,1) declare ui_label $label2(1,1) declare ui_label $label3(2,1) declare ui_label $label4(2,1) declare ui_menu $logic declare ui_menu $ks_duration declare ui_value_edit $KS(-1,127,1) declare ui_button $learn declare ui_value_edit $min(0,100,1) declare ui_value_edit $max(100,2000,1) declare $last_time declare $last_note declare $last_id declare $bpm declare $new_bpm declare $condition declare $is_keyswitch declare $is_outside_note_range declare %settings[5] $KS := -1 $min := 10 $max := 700 declare ui_menu $control1 declare ui_menu $control2 declare ui_menu $control3 declare ui_menu $control4 declare ui_value_edit $lower1(0,800,1) declare ui_value_edit $lower2(0,800,1) declare ui_value_edit $lower3(0,800,1) declare ui_value_edit $lower4(0,800,1) declare ui_value_edit $upper1(0,1500,1) declare ui_value_edit $upper2(0,1500,1) declare ui_value_edit $upper3(0,1500,1) declare ui_value_edit $upper4(0,1500,1) declare ui_value_edit $CC_KS1(0,127,1) declare ui_value_edit $CC_KS2(0,127,1) declare ui_value_edit $CC_KS3(0,127,1) declare ui_value_edit $CC_KS4(0,127,1) declare ui_button $learn1 declare ui_button $learn2 declare ui_button $learn3 declare ui_button $learn4 declare ui_button $active1 declare ui_button $active2 declare ui_button $active3 declare ui_button $active4 declare $learning_state1 declare $learning_state2 declare $learning_state3 declare $learning_state4 add_menu_item($control1, "------------", $INACTIVE) add_menu_item($control1, "" & "Key switch", $KEYSWITCH) add_menu_item($control1, "" & "Velocity", $VELOCITY) add_menu_item($control1, "" & "Speed(bpm)", $SPEED) add_menu_item($control1, "" & "MIDI CC", $MIDICC) add_menu_item($control1, "" & "Legato", $LEGATO) add_menu_item($control1, "" & "Not legato", $NOTLEGATO) add_menu_item($control1, "" & "Repetition", $REPETITION) add_menu_item($control1, "" & "Not repetition", $NOTREPETITION) add_menu_item($control1, "" & "Key range", $KEYRANGE) add_menu_item($control1, "" & "Toggle", $TOGGLE) add_menu_item($control1, "-----------------------", $INACTIVE) add_menu_item($control1, ">> Pedal down", $PEDALDOWN) add_menu_item($control1, ">> Pedal up", $PEDALUP) add_menu_item($control1, "-----------------------", $INACTIVE) add_menu_item($control1, ">> MIDI CC (0-50)", 5000) add_menu_item($control1, ">> MIDI CC (50-100)", 10050) add_menu_item($control1, "-----------------------", $INACTIVE) add_menu_item($control1, ">> MIDI CC (0-33)", 3300) add_menu_item($control1, ">> MIDI CC (33-66)", 6633) add_menu_item($control1, ">> MIDI CC (66-100)", 10066) add_menu_item($control1, "-----------------------", $INACTIVE) add_menu_item($control1, ">> MIDI CC (0-25)", 2500) add_menu_item($control1, ">> MIDI CC (25-50)", 5025) add_menu_item($control1, ">> MIDI CC (50-75)", 7550) add_menu_item($control1, ">> MIDI CC (75-100)", 10075) add_menu_item($control1, "-----------------------", $INACTIVE) add_menu_item($control1, ">> MIDI CC (0-20)", 2000) add_menu_item($control1, ">> MIDI CC (20-40)", 4020) add_menu_item($control1, ">> MIDI CC (40-60)", 6020) add_menu_item($control1, ">> MIDI CC (60-80)", 8060) add_menu_item($control1, ">> MIDI CC (80-100)", 10080) move_control($control1,1,1) move_control($lower1,2,1) move_control($upper1,3,1) move_control($CC_KS1,4,1) move_control($learn1,5,1) move_control($active1,6,1) make_persistent($control1) make_persistent($lower1) make_persistent($upper1) make_persistent($CC_KS1) make_persistent($learn1) make_persistent($active1) $CC_KS1 := 1 add_menu_item($control2, "------------", $INACTIVE) add_menu_item($control2, "" & "Key switch", $KEYSWITCH) add_menu_item($control2, "" & "Velocity", $VELOCITY) add_menu_item($control2, "" & "Speed(bpm)", $SPEED) add_menu_item($control2, "" & "MIDI CC", $MIDICC) add_menu_item($control2, "" & "Legato", $LEGATO) add_menu_item($control2, "" & "Not legato", $NOTLEGATO) add_menu_item($control2, "" & "Repetition", $REPETITION) add_menu_item($control2, "" & "Not repetition", $NOTREPETITION) add_menu_item($control2, "" & "Key range", $KEYRANGE) add_menu_item($control2, "" & "Toggle", $TOGGLE) add_menu_item($control2, "-----------------------", $INACTIVE) add_menu_item($control2, ">> Pedal down", $PEDALDOWN) add_menu_item($control2, ">> Pedal up", $PEDALUP) add_menu_item($control2, "-----------------------", $INACTIVE) add_menu_item($control2, ">> MIDI CC (0-50)", 5000) add_menu_item($control2, ">> MIDI CC (50-100)", 10050) add_menu_item($control2, "-----------------------", $INACTIVE) add_menu_item($control2, ">> MIDI CC (0-33)", 3300) add_menu_item($control2, ">> MIDI CC (33-66)", 6633) add_menu_item($control2, ">> MIDI CC (66-100)", 10066) add_menu_item($control2, "-----------------------", $INACTIVE) add_menu_item($control2, ">> MIDI CC (0-25)", 2500) add_menu_item($control2, ">> MIDI CC (25-50)", 5025) add_menu_item($control2, ">> MIDI CC (50-75)", 7550) add_menu_item($control2, ">> MIDI CC (75-100)", 10075) add_menu_item($control2, "-----------------------", $INACTIVE) add_menu_item($control2, ">> MIDI CC (0-20)", 2000) add_menu_item($control2, ">> MIDI CC (20-40)", 4020) add_menu_item($control2, ">> MIDI CC (40-60)", 6020) add_menu_item($control2, ">> MIDI CC (60-80)", 8060) add_menu_item($control2, ">> MIDI CC (80-100)", 10080) move_control($control2,1,2) move_control($lower2,2,2) move_control($upper2,3,2) move_control($CC_KS2,4,2) move_control($learn2,5,2) move_control($active2,6,2) make_persistent($control2) make_persistent($lower2) make_persistent($upper2) make_persistent($CC_KS2) make_persistent($learn2) make_persistent($active2) $CC_KS2 := 1 add_menu_item($control3, "------------", $INACTIVE) add_menu_item($control3, "" & "Key switch", $KEYSWITCH) add_menu_item($control3, "" & "Velocity", $VELOCITY) add_menu_item($control3, "" & "Speed(bpm)", $SPEED) add_menu_item($control3, "" & "MIDI CC", $MIDICC) add_menu_item($control3, "" & "Legato", $LEGATO) add_menu_item($control3, "" & "Not legato", $NOTLEGATO) add_menu_item($control3, "" & "Repetition", $REPETITION) add_menu_item($control3, "" & "Not repetition", $NOTREPETITION) add_menu_item($control3, "" & "Key range", $KEYRANGE) add_menu_item($control3, "" & "Toggle", $TOGGLE) add_menu_item($control3, "-----------------------", $INACTIVE) add_menu_item($control3, ">> Pedal down", $PEDALDOWN) add_menu_item($control3, ">> Pedal up", $PEDALUP) add_menu_item($control3, "-----------------------", $INACTIVE) add_menu_item($control3, ">> MIDI CC (0-50)", 5000) add_menu_item($control3, ">> MIDI CC (50-100)", 10050) add_menu_item($control3, "-----------------------", $INACTIVE) add_menu_item($control3, ">> MIDI CC (0-33)", 3300) add_menu_item($control3, ">> MIDI CC (33-66)", 6633) add_menu_item($control3, ">> MIDI CC (66-100)", 10066) add_menu_item($control3, "-----------------------", $INACTIVE) add_menu_item($control3, ">> MIDI CC (0-25)", 2500) add_menu_item($control3, ">> MIDI CC (25-50)", 5025) add_menu_item($control3, ">> MIDI CC (50-75)", 7550) add_menu_item($control3, ">> MIDI CC (75-100)", 10075) add_menu_item($control3, "-----------------------", $INACTIVE) add_menu_item($control3, ">> MIDI CC (0-20)", 2000) add_menu_item($control3, ">> MIDI CC (20-40)", 4020) add_menu_item($control3, ">> MIDI CC (40-60)", 6020) add_menu_item($control3, ">> MIDI CC (60-80)", 8060) add_menu_item($control3, ">> MIDI CC (80-100)", 10080) move_control($control3,1,3) move_control($lower3,2,3) move_control($upper3,3,3) move_control($CC_KS3,4,3) move_control($learn3,5,3) move_control($active3,6,3) make_persistent($control3) make_persistent($lower3) make_persistent($upper3) make_persistent($CC_KS3) make_persistent($learn3) make_persistent($active3) $CC_KS3 := 1 add_menu_item($control4, "------------", $INACTIVE) add_menu_item($control4, "" & "Key switch", $KEYSWITCH) add_menu_item($control4, "" & "Velocity", $VELOCITY) add_menu_item($control4, "" & "Speed(bpm)", $SPEED) add_menu_item($control4, "" & "MIDI CC", $MIDICC) add_menu_item($control4, "" & "Legato", $LEGATO) add_menu_item($control4, "" & "Not legato", $NOTLEGATO) add_menu_item($control4, "" & "Repetition", $REPETITION) add_menu_item($control4, "" & "Not repetition", $NOTREPETITION) add_menu_item($control4, "" & "Key range", $KEYRANGE) add_menu_item($control4, "" & "Toggle", $TOGGLE) add_menu_item($control4, "-----------------------", $INACTIVE) add_menu_item($control4, ">> Pedal down", $PEDALDOWN) add_menu_item($control4, ">> Pedal up", $PEDALUP) add_menu_item($control4, "-----------------------", $INACTIVE) add_menu_item($control4, ">> MIDI CC (0-50)", 5000) add_menu_item($control4, ">> MIDI CC (50-100)", 10050) add_menu_item($control4, "-----------------------", $INACTIVE) add_menu_item($control4, ">> MIDI CC (0-33)", 3300) add_menu_item($control4, ">> MIDI CC (33-66)", 6633) add_menu_item($control4, ">> MIDI CC (66-100)", 10066) add_menu_item($control4, "-----------------------", $INACTIVE) add_menu_item($control4, ">> MIDI CC (0-25)", 2500) add_menu_item($control4, ">> MIDI CC (25-50)", 5025) add_menu_item($control4, ">> MIDI CC (50-75)", 7550) add_menu_item($control4, ">> MIDI CC (75-100)", 10075) add_menu_item($control4, "-----------------------", $INACTIVE) add_menu_item($control4, ">> MIDI CC (0-20)", 2000) add_menu_item($control4, ">> MIDI CC (20-40)", 4020) add_menu_item($control4, ">> MIDI CC (40-60)", 6020) add_menu_item($control4, ">> MIDI CC (60-80)", 8060) add_menu_item($control4, ">> MIDI CC (80-100)", 10080) move_control($control4,1,4) move_control($lower4,2,4) move_control($upper4,3,4) move_control($CC_KS4,4,4) move_control($learn4,5,4) move_control($active4,6,4) make_persistent($control4) make_persistent($lower4) make_persistent($upper4) make_persistent($CC_KS4) make_persistent($learn4) make_persistent($active4) $CC_KS4 := 1 add_menu_item($logic, "1&2&3&4", $LOGIC_ALLAND) add_menu_item($logic, "1&(2&3|4)", $LOGIC_LASTOR) add_menu_item($logic, "(1&2)|(3&4)", $LOGIC_MIDDLEOR) add_menu_item($logic, "not 1&2&3&4", $NLOGIC + $LOGIC_ALLAND) add_menu_item($logic, "not 1&(2&3|4)", $NLOGIC + $LOGIC_LASTOR) add_menu_item($logic, "not (1&2)|(3&4)", $NLOGIC + $LOGIC_MIDDLEOR) set_text($label1, "Logic function:") set_text($label2, "KS active:") set_text($label3, "Articulation key switch: (or -1)") set_text($label4, "Valid speed range: (no change outside)") add_menu_item($ks_duration, "Until next KS", 1) add_menu_item($ks_duration, "While pressed (not yet implemented)", 2) add_menu_item($ks_duration, "For one note (not yet implemented)", 3) move_control($label1,1,5) move_control($logic,1,6) move_control($label2,2,5) move_control($ks_duration,2,6) move_control($label3,3,5) move_control($KS,3,6) move_control($learn,4,6) move_control($label4,5,5) move_control($min,5,6) move_control($max,6,6) make_persistent($logic) make_persistent($ks_duration) make_persistent($KS) make_persistent($min) make_persistent($max) SET_CONDITION(NO_SYS_SCRIPT_PEDAL) end on on note { check if in key switch learning mode } if ($learn = 1) $KS := $EVENT_NOTE $learn := 0 exit end if { update bpm } $new_bpm := 60000 / ($ENGINE_UPTIME - $last_time) $last_time := $ENGINE_UPTIME if (in_range($new_bpm, $min, $max)) $bpm := $new_bpm end if { if we're in learning mode } if ($learn1+$learn2+$learn3+$learn4 # 0) if ($learn1 = 1) select ($control1) case $VELOCITY if ($learning_state1 = 1) $lower1 := 127 $upper1 := 0 $learning_state1 := 0 end if if ($EVENT_VELOCITY < $lower1) $lower1 := $EVENT_VELOCITY end if if ($EVENT_VELOCITY > $upper1) $upper1 := $EVENT_VELOCITY end if case $SPEED if ($learning_state1 = 2) $lower1 := $bpm $upper1 := $bpm else if ($learning_state1 > 2) if ($bpm < $lower1) $lower1 := $bpm end if if ($bpm > $upper1) $upper1 := $bpm end if end if end if inc($learning_state1) case $KEYSWITCH select($learning_state1) case 1 $lower1 := $EVENT_NOTE case 2 $upper1 := $EVENT_NOTE case 3 $CC_KS1 := $EVENT_NOTE $learn1 := 0 end select inc($learning_state1) case $KEYRANGE select($learning_state1) case 1 $lower1 := $EVENT_NOTE case 2 $upper1 := $EVENT_NOTE $learn1 := 0 end select inc($learning_state1) end select end if if ($learn2 = 1) select ($control2) case $VELOCITY if ($learning_state2 = 1) $lower2 := 127 $upper2 := 0 $learning_state2 := 0 end if if ($EVENT_VELOCITY < $lower2) $lower2 := $EVENT_VELOCITY end if if ($EVENT_VELOCITY > $upper2) $upper2 := $EVENT_VELOCITY end if case $SPEED if ($learning_state2 = 2) $lower2 := $bpm $upper2 := $bpm else if ($learning_state2 > 2) if ($bpm < $lower2) $lower2 := $bpm end if if ($bpm > $upper2) $upper2 := $bpm end if end if end if inc($learning_state2) case $KEYSWITCH select($learning_state2) case 1 $lower2 := $EVENT_NOTE case 2 $upper2 := $EVENT_NOTE case 3 $CC_KS2 := $EVENT_NOTE $learn2 := 0 end select inc($learning_state2) case $KEYRANGE select($learning_state2) case 1 $lower2 := $EVENT_NOTE case 2 $upper2 := $EVENT_NOTE $learn2 := 0 end select inc($learning_state2) end select end if if ($learn3 = 1) select ($control3) case $VELOCITY if ($learning_state3 = 1) $lower3 := 127 $upper3 := 0 $learning_state3 := 0 end if if ($EVENT_VELOCITY < $lower3) $lower3 := $EVENT_VELOCITY end if if ($EVENT_VELOCITY > $upper3) $upper3 := $EVENT_VELOCITY end if case $SPEED if ($learning_state3 = 2) $lower3 := $bpm $upper3 := $bpm else if ($learning_state3 > 2) if ($bpm < $lower3) $lower3 := $bpm end if if ($bpm > $upper3) $upper3 := $bpm end if end if end if inc($learning_state3) case $KEYSWITCH select($learning_state3) case 1 $lower3 := $EVENT_NOTE case 2 $upper3 := $EVENT_NOTE case 3 $CC_KS3 := $EVENT_NOTE $learn3 := 0 end select inc($learning_state3) case $KEYRANGE select($learning_state3) case 1 $lower3 := $EVENT_NOTE case 2 $upper3 := $EVENT_NOTE $learn3 := 0 end select inc($learning_state3) end select end if if ($learn4 = 1) select ($control4) case $VELOCITY if ($learning_state4 = 1) $lower4 := 127 $upper4 := 0 $learning_state4 := 0 end if if ($EVENT_VELOCITY < $lower4) $lower4 := $EVENT_VELOCITY end if if ($EVENT_VELOCITY > $upper4) $upper4 := $EVENT_VELOCITY end if case $SPEED if ($learning_state4 = 2) $lower4 := $bpm $upper4 := $bpm else if ($learning_state4 > 2) if ($bpm < $lower4) $lower4 := $bpm end if if ($bpm > $upper4) $upper4 := $bpm end if end if end if inc($learning_state4) case $KEYSWITCH select($learning_state4) case 1 $lower4 := $EVENT_NOTE case 2 $upper4 := $EVENT_NOTE case 3 $CC_KS4 := $EVENT_NOTE $learn4 := 0 end select inc($learning_state4) case $KEYRANGE select($learning_state4) case 1 $lower4 := $EVENT_NOTE case 2 $upper4 := $EVENT_NOTE $learn4 := 0 end select inc($learning_state4) end select end if else $is_keyswitch := 0 { this value might be set to true in one of the four functions below } $is_outside_note_range := 0 { this value might be set to true in one of the four functions below } select($control1) case $INACTIVE $active1 := 0 case $KEYSWITCH if (in_range($EVENT_NOTE, $lower1, $upper1)) $is_keyswitch := 1 if ($EVENT_NOTE = $CC_KS1) $active1 := 1 else $active1 := 0 end if end if case $VELOCITY if (in_range($EVENT_VELOCITY, $lower1, $upper1)) $active1 := 1 else $active1 := 0 end if case $SPEED if (in_range($bpm, $min, $max)) if (in_range($bpm, $lower1, $upper1)) $active1 := 1 else $active1 := 0 end if end if case $MIDICC if (in_range(%CC[$CC_KS1], $lower1, $upper1)) $active1 := 1 else $active1 := 0 end if case $LEGATO to $NOTLEGATO if (%KEY_DOWN[$last_note] = 1 and $last_note # $EVENT_NOTE) $active1 := 1 else $active1 := 0 end if if ($control1 = $NOTLEGATO) if ($active1=1 and %KEY_DOWN[$last_note]=1) note_off($last_id) end if $active1 := 1 - $active1 { toggle } end if case $REPETITION to $NOTREPETITION if ($EVENT_NOTE = $last_note) $active1 := 1 else $active1 := 0 end if if ($control1 = $NOTREPETITION) $active1 := 1 - $active1 { toggle } end if case $KEYRANGE if (in_range($EVENT_NOTE, $lower1, $upper1)) $active1 := 1 else $active1 := 0 $is_outside_note_range := 1 end if end select select($control2) case $INACTIVE $active2 := 0 case $KEYSWITCH if (in_range($EVENT_NOTE, $lower2, $upper2)) $is_keyswitch := 1 if ($EVENT_NOTE = $CC_KS2) $active2 := 1 else $active2 := 0 end if end if case $VELOCITY if (in_range($EVENT_VELOCITY, $lower2, $upper2)) $active2 := 1 else $active2 := 0 end if case $SPEED if (in_range($bpm, $min, $max)) if (in_range($bpm, $lower2, $upper2)) $active2 := 1 else $active2 := 0 end if end if case $MIDICC if (in_range(%CC[$CC_KS2], $lower2, $upper2)) $active2 := 1 else $active2 := 0 end if case $LEGATO to $NOTLEGATO if (%KEY_DOWN[$last_note] = 1 and $last_note # $EVENT_NOTE) $active2 := 1 else $active2 := 0 end if if ($control2 = $NOTLEGATO) if ($active2=1 and %KEY_DOWN[$last_note]=1) note_off($last_id) end if $active2 := 1 - $active2 { toggle } end if case $REPETITION to $NOTREPETITION if ($EVENT_NOTE = $last_note) $active2 := 1 else $active2 := 0 end if if ($control2 = $NOTREPETITION) $active2 := 1 - $active2 { toggle } end if case $KEYRANGE if (in_range($EVENT_NOTE, $lower2, $upper2)) $active2 := 1 else $active2 := 0 $is_outside_note_range := 1 end if end select select($control3) case $INACTIVE $active3 := 0 case $KEYSWITCH if (in_range($EVENT_NOTE, $lower3, $upper3)) $is_keyswitch := 1 if ($EVENT_NOTE = $CC_KS3) $active3 := 1 else $active3 := 0 end if end if case $VELOCITY if (in_range($EVENT_VELOCITY, $lower3, $upper3)) $active3 := 1 else $active3 := 0 end if case $SPEED if (in_range($bpm, $min, $max)) if (in_range($bpm, $lower3, $upper3)) $active3 := 1 else $active3 := 0 end if end if case $MIDICC if (in_range(%CC[$CC_KS3], $lower3, $upper3)) $active3 := 1 else $active3 := 0 end if case $LEGATO to $NOTLEGATO if (%KEY_DOWN[$last_note] = 1 and $last_note # $EVENT_NOTE) $active3 := 1 else $active3 := 0 end if if ($control3 = $NOTLEGATO) if ($active3=1 and %KEY_DOWN[$last_note]=1) note_off($last_id) end if $active3 := 1 - $active3 { toggle } end if case $REPETITION to $NOTREPETITION if ($EVENT_NOTE = $last_note) $active3 := 1 else $active3 := 0 end if if ($control3 = $NOTREPETITION) $active3 := 1 - $active3 { toggle } end if case $KEYRANGE if (in_range($EVENT_NOTE, $lower3, $upper3)) $active3 := 1 else $active3 := 0 $is_outside_note_range := 1 end if end select select($control4) case $INACTIVE $active4 := 0 case $KEYSWITCH if (in_range($EVENT_NOTE, $lower4, $upper4)) $is_keyswitch := 1 if ($EVENT_NOTE = $CC_KS4) $active4 := 1 else $active4 := 0 end if end if case $VELOCITY if (in_range($EVENT_VELOCITY, $lower4, $upper4)) $active4 := 1 else $active4 := 0 end if case $SPEED if (in_range($bpm, $min, $max)) if (in_range($bpm, $lower4, $upper4)) $active4 := 1 else $active4 := 0 end if end if case $MIDICC if (in_range(%CC[$CC_KS4], $lower4, $upper4)) $active4 := 1 else $active4 := 0 end if case $LEGATO to $NOTLEGATO if (%KEY_DOWN[$last_note] = 1 and $last_note # $EVENT_NOTE) $active4 := 1 else $active4 := 0 end if if ($control4 = $NOTLEGATO) if ($active4=1 and %KEY_DOWN[$last_note]=1) note_off($last_id) end if $active4 := 1 - $active4 { toggle } end if case $REPETITION to $NOTREPETITION if ($EVENT_NOTE = $last_note) $active4 := 1 else $active4 := 0 end if if ($control4 = $NOTREPETITION) $active4 := 1 - $active4 { toggle } end if case $KEYRANGE if (in_range($EVENT_NOTE, $lower4, $upper4)) $active4 := 1 else $active4 := 0 $is_outside_note_range := 1 end if end select { do the logical combination of the active buttons - 1 and (2 and 3 or 4) } $condition := 1 if ($logic mod $NLOGIC = $LOGIC_MIDDLEOR) if ($control1 # $INACTIVE and $active1=0) $condition := 0 end if if ($control2 # $INACTIVE and $active2=0) $condition := 0 end if if ($condition = 0 and ($control3 # $INACTIVE or $control4 # $INACTIVE)) $condition := 1 if ($control3 # $INACTIVE and $active3=0) $condition := 0 end if if ($control4 # $INACTIVE and $active4=0) $condition := 0 end if end if else if ($control1 # $INACTIVE and $active1=0) $condition := 0 else if ($control2 # $INACTIVE and $active2=0) $condition := 0 end if if ($control3 # $INACTIVE and $active3=0) $condition := 0 end if if ($logic mod $NLOGIC = $LOGIC_ALLAND) if ($control4 # $INACTIVE and $active4=0) $condition := 0 end if else if ($control4 # $INACTIVE and $active4=1) $condition := 1 end if end if end if end if { if 'not' condition, negate the condition } if ($logic >= $NLOGIC) $condition := 1 - $condition end if if ($is_keyswitch = 1) $condition := 0 { block key switch notes } else if ($is_outside_note_range = 0) $last_note := $EVENT_NOTE { remember last note } end if end if ignore_event($EVENT_ID) if ($condition = 1) if ($KS # -1) play_note($KS, 100, 0, -1) end if $last_id := play_note($EVENT_NOTE, $EVENT_VELOCITY, 0, -1) end if end if end on on controller if ($learn1 = 1 and $control1 = $MIDICC) if ($learning_state1 = 1) $lower1 := 127 $upper1 := 0 $learning_state1 := 0 end if if (%CC[$CC_KS1] < $lower1) $lower1 := %CC[$CC_KS1] end if if (%CC[$CC_KS1] > $upper1) $upper1 := %CC[$CC_KS1] end if end if if ($learn2 = 1 and $control2 = $MIDICC) if ($learning_state2 = 1) $lower2 := 127 $upper2 := 0 $learning_state2 := 0 end if if (%CC[$CC_KS2] < $lower2) $lower2 := %CC[$CC_KS2] end if if (%CC[$CC_KS2] > $upper2) $upper2 := %CC[$CC_KS2] end if end if if ($learn3 = 1 and $control3 = $MIDICC) if ($learning_state3 = 1) $lower3 := 127 $upper3 := 0 $learning_state3 := 0 end if if (%CC[$CC_KS3] < $lower3) $lower3 := %CC[$CC_KS3] end if if (%CC[$CC_KS3] > $upper3) $upper3 := %CC[$CC_KS3] end if end if if ($learn4 = 1 and $control4 = $MIDICC) if ($learning_state4 = 1) $lower4 := 127 $upper4 := 0 $learning_state4 := 0 end if if (%CC[$CC_KS4] < $lower4) $lower4 := %CC[$CC_KS4] end if if (%CC[$CC_KS4] > $upper4) $upper4 := %CC[$CC_KS4] end if end if end on on ui_control($lower1) if ($lower1 > $upper1) $upper1 := $lower1 end if if ($control1 # $SPEED and $lower1 > 127) $lower1 := 127 end if if ($control1 # $SPEED and $upper1 > 127) $upper1 := 127 end if end on on ui_control($lower2) if ($lower2 > $upper2) $upper2 := $lower2 end if if ($control2 # $SPEED and $lower2 > 127) $lower2 := 127 end if if ($control2 # $SPEED and $upper2 > 127) $upper2 := 127 end if end on on ui_control($lower3) if ($lower3 > $upper3) $upper3 := $lower3 end if if ($control3 # $SPEED and $lower3 > 127) $lower3 := 127 end if if ($control3 # $SPEED and $upper3 > 127) $upper3 := 127 end if end on on ui_control($lower4) if ($lower4 > $upper4) $upper4 := $lower4 end if if ($control4 # $SPEED and $lower4 > 127) $lower4 := 127 end if if ($control4 # $SPEED and $upper4 > 127) $upper4 := 127 end if end on on ui_control($upper1) if ($upper1 < $lower1) $lower1 := $upper1 end if if ($control1 # $SPEED and $lower1 > 127) $lower1 := 127 end if if ($control1 # $SPEED and $upper1 > 127) $upper1 := 127 end if end on on ui_control($upper2) if ($upper2 < $lower2) $lower2 := $upper2 end if if ($control2 # $SPEED and $lower2 > 127) $lower2 := 127 end if if ($control2 # $SPEED and $upper2 > 127) $upper2 := 127 end if end on on ui_control($upper3) if ($upper3 < $lower3) $lower3 := $upper3 end if if ($control3 # $SPEED and $lower3 > 127) $lower3 := 127 end if if ($control3 # $SPEED and $upper3 > 127) $upper3 := 127 end if end on on ui_control($upper4) if ($upper4 < $lower4) $lower4 := $upper4 end if if ($control4 # $SPEED and $lower4 > 127) $lower4 := 127 end if if ($control4 # $SPEED and $upper4 > 127) $upper4 := 127 end if end on { ******************* on learn ******************* } on ui_control($learn1) $learning_state1 := 1 end on on ui_control($learn2) $learning_state2 := 1 end on on ui_control($learn3) $learning_state3 := 1 end on on ui_control($learn4) $learning_state4 := 1 end on on ui_control($control1) if ($control1 > 100) $lower1 := 127 * ($control1 mod 100) / 100 + 1 $upper1 := 127 * ($control1 / 100) / 100 if ($control1 mod 100 = 0) $lower1 := 0 end if $control1 := $MIDICC end if if ($control1 = $PEDALDOWN) $control1 := $MIDICC $lower1 := 64 $upper1 := 127 $CC_KS1 := 64 end if if ($control1 = $PEDALUP) $control1 := $MIDICC $lower1 := 0 $upper1 := 64 $CC_KS1 := 64 end if end on on ui_control($control2) if ($control2 > 100) $lower2 := 127 * ($control2 mod 100) / 100 + 1 $upper2 := 127 * ($control2 / 100) / 100 if ($control2 mod 100 = 0) $lower2 := 0 end if $control2 := $MIDICC end if if ($control2 = $PEDALDOWN) $control2 := $MIDICC $lower2 := 64 $upper2 := 127 $CC_KS2 := 64 end if if ($control2 = $PEDALUP) $control2 := $MIDICC $lower2 := 0 $upper2 := 64 $CC_KS2 := 64 end if end on on ui_control($control3) if ($control3 > 100) $lower3 := 127 * ($control3 mod 100) / 100 + 1 $upper3 := 127 * ($control3 / 100) / 100 if ($control3 mod 100 = 0) $lower3 := 0 end if $control3 := $MIDICC end if if ($control3 = $PEDALDOWN) $control3 := $MIDICC $lower3 := 64 $upper3 := 127 $CC_KS3 := 64 end if if ($control3 = $PEDALUP) $control3 := $MIDICC $lower3 := 0 $upper3 := 64 $CC_KS3 := 64 end if end on on ui_control($control4) if ($control4 > 100) $lower4 := 127 * ($control4 mod 100) / 100 + 1 $upper4 := 127 * ($control4 / 100) / 100 if ($control4 mod 100 = 0) $lower4 := 0 end if $control4 := $MIDICC end if if ($control4 = $PEDALDOWN) $control4 := $MIDICC $lower4 := 64 $upper4 := 127 $CC_KS4 := 64 end if if ($control4 = $PEDALUP) $control4 := $MIDICC $lower4 := 0 $upper4 := 64 $CC_KS4 := 64 end if end on