# Ui_waveform_use_table



## pjbridger (Jan 22, 2013)

Hi,

I am trying to use the UI_Waveform_use_table to change the pitch of slices within a sample,

I dont really know where to start,

can anyone help?

Thanks,

Pj


----------



## mk282 (Jan 22, 2013)

Check this NKI out:

http://www.mediafire.com/download.php?3ee7d9zqsk59azi


----------



## pjbridger (Jan 24, 2013)

Thank you soooo much mk282,

This is more than i needed!

:D


----------



## pjbridger (Feb 5, 2013)

I have been trying to edit and understand the ui_waveform script you sent me previously,

Unfortunately i am embarrassed to say it is way above my current level,

I am trying to adapt the script to work with a single waveform and also add controls for pitch and volume,

I have been trying to remove the buttons and the drop down loop menu, to make the script work with a single waveform making it easier for me to understand and modify but every time i remove these controls the script breaks further down,

this is what i have so far



> on init
> message ("")
> set_ui_height (8)
> make_perfview
> ...




I am getting an error at line 33 with the $which_zone argument

it says := expected

can anyone help please


----------



## StayOnIt4Life23 (Apr 20, 2013)

I been looking for help with this one to!!!
Did you get it? If so help me....


----------



## StayOnIt4Life23 (Apr 20, 2013)

How do you add more then two loops in the code?? Like I need to add about 16-20 loops to the code, I see some of the things that need to be added like declare $a,$b BUT how do you add $c,$d,$e and so on?

and begin the Command from here?

$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}
if ($Filter = 1)
set_ui_wf_property($waveform_control,$UI_WF_PROP_TABLE_VAL,$b,%slicefilter[($menu_beat_select * 64) + $b])
else
set_ui_wf_property($waveform_control,$UI_WF_PROP_TABLE_VAL,$b,%slicepan[($menu_beat_select * 64) + $b])
end if
inc ($b)
end while
inc ($a)
end while

$a := 0
while ($a < num_slices_zone (%zoneids[$menu_beat_select]))
if ($Filter = 1)
set_ui_wf_property($waveform_control,$UI_WF_PROP_TABLE_VAL,$a,%slicefilter[($menu_beat_select * 64) + $a])
else
set_ui_wf_property($waveform_control,$UI_WF_PROP_TABLE_VAL,$a,%slicepan[($menu_beat_select * 64) + $a])
end if
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
if ($button_show_table = 1)
$flags := $flags .or. $UI_WAVEFORM_USE_TABLE
end if

