Anyway it basically brings a sliced loop into performance view (preview loop on B2 slice up from c3)
If anyone wants to mess around adding some tables for volume,pitch etc (I did have this going but got clicks etc) feel free, if not it may come in useful for saving separate nki's with your favorite breaks etc.
in group edit right now both groups need to share the same name, and you have to name your source loops in the script
ie: !filenames[0] := "Break0001" {Name of sample in samples folder}
!filenames[1] := "Break0001" {Name of sample in samples folder}

on init
message ("")
set_ui_height (7)
make_perfview
set_control_par_str($INST_WALLPAPER_ID,$CONTROL_PAR_PICTURE,"wallpaper")
{BOTH GROUPS MUST BE NAMED THE SAME AS LOADED SAMPLES}
declare !filenames[2] {A string array to store the filenames of the loops - please note that there's no .wav}
!filenames[0] := "Break0001" {Name of sample in samples folder}
!filenames[1] := "Break0001" {Name of sample in samples folder}
declare $i2 {for stepping through the zones to set to midway point}
declare $i3 {for stepping through the zones for volume}
declare $a {A simple counter}
declare $b {Another simple counter}
declare $flags {Used to make flags management easier}
declare $playpos {The current playing position}
declare $currentslice {The currently active slice}
declare $previousslice {The previously active slice}
declare %slicestartpoints[256] {An array to store the samplestart positions of each slice}
declare %zoneids[2] {An array to store the ids of the used zones}
declare ui_menu $mode {Dropdown menu to select a loop}
move_control ($mode,1,0)
make_persistent ($mode)
read_persistent_var ($mode)
add_menu_item ($mode,"Loop",0)
add_menu_item ($mode,"Slices",1)
declare ui_waveform $waveform_control (6,12) {The actual waveform control}
set_control_par(get_ui_id($waveform_control),$CONTROL_PAR_BG_COLOR,9000000h) {BG Color}
set_control_par(get_ui_id($waveform_control),$CONTROL_PAR_WAVE_COLOR,9FF7F24h) {Wave Color}
set_control_par(get_ui_id($waveform_control),$CONTROL_PAR_BAR_COLOR,9FFFFFFh) {Table Color}
move_control ($waveform_control,1,1)
declare ui_button $button_show_midi {A simple button that show the midi drag 'n' drop icon}
make_persistent ($button_show_midi)
read_persistent_var ($button_show_midi)
set_control_par_str (get_ui_id($button_show_midi),$CONTROL_PAR_TEXT,"Midi Drag 'n' Drop")
move_control ($button_show_midi,1,14)
declare ui_button $button_play_cursor {A simple button that enables the play cursor}
make_persistent ($button_play_cursor)
read_persistent_var ($button_play_cursor)
set_control_par_str (get_ui_id($button_play_cursor),$CONTROL_PAR_TEXT,"Playcursor")
move_control ($button_play_cursor,2,14)
$a := 0
while ($a < 2)
%zoneids[$a] := find_zone(!filenames[$a]) {The zone ids are detected}
$b := 0
while ($b < num_slices_zone (%zoneids[$a]))
%slicestartpoints[($a * 64) + $b] := zone_slice_start (%zoneids[$a],$b) {the slice start positions are detected}
inc ($b)
end while
inc ($a)
end while
$a := 0
while ($a < num_slices_zone (%zoneids[$mode]))
inc ($a)
end while
$flags := $UI_WAVEFORM_USE_SLICES {The flags are being updates}
if ($button_show_midi = 1)
$flags := $flags .or. $UI_WAVEFORM_USE_MIDI_DRAG
end if
attach_zone ($waveform_control,%zoneids[$mode],$flags) {the selected loop gets attached to the wf control}
end on
function UpdateFlags
{Using a function for updating and configuring different flag settings a lot easier}
$flags := $UI_WAVEFORM_USE_SLICES
if ($button_show_midi = 1)
$flags := $flags .or. $UI_WAVEFORM_USE_MIDI_DRAG
end if
$b := 0
while ($b < num_slices_zone (%zoneids[$mode]))
%slicestartpoints[($mode * 64) + $b] := zone_slice_start (%zoneids[$mode],$b)
inc ($b)
end while
end function
on ui_control ($mode)
{The selected beat is attached to the waveform control and the flags are updates}
call UpdateFlags
attach_zone ($waveform_control,%zoneids[$mode],$flags)
end on
on ui_control ($button_show_midi)
{Display or hides the midi drag'n' drop icon by updating the flags}
call UpdateFlags
set_ui_wf_property ($waveform_control,$UI_WF_PROP_FLAGS,0,$flags)
end on
{Display or hides the waveform control's table by updating the flags}
on ui_control ($button_play_cursor)
{Display or hides the play cursor}
set_ui_wf_property($waveform_control,$UI_WF_PROP_PLAY_CURSOR,0,0)
end on
on ui_control ($waveform_control)
{The different table values are stored in an array so that they can be recalled easily.}
end on
on note
allow_group ($ALL_GROUPS)
{This is the main loop}
while ($NOTE_HELD = 1)
{Play cursor}
if ($button_play_cursor = 1)
$playpos := get_event_par ($EVENT_ID,$EVENT_PAR_PLAY_POS)
set_ui_wf_property($waveform_control,$UI_WF_PROP_PLAY_CURSOR,0,$playpos)
end if
{Detecting the current slice}
$currentslice := 0
while(($playpos > %slicestartpoints[($mode * 64) + $currentslice]) and ($currentslice < num_slices_zone(%zoneids[$mode])))
inc($currentslice)
end while
{Changing the volume}
if ($currentslice = 0)
else
end if
if ($currentslice # $previousslice)
set_ui_wf_property($waveform_control,$UI_WF_PROP_TABLE_IDX_HIGHLIGHT,0,$currentslice - 1)
$previousslice := $currentslice
end if
wait (10000)
end while
end on
