{ Compiled on Sat Jul 16 18:29:57 2016 }
on init
declare %24kub[32768]
declare $2j2se
$2j2se := 118
declare $w215g
$w215g := 118
declare $tldxu
declare %3sxc3[654] := (0)
declare %dfixe[654]
declare %e0wqy[654]
declare %trwd2[654]
$tldxu := 0
while ($tldxu<654)
%trwd2[$tldxu] := 68+($tldxu*50)
inc($tldxu)
end while
$tldxu := 0
%3sxc3[0] := -1
pgs_create_key(TCM_EXCEPTION,5)
pgs_set_key_val(TCM_EXCEPTION,$CURRENT_SCRIPT_SLOT,0)
set_script_title("Waveform Demo")
set_ui_height(4)
make_perfview
declare %g552i[128] := (-1)
make_persistent(%g552i)
read_persistent_var(%g552i)
declare $crypi
declare $fg4rw
declare $g5k3r
declare $25gvz
declare $cozj0 := 0
declare $huuzj
make_persistent($huuzj)
read_persistent_var($huuzj)
declare $ufh4p
declare $fcifc
declare $qmqhz
make_persistent($qmqhz)
read_persistent_var($qmqhz)
declare %b4l40[24576] := (500000)
make_persistent(%b4l40)
read_persistent_var(%b4l40)
declare %z2scz[3] := ($ENGINE_PAR_VOLUME, $ENGINE_PAR_PAN, $ENGINE_PAR_TUNE)
declare ui_waveform $qdcvk(1, 1) 
set_control_par(get_ui_id($qdcvk),$CONTROL_PAR_WIDTH,600)
set_control_par(get_ui_id($qdcvk),$CONTROL_PAR_HEIGHT,100)
move_control_px($qdcvk,15,0)
declare %kmmxf[4]
declare ui_switch $hswsi
make_persistent($hswsi)
move_control_px($hswsi,15,115)
set_control_par_str(get_ui_id($hswsi),$CONTROL_PAR_TEXT,"VOLUME")
%kmmxf[0] := get_ui_id($hswsi)
declare ui_switch $br0zw
make_persistent($br0zw)
move_control_px($br0zw,115,115)
set_control_par_str(get_ui_id($br0zw),$CONTROL_PAR_TEXT,"PAN")
%kmmxf[1] := get_ui_id($br0zw)
declare ui_switch $pbwjc
make_persistent($pbwjc)
move_control_px($pbwjc,215,115)
set_control_par_str(get_ui_id($pbwjc),$CONTROL_PAR_TEXT,"PITCH")
%kmmxf[2] := get_ui_id($pbwjc)
declare ui_switch $kmuyq
make_persistent($kmuyq)
move_control_px($kmuyq,315,115)
set_control_par_str(get_ui_id($kmuyq),$CONTROL_PAR_TEXT,"HIDE")
%kmmxf[3] := get_ui_id($kmuyq)
declare ui_switch $jf1p5
make_persistent($jf1p5)
read_persistent_var($jf1p5)
move_control_px($jf1p5,415,115)
set_control_par_str(get_ui_id($jf1p5),$CONTROL_PAR_TEXT,"RESET")
declare ui_switch $tb3bh
make_persistent($tb3bh)
read_persistent_var($tb3bh)
move_control_px($tb3bh,515,115)
set_control_par_str(get_ui_id($tb3bh),$CONTROL_PAR_TEXT,"REVERSE")
declare %pkq5x[3] := (165223709, 154673606, 153069429)
end on
function _twait
%24kub[$2j2se-2] := search(%3sxc3,0)
if (%24kub[$2j2se-2]=-1)
pgs_set_key_val(TCM_EXCEPTION,$CURRENT_SCRIPT_SLOT,1)
else
%3sxc3[$tldxu] := $NI_CALLBACK_ID
%e0wqy[$tldxu] := $w215g
%dfixe[$tldxu] := $2j2se
$tldxu := %24kub[$2j2se-2]
%3sxc3[$tldxu] := -1
$w215g := %trwd2[$tldxu]+50
%24kub[$w215g-1] := %24kub[$2j2se-1]
$2j2se := $w215g
wait(%24kub[$2j2se-1])
%3sxc3[$tldxu] := 0
$tldxu := search(%3sxc3,$NI_CALLBACK_ID)
%3sxc3[$tldxu] := -1
$w215g := %e0wqy[$tldxu]
$2j2se := %dfixe[$tldxu]
end if
end function
function get_zone_id
%24kub[$2j2se-6] := $w215g
$w215g := $2j2se-6
$2j2se := $w215g
%24kub[$w215g+1] := play_note(%24kub[$w215g+2],%24kub[$w215g+3],0,1)
change_vol(%24kub[$w215g+1],-200000,0)
%24kub[$2j2se-1] := 1
call _twait
set_event_par_arr(%24kub[$w215g+1],$EVENT_PAR_ALLOW_GROUP,0,$ALL_GROUPS)
set_event_par_arr(%24kub[$w215g+1],$EVENT_PAR_ALLOW_GROUP,1,%24kub[$w215g+4])
%24kub[$w215g+5] := get_event_par(%24kub[$w215g+1],$EVENT_PAR_ZONE_ID)
$2j2se := $w215g
$w215g := %24kub[$w215g]
$2j2se := $2j2se+6
end function
function toggle_envelope_switches
%24kub[$2j2se-3] := $w215g
$w215g := $2j2se-3
$2j2se := $w215g
%24kub[$w215g+1] := 0
while (%24kub[$w215g+1]<num_elements(%kmmxf))
set_control_par(%kmmxf[%24kub[$w215g+1]],$CONTROL_PAR_VALUE,0)
inc(%24kub[$w215g+1])
end while
set_control_par(%kmmxf[%24kub[$w215g+2]],$CONTROL_PAR_VALUE,1)
$2j2se := $w215g
$w215g := %24kub[$w215g]
$2j2se := $2j2se+3
end function
function attach_zone_to_waveform
%24kub[$2j2se-3] := $w215g
$w215g := $2j2se-3
$2j2se := $w215g
if (%24kub[$w215g+1]>-1)
if (%24kub[$w215g+2]=0)
attach_zone($qdcvk,%24kub[$w215g+1],$UI_WAVEFORM_USE_SLICES)
else
attach_zone($qdcvk,%24kub[$w215g+1],$UI_WAVEFORM_USE_SLICES .or. $UI_WAVEFORM_USE_TABLE)
end if
end if
$2j2se := $w215g
$w215g := %24kub[$w215g]
$2j2se := $2j2se+3
end function
function load_envelope
%24kub[$2j2se-3] := $w215g
$w215g := $2j2se-3
$2j2se := $w215g
if ($kmuyq=0)
%24kub[$w215g+1] := 0
while (%24kub[$w215g+1]<3)
if (get_control_par(%kmmxf[%24kub[$w215g+1]],$CONTROL_PAR_VALUE)=1)
%24kub[$w215g+2] := 0
while (%24kub[$w215g+2]<num_slices_zone($huuzj))
set_ui_wf_property($qdcvk,$UI_WF_PROP_TABLE_VAL,%24kub[$w215g+2],%b4l40[8192*%24kub[$w215g+1]+(64*$qmqhz)+%24kub[$w215g+2]])
inc(%24kub[$w215g+2])
end while
end if
inc(%24kub[$w215g+1])
end while
end if
$2j2se := $w215g
$w215g := %24kub[$w215g]
$2j2se := $2j2se+3
end function
function set_envelope_colour
%24kub[$2j2se-2] := $w215g
$w215g := $2j2se-2
$2j2se := $w215g
%24kub[$w215g+1] := 0
while (%24kub[$w215g+1]<3)
if (get_control_par(%kmmxf[%24kub[$w215g+1]],$CONTROL_PAR_VALUE)=1)
set_control_par(get_ui_id($qdcvk),$CONTROL_PAR_BAR_COLOR,%pkq5x[%24kub[$w215g+1]])
end if
inc(%24kub[$w215g+1])
end while
$2j2se := $w215g
$w215g := %24kub[$w215g]
$2j2se := $2j2se+2
end function
on pgs_changed
if ($cozj0=0)
$cozj0 := 1
%24kub[$2j2se-2] := $huuzj
%24kub[$2j2se-1] := 1-$kmuyq
call attach_zone_to_waveform
call load_envelope
call set_envelope_colour
set_control_par(get_ui_id($qdcvk),$CONTROL_PAR_HIDE,$HIDE_WHOLE_CONTROL)
%24kub[$2j2se-1] := 50000
call _twait
set_control_par(get_ui_id($qdcvk),$CONTROL_PAR_HIDE,$HIDE_PART_NOTHING)
if (%g552i[$qmqhz] # -1)
set_ui_wf_property($qdcvk,$UI_WF_PROP_TABLE_IDX_HIGHLIGHT,0,%g552i[$qmqhz])
end if
message("")
end if
end on
on note
ignore_event($EVENT_ID)
%24kub[$2j2se-4] := $EVENT_NOTE
%24kub[$2j2se-3] := $EVENT_VELOCITY
%24kub[$2j2se-2] := $tb3bh
call get_zone_id
$huuzj := %24kub[$2j2se-1]
if ($huuzj>-1)
if ($EVENT_NOTE # $qmqhz)
%24kub[$2j2se-2] := $huuzj
%24kub[$2j2se-1] := 1-$kmuyq
call attach_zone_to_waveform
call load_envelope
call set_envelope_colour
set_control_par(get_ui_id($qdcvk),$CONTROL_PAR_HIDE,$HIDE_WHOLE_CONTROL)
%24kub[$2j2se-1] := 50000
call _twait
set_control_par(get_ui_id($qdcvk),$CONTROL_PAR_HIDE,$HIDE_PART_NOTHING)
end if
$qmqhz := $EVENT_NOTE
disallow_group($ALL_GROUPS)
allow_group($tb3bh)
if (%g552i[$EVENT_NOTE] # -1)
set_ui_wf_property($qdcvk,$UI_WF_PROP_TABLE_IDX_HIGHLIGHT,0,%g552i[$EVENT_NOTE])
if ($tb3bh=0)
$fcifc := play_note($EVENT_NOTE,$EVENT_VELOCITY,zone_slice_start($huuzj,%g552i[$EVENT_NOTE]),-1)
else
$fcifc := play_note($EVENT_NOTE,$EVENT_VELOCITY,get_sample_length($huuzj)-zone_slice_start($huuzj,%g552i[$EVENT_NOTE]+1),-1)
end if
else
$fcifc := play_note($EVENT_NOTE,$EVENT_VELOCITY,0,-1)
end if
while ($NOTE_HELD=1)
$ufh4p := get_event_par($fcifc,$EVENT_PAR_PLAY_POS)
set_ui_wf_property($qdcvk,$UI_WF_PROP_PLAY_CURSOR,0,$ufh4p)
$crypi := 0
while ($ufh4p>zone_slice_start($huuzj,$crypi) and ($crypi<num_slices_zone($huuzj)))
inc($crypi)
end while
set_ui_wf_property($qdcvk,$UI_WF_PROP_TABLE_IDX_HIGHLIGHT,0,$crypi-1)
$fg4rw := 0
while ($fg4rw<num_elements(%z2scz))
if ($kmuyq=0)
set_engine_par(%z2scz[$fg4rw],%b4l40[8192*$fg4rw+(64*$EVENT_NOTE)+($crypi-1)],$tb3bh,-1,-1)
else
set_engine_par(%z2scz[$fg4rw],500000,$tb3bh,-1,-1)
end if
inc($fg4rw)
end while
wait(1000)
end while
end if
end on
on release
set_ui_wf_property($qdcvk,$UI_WF_PROP_PLAY_CURSOR,0,0)
set_ui_wf_property($qdcvk,$UI_WF_PROP_TABLE_IDX_HIGHLIGHT,0,-1)
if (%g552i[$EVENT_NOTE] # -1)
set_ui_wf_property($qdcvk,$UI_WF_PROP_TABLE_IDX_HIGHLIGHT,0,%g552i[$EVENT_NOTE])
end if
end on
on ui_control($qdcvk)
if (get_control_par(get_ui_id($qdcvk),$CONTROL_PAR_KEY_CONTROL)=1)
set_ui_wf_property($qdcvk,$UI_WF_PROP_TABLE_VAL,$qdcvk,500000)
end if
if (get_control_par(get_ui_id($qdcvk),$CONTROL_PAR_KEY_ALT)=1)
if (%g552i[$qmqhz] # -1)
set_ui_wf_property($qdcvk,$UI_WF_PROP_TABLE_IDX_HIGHLIGHT,0,-1)
%g552i[$qmqhz] := -1
else
%g552i[$qmqhz] := $qdcvk
set_ui_wf_property($qdcvk,$UI_WF_PROP_TABLE_IDX_HIGHLIGHT,0,$qdcvk)
end if
end if
if ($kmuyq=0)
$fg4rw := 0
while ($fg4rw<num_elements(%kmmxf))
if (get_control_par(%kmmxf[$fg4rw],$CONTROL_PAR_VALUE)=1)
%b4l40[8192*$fg4rw+(64*$qmqhz)+$qdcvk] := get_ui_wf_property($qdcvk,$UI_WF_PROP_TABLE_VAL,$qdcvk)
end if
inc($fg4rw)
end while
end if
end on
on ui_control($jf1p5)
$fg4rw := 0
while ($fg4rw<3)
$g5k3r := 0
while ($g5k3r<128)
$25gvz := 0
while ($25gvz<64)
%b4l40[8192*$fg4rw+(64*$g5k3r)+$25gvz] := 500000
inc($25gvz)
end while
inc($g5k3r)
end while
inc($fg4rw)
end while
call load_envelope
$jf1p5 := 0
%g552i[$qmqhz] := -1
set_ui_wf_property($qdcvk,$UI_WF_PROP_TABLE_IDX_HIGHLIGHT,0,-1)
end on
on ui_control($hswsi)
%24kub[$2j2se-1] := 0
call toggle_envelope_switches
%24kub[$2j2se-2] := $huuzj
%24kub[$2j2se-1] := 1-$kmuyq
call attach_zone_to_waveform
call load_envelope
call set_envelope_colour
set_control_par(get_ui_id($qdcvk),$CONTROL_PAR_HIDE,$HIDE_WHOLE_CONTROL)
%24kub[$2j2se-1] := 50000
call _twait
set_control_par(get_ui_id($qdcvk),$CONTROL_PAR_HIDE,$HIDE_PART_NOTHING)
end on
on ui_control($br0zw)
%24kub[$2j2se-1] := 1
call toggle_envelope_switches
%24kub[$2j2se-2] := $huuzj
%24kub[$2j2se-1] := 1-$kmuyq
call attach_zone_to_waveform
call load_envelope
call set_envelope_colour
set_control_par(get_ui_id($qdcvk),$CONTROL_PAR_HIDE,$HIDE_WHOLE_CONTROL)
%24kub[$2j2se-1] := 50000
call _twait
set_control_par(get_ui_id($qdcvk),$CONTROL_PAR_HIDE,$HIDE_PART_NOTHING)
end on
on ui_control($pbwjc)
%24kub[$2j2se-1] := 2
call toggle_envelope_switches
%24kub[$2j2se-2] := $huuzj
%24kub[$2j2se-1] := 1-$kmuyq
call attach_zone_to_waveform
call load_envelope
call set_envelope_colour
set_control_par(get_ui_id($qdcvk),$CONTROL_PAR_HIDE,$HIDE_WHOLE_CONTROL)
%24kub[$2j2se-1] := 50000
call _twait
set_control_par(get_ui_id($qdcvk),$CONTROL_PAR_HIDE,$HIDE_PART_NOTHING)
end on
on ui_control($kmuyq)
%24kub[$2j2se-1] := 3
call toggle_envelope_switches
%24kub[$2j2se-2] := $huuzj
%24kub[$2j2se-1] := 1-$kmuyq
call attach_zone_to_waveform
call load_envelope
call set_envelope_colour
set_control_par(get_ui_id($qdcvk),$CONTROL_PAR_HIDE,$HIDE_WHOLE_CONTROL)
%24kub[$2j2se-1] := 50000
call _twait
set_control_par(get_ui_id($qdcvk),$CONTROL_PAR_HIDE,$HIDE_PART_NOTHING)
end on