attach_zone ($waveform_control,%zoneids[$menu_beat_select],$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
if ($button_show_table = 1)
$flags := $flags .or. $UI_WAVEFORM_USE_TABLE
end if

$b := 0
while ($b < num_slices_zone (%zoneids[$menu_beat_select]))
%slicestartpoints[($menu_beat_select * 64) + $b] := zone_slice_start (%zoneids[$menu_beat_select],$b)
if ($Filter = 1)
set_ui_wf_property($waveform_control,$UI_WF_PROP_TABLE_VAL,$b,%slicefilter[($menu_beat_select * 64) + $b])
else
set_ui_wf_property($waveform_control,$UI_WF_PROP_TABLE_VAL,$b,%slicepan[($menu_beat_select * 64) + $b])
end if
inc ($b)
end while
end function

on ui_control ($menu_beat_select)
{The selected beat is attached to the waveform control and the flags are updates}
call UpdateFlags
attach_zone ($waveform_control,%zoneids[$menu_beat_select],$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

on ui_control ($button_show_table)
{Display or hides the waveform control's table by updating the flags}
call UpdateFlags
set_ui_wf_property ($waveform_control,$UI_WF_PROP_FLAGS,0,$flags)
end on

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($Filter)
if ($Filter = 1)
$Pan := 0
end if

call UpdateFlags
end on

on ui_control($Pan)
if ($Pan = 1)
$Filter := 0
end if

call UpdateFlags
end on

on ui_control ($waveform_control)
{The different table values are stored in an array so that they can be recalled easily.}
if ($Filter = 1)
%slicefilter[($menu_beat_select * 64) + $waveform_control] := get_ui_wf_property($waveform_control,$UI_WF_PROP_TABLE_VAL,$waveform_control)
else
%slicepan[($menu_beat_select * 64) + $waveform_control] := get_ui_wf_property($waveform_control,$UI_WF_PROP_TABLE_VAL,$waveform_control)
end if
end on

on note
disallow_group ($ALL_GROUPS)
allow_group ($menu_beat_select)

{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[($menu_beat_select * 64) + $currentslice]) and ($currentslice < num_slices_zone(%zoneids[$menu_beat_select])))
inc($currentslice)
end while
{Changing the filter cutoff}
if ($currentslice = 0)
set_engine_par($ENGINE_PAR_CUTOFF,%slicefilter[($menu_beat_select * 64) + $currentslice],$menu_beat_select,0,-1)
set_engine_par($ENGINE_PAR_PAN,%slicepan[($menu_beat_select * 64) + $currentslice],$menu_beat_select,0,-1)
else
set_engine_par($ENGINE_PAR_CUTOFF,%slicefilter[($menu_beat_select * 64) + $currentslice - 1],$menu_beat_select,0,-1)
set_engine_par($ENGINE_PAR_PAN,%slicepan[($menu_beat_select * 64) + $currentslice],$menu_beat_select,0,-1)
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


----------



## StayOnIt4Life23 (Apr 21, 2013)

OKAY I THINK I WAS ABLE TO ADD A (LOOP3) IT'S SHOWING UP AND WORKING SO FAR SO GOOD!!

BUTTTT I'M GETTING THIS ERROR IN KONTALT (SCRIPT WARNING: WHILE LOOP TERMINATED(TOO MUCH ITERATIONS, NO WAIT STATERMENT)

ANY ONE KNOW HOW TO FIX THIS????? PLEASE HELP 

CODE:


{
**************************************
WAVEFORM CONTROL EXAMPLE
last update: 2011/02/03
**************************************
}

on init
message ("")
set_ui_height (8)
make_perfview

declare $a {A simple counter}
declare $b {Another simple counter}
declare $c {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 !filenames[3] {A string array to store the filenames of the loops - please note that there's no .wav}
!filenames[0] := "Loop 1"
!filenames[1] := "Loop 2"
!filenames[2] := "Loop 3"

declare %slicestartpoints[256] {An array to store the samplestart positions of each slice}

declare %zoneids[3] {An array to store the ids of the used zones}

declare ui_menu $menu_beat_select {Dropdown menu to select a loop}
make_persistent ($menu_beat_select)
read_persistent_var ($menu_beat_select)
add_menu_item ($menu_beat_select,"Beat 1",0)
add_menu_item ($menu_beat_select,"Beat 2",1)
add_menu_item ($menu_beat_select,"Beat 3",2)
declare ui_waveform $waveform_control (6,12) {The actual waveform control}
move_control ($waveform_control,1,2) 

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_show_table {A simple button that shows the waveform's table}
make_persistent ($button_show_table)
read_persistent_var ($button_show_table)
set_control_par_str (get_ui_id($button_show_table),$CONTROL_PAR_TEXT,"Table")
move_control ($button_show_table,2,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,3,14)



$a := 0
while ($a < 3)
%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[$menu_beat_select]))

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
if ($button_show_table = 1)
$flags := $flags .or. $UI_WAVEFORM_USE_TABLE
end if

attach_zone ($waveform_control,%zoneids[$menu_beat_select],$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
if ($button_show_table = 1)
$flags := $flags .or. $UI_WAVEFORM_USE_TABLE
end if

$b := 0
while ($b < num_slices_zone (%zoneids[$menu_beat_select]))
%slicestartpoints[($menu_beat_select * 64) + $b] := zone_slice_start (%zoneids[$menu_beat_select],$b)
end while

$c := 0
while ($c < num_slices_zone (%zoneids[$menu_beat_select]))
%slicestartpoints[($menu_beat_select * 64) + $c] := zone_slice_start (%zoneids[$menu_beat_select],$c)	


inc ($b)
inc ($c)
end while
end function




on ui_control ($menu_beat_select)
{The selected beat is attached to the waveform control and the flags are updates}
call UpdateFlags
attach_zone ($waveform_control,%zoneids[$menu_beat_select],$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

on ui_control ($button_show_table)
{Display or hides the waveform control's table by updating the flags}
call UpdateFlags
set_ui_wf_property ($waveform_control,$UI_WF_PROP_FLAGS,0,$flags)
end on

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 note
disallow_group ($ALL_GROUPS)
allow_group ($menu_beat_select)

{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[($menu_beat_select * 64) + $currentslice]) and ($currentslice < num_slices_zone(%zoneids[$menu_beat_select])))
inc($currentslice)
end while


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


----------



## topaz (May 31, 2019)

Great script ED (I am sure this must be your amazing work) 

Can anyone work out a way to get the tables to work on all groups, at the moment it only works on the 1st group.

I tried adding allow_group ($ALL_GROUPS) but that doesn't work.

any help would be awesome


----------



## EvilDragon (May 31, 2019)

topaz said:


> (I am sure this must be your amazing work)



Actually it's not. 

The script is made with tables per loop in mind, so it's not exactly a simple one-line change. When you select Beat 1, you get filter and pan tables for the loop in first group, when you select Beat 2, you get those for the loop in second group.


----------



## topaz (May 31, 2019)

hehe, ok 

workaround is to move slices mapped into group 1. 



EvilDragon said:


> Actually it's not.
> 
> The script is made with tables per loop in mind, so it's not exactly a simple one-line change. When you select Beat 1, you get filter and pan tables for the loop in first group, when you select Beat 2, you get those for the loop in second group.


----------



## EvilDragon (May 31, 2019)

I guess you could do that, yeah.


----------

