on init
make_perfview
set_script_title("ACME Fiddle")
set_control_par_str($INST_WALLPAPER_ID,$CONTROL_PAR_PICTURE,"skin")
set_ui_height_px(259)
set_control_par($INST_ICON_ID,$CONTROL_PAR_HIDE,$HIDE_WHOLE_CONTROL)
declare $fg4rw
declare $ujobj := 0
declare $f0czl := -1
declare %ndief[2] := (24, 26)
declare %r1ezg[2] := (0, 1)
declare %w44vd[2] := (2, 3)
declare $0qh3i := 4
$fg4rw := 0
while ($fg4rw<num_elements(%ndief))
set_key_color(%ndief[$fg4rw],$KEY_COLOR_RED)
inc($fg4rw)
end while
declare ui_switch $xt0x1
set_control_par_str(get_ui_id($xt0x1),$CONTROL_PAR_PICTURE,"switch")
set_control_par_str(get_ui_id($xt0x1),$CONTROL_PAR_TEXT,"")
set_control_par(get_ui_id($xt0x1),$CONTROL_PAR_WIDTH,36)
set_control_par(get_ui_id($xt0x1),$CONTROL_PAR_HEIGHT,58)
set_control_help($xt0x1,"When set to OFF the true legato feature will be bypassed. When set to ON the repetition feature will be bypassed.")
move_control_px($xt0x1,168,4)
make_persistent($xt0x1)
declare ui_slider $02y3l(0, 250000) 
set_control_par_str(get_ui_id($02y3l),$CONTROL_PAR_PICTURE,"knob")
set_control_par(get_ui_id($02y3l),$CONTROL_PAR_MOUSE_BEHAVIOUR,-2500)
set_control_help($02y3l,"Offset the sample start time (attack) of sustain samples following a true legato transition.")
move_control_px($02y3l,65,70)
make_persistent($02y3l)
read_persistent_var($02y3l)
declare ui_label $ffmb0(1, 1) 
set_text($ffmb0,$02y3l)
set_control_par(get_ui_id($ffmb0),$CONTROL_PAR_WIDTH,60)
move_control_px($ffmb0,118,86)
hide_part($ffmb0,$HIDE_PART_BG)
declare ui_slider $qzfgp(100000, 700000) 
set_control_par_str(get_ui_id($qzfgp),$CONTROL_PAR_PICTURE,"knob")
set_control_par(get_ui_id($qzfgp),$CONTROL_PAR_MOUSE_BEHAVIOUR,-2500)
set_control_help($qzfgp,"Sets the crossfade time, in microseconds, for true legato transtitions.")
move_control_px($qzfgp,65,121)
make_persistent($qzfgp)
read_persistent_var($qzfgp)
declare ui_label $wimzd(1, 1) 
set_text($wimzd,$qzfgp)
set_control_par(get_ui_id($wimzd),$CONTROL_PAR_WIDTH,60)
move_control_px($wimzd,118,137)
hide_part($wimzd,$HIDE_PART_BG)
declare ui_switch $hkkxi
set_control_par_str(get_ui_id($hkkxi),$CONTROL_PAR_PICTURE,"switch")
set_control_par_str(get_ui_id($hkkxi),$CONTROL_PAR_TEXT,"")
set_control_par(get_ui_id($hkkxi),$CONTROL_PAR_WIDTH,36)
set_control_par(get_ui_id($hkkxi),$CONTROL_PAR_HEIGHT,58)
set_control_help($hkkxi,"When set to OFF the repetition feature will be bypassed. WHen set to ON the true legato feature will be bypassed.")
move_control_px($hkkxi,296,124)
make_persistent($hkkxi)
declare ui_slider $sannz(0, 500000) 
set_control_par_str(get_ui_id($sannz),$CONTROL_PAR_PICTURE,"knob")
set_control_par(get_ui_id($sannz),$CONTROL_PAR_MOUSE_BEHAVIOUR,-2500)
set_control_help($sannz,"Sets the reverb's gain.")
move_control_px($sannz,506,86)
make_persistent($sannz)
declare ui_label $dybba(1, 1) 
set_text($dybba,get_engine_par_disp($ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN,-1,7,-1) & "dB")
set_control_par(get_ui_id($dybba),$CONTROL_PAR_WIDTH,60)
move_control_px($dybba,558,102)
hide_part($dybba,$HIDE_PART_BG)
declare ui_menu $asieg
set_control_par_str(get_ui_id($asieg),$CONTROL_PAR_PICTURE,"menu")
set_control_help($asieg,"Select a CC number from this menu to control the sustain articulation's dynamics; The staccato's dynamics are controlled by note velocity.")
move_control_px($asieg,316,50)
declare $3tnu3
$3tnu3 := 1
while ($3tnu3<=99)
add_menu_item($asieg,"CC: " & $3tnu3,$3tnu3)
inc($3tnu3)
end while
$asieg := 1
set_control_par(get_ui_id($asieg),$CONTROL_PAR_TEXTPOS_Y,4)
declare ui_label $s1am3(1, 1) 
set_control_par_str(get_ui_id($s1am3),$CONTROL_PAR_PICTURE,"articulation")
set_text($s1am3,"")
set_control_par(get_ui_id($s1am3),$CONTROL_PAR_WIDTH,150)
move_control_px($s1am3,66,221)
message("")
declare $iyk32
declare $bh2do
declare $lhmeo
declare $gdty5
declare $q0z4a
declare $npxdg
declare $imjnx
declare $1pprt
declare $mijyp
end on
on note
disallow_group($ALL_GROUPS)
if (in_range($EVENT_NOTE,42,127))
if ($xt0x1=1)
if ($ujobj=0)
$fg4rw := 0
while ($fg4rw<num_elements(%r1ezg))
allow_group(%r1ezg[$fg4rw])
inc($fg4rw)
end while
else
allow_group($0qh3i)
end if
if ($hkkxi=0)
ignore_event($EVENT_ID)
$iyk32 := random(-2,2)
$bh2do := random(-10000,10000)
$lhmeo := play_note($EVENT_NOTE+$iyk32,$EVENT_VELOCITY,0,-1)
change_tune($lhmeo,-$iyk32*100000+$bh2do,0)
end if
else
ignore_event($EVENT_ID)
if ($q0z4a=1)
$imjnx := 300000
wait(500)
end if
if ($f0czl>-1)
$gdty5 := abs($EVENT_NOTE-$f0czl)
if ($f0czl<$EVENT_NOTE)
$gdty5 := $gdty5+64
end if
else
$gdty5 := 0
end if
if ($gdty5 # 0 and ($gdty5<=8 or in_range($gdty5,65,72)))
disallow_group($ALL_GROUPS)
$npxdg := 0
while ($npxdg<num_elements(%w44vd))
allow_group(%w44vd[$npxdg])
inc($npxdg)
end while
note_off($mijyp)
$mijyp := play_note($f0czl,$gdty5,0,-1)
fade_out($1pprt,$qzfgp,1)
fade_in($mijyp,$qzfgp/2)
$q0z4a := 1
$imjnx := 0
while ($imjnx<=600)
wait(500)
inc($imjnx)
end while
$q0z4a := 0
disallow_group($ALL_GROUPS)
$npxdg := 0
while ($npxdg<num_elements(%r1ezg))
allow_group(%r1ezg[$npxdg])
inc($npxdg)
end while
note_off($1pprt)
$1pprt := play_note($EVENT_NOTE,$EVENT_VELOCITY,$02y3l,-1)
fade_out($mijyp,$qzfgp,1)
fade_in($1pprt,$qzfgp/2)
else
disallow_group($ALL_GROUPS)
$npxdg := 0
while ($npxdg<num_elements(%r1ezg))
allow_group(%r1ezg[$npxdg])
inc($npxdg)
end while
note_off($1pprt)
$1pprt := play_note($EVENT_NOTE,$EVENT_VELOCITY,0,-1)
end if
$f0czl := $EVENT_NOTE
end if
else
if (search(%ndief,$EVENT_NOTE) # -1)
$ujobj := search(%ndief,$EVENT_NOTE)
$ujobj := $ujobj
set_control_par(get_ui_id($s1am3),$CONTROL_PAR_PICTURE_STATE,$ujobj)
if ($ujobj=1)
$xt0x1 := 1
end if
end if
end if
end on
on release
if ($EVENT_NOTE=$f0czl and ($xt0x1=0))
$f0czl := -1
end if
end on
on controller
if ($CC_NUM=$asieg)
ignore_controller
set_controller(102,%CC[$CC_NUM])
end if
end on
on ui_control($xt0x1)
if ($xt0x1=0)
$hkkxi := 1
else
$ujobj := 0
set_control_par(get_ui_id($s1am3),$CONTROL_PAR_PICTURE_STATE,0)
end if
end on
on ui_control($02y3l)
set_text($ffmb0,$02y3l)
end on
on ui_control($qzfgp)
set_text($wimzd,$qzfgp)
end on
on ui_control($sannz)
set_engine_par($ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN,$sannz,-1,7,0)
set_control_par_str(get_ui_id($dybba),$CONTROL_PAR_TEXT,get_engine_par_disp($ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN,-1,7,-1) & "dB")
end on
on ui_control($hkkxi)
if ($hkkxi=0)
$xt0x1 := 1
end if
end on
