What's new

Wavetable zone waveform

Claud9

Active Member
Hello,
I'm doing some script experiments with the new wavetable functions in K6.

Everything is working fine with 1 group/zone

But if I try with a 4 group/zones instrument I have some problems showing the correct zone/waveform...

This is the code I have in the on init

Code:
declare ui_wavetable $wt
set_control_par(get_ui_id($wt), $CONTROL_PAR_WT_VIS_MODE, $NI_WT_VIS_2D)
make_persistent($wt)
read_persistent_var($wt)

declare ui_menu $waveform
while ($i < $NUM_GROUPS)
  add_menu_item($waveform,group_name($i),$i)
     inc($i)
   end while

if ($waveform=0)
set_control_par(get_ui_id($wt),$CONTROL_PAR_WT_ZONE,1)
end if
if ($waveform=1)
set_control_par(get_ui_id($wt),$CONTROL_PAR_WT_ZONE,2)
end if
if ($waveform=2)
set_control_par(get_ui_id($wt),$CONTROL_PAR_WT_ZONE,3)
end if
if ($waveform=3)
set_control_par(get_ui_id($wt),$CONTROL_PAR_WT_ZONE,4)
end if

make_persistent($waveform)
read_persistent_var($waveform)
end on

in the on ui_control I have this:

Code:
on ui_control ($waveform)
  $i :=0
  while ($i < $NUM_GROUPS)
   purge_group($i,0)
   inc($i)
end while
purge_group($waveform,1)
if ($waveform=0)
set_control_par(get_ui_id($wt),$CONTROL_PAR_WT_ZONE,1)
end if
if ($waveform=1)
set_control_par(get_ui_id($wt),$CONTROL_PAR_WT_ZONE,2)
end if
if ($waveform=2)
set_control_par(get_ui_id($wt),$CONTROL_PAR_WT_ZONE,3)
end if
if ($waveform=3)
set_control_par(get_ui_id($wt),$CONTROL_PAR_WT_ZONE,4)
end if
end on

Thanks in advance for any help
 
Last edited:

EvilDragon

KSP Wizard
You need to know the zone ID of the waveform you want to show. You cannot just use raw numbers without consequence. The way to do this is the same as with ui_waveform control... You need those zone IDs for each group you want to display the waveform/wavetable for. Best use a lookup table once you get zone IDs (preferably after your instrument structure is completed as far as sample mapping is concerned).
 
OP
Claud9

Claud9

Active Member
Thread starter
  • Thread Starter
  • Thread Starter
  • #3
You need to know the zone ID of the waveform you want to show. You cannot just use raw numbers without consequence. The way to do this is the same as with ui_waveform control... You need those zone IDs for each group you want to display the waveform/wavetable for. Best use a lookup table once you get zone IDs (preferably after your instrument structure is completed as far as sample mapping is concerned).
Thanks for the help.
Zone ID 1 2 3 4 are the one I can find in the "expert - zone" tab.
The script I posted work. I can see the waveforms but is not working properly.
First problem: If I save an instrument that shows for example waveform of Zone ID 1 when I reload the instrument the waveform does not show up.
Second problem: when I select one of the groups with the menu the first time the waveform is not loaded and stay the same of the previous group, It's loaded only after I re-select that group with the menu.
 

EvilDragon

KSP Wizard
You need to set the waveform AFTER read_persistent_var for the menu in init callback. But better yet, do it in persistence_changed callback and then you don't need to use read_persistent_var at all.
 
OP
Claud9

Claud9

Active Member
Thread starter
  • Thread Starter
  • Thread Starter
  • #5
You need to set the waveform AFTER read_persistent_var for the menu in init callback. But better yet, do it in persistence_changed callback and then you don't need to use read_persistent_var at all.
I have already tried both your suggestions but the problem remains the same: when I reload the saved instrument the waveform does not show up and if I change group/zone with the menu the waveform change only if I select with the menu the group/zone twice, It never changes at the first attempt. Once I have correctly shown all waveforms than they show up correctly at the first attempt when I change group/zone with the menu.
 

EvilDragon

KSP Wizard
It has to work after moving the $CONTROL_PAR_WT_ZONE part in "on persistence_changed". Tried that here and it works. You're doing something else wrong, then.


(Also, there's no point in making the ui_wavetable control persistent at all.)
 
OP
Claud9

Claud9

Active Member
Thread starter
  • Thread Starter
  • Thread Starter
  • #7
this is working now when I reload the instrument but is not working in the ui_control callback. I have always to reload twice the group in order to have Kontakt show the correct waveform. is this the correct way to show waveform in the ui_control callback?

Code:
on init
make_perfview
set_ui_width_px(170)
 
declare $i
declare ui_wavetable $wt
set_control_par(get_ui_id($wt), $CONTROL_PAR_WT_VIS_MODE, $NI_WT_VIS_2D)
 
declare ui_menu $waveform
make_persistent($waveform)
read_persistent_var($waveform)

while ($i < $NUM_GROUPS)
add_menu_item($waveform,group_name($i),$i)
inc($i)
end while
end on
on persistence_changed
if ($waveform=0)
set_control_par(get_ui_id($wt),$CONTROL_PAR_WT_ZONE,1)
end if
if ($waveform=1)
set_control_par(get_ui_id($wt),$CONTROL_PAR_WT_ZONE,2)
end if
if ($waveform=2)
set_control_par(get_ui_id($wt),$CONTROL_PAR_WT_ZONE,3)
end if
if ($waveform=3)
set_control_par(get_ui_id($wt),$CONTROL_PAR_WT_ZONE,4)
end if
end on

on ui_control ($waveform)
$i :=0
while ($i < $NUM_GROUPS)
purge_group($i,0)
inc($i)
end while
purge_group($waveform,1)
if ($waveform=0)
set_control_par(get_ui_id($wt),$CONTROL_PAR_WT_ZONE,1)
end if
if ($waveform=1)
set_control_par(get_ui_id($wt),$CONTROL_PAR_WT_ZONE,2)
end if
if ($waveform=2)
set_control_par(get_ui_id($wt),$CONTROL_PAR_WT_ZONE,3)
end if
if ($waveform=3)
set_control_par(get_ui_id($wt),$CONTROL_PAR_WT_ZONE,4)
end if
end on
 
Last edited:
OP
Claud9

Claud9

Active Member
Thread starter
  • Thread Starter
  • Thread Starter
  • #9
It should work, I'm not having any problems changing the waveforms from ui_control callback.
I really don't understand
It should work, I'm not having any problems changing the waveforms from ui_control callback.
Just tested again on a second computer, same problem. I have to load twice the same group/zone with the menu in order to load the correct waveform. On the first attempt, the waveform is not loaded. Have you tried to save and reopen the instrument? When I do so I always have the waveform problem. Is there another method to load wavetable waveform that I can try in the ui_control callback? Thank in advance for any help
 

EvilDragon

KSP Wizard
Have you tried to save and reopen the instrument?

Yes, works fine here.

Is there another method to load wavetable waveform that I can try in the ui_control callback?

No. That's the proper/only command to load wavetable waveforms into ui_wavetable widget. You have some other problem in the code, then, because it all works just fine here.

Code:
on init
   set_ui_height(2)

   declare $i

   declare ui_menu $Wave
   declare ui_wavetable $WT

    $i := 0
    while ($i < $NUM_GROUPS)
       add_menu_item($Wave, "Group " & $i + 1, $i)
       inc($i)
   end while
   
   make_persistent($Wave)

   set_control_par(get_ui_id($WT), $CONTROL_PAR_WIDTH, 200)
   set_control_par(get_ui_id($WT), $CONTROL_PAR_HEIGHT, 75)
   move_control_px($WT, 158, 2)
end on

function LoadWT()
   set_control_par(get_ui_id($WT), $CONTROL_PAR_WT_ZONE, $Wave)
end function

on persistence_changed
   call LoadWT()
end on

on ui_control ($Wave)
    $i := 0
    while ($i < $NUM_GROUPS)
       purge_group($i, 0)
       inc($i)
   end while
   purge_group($i, $Wave)

   call LoadWT()
end on

In the above example, wavetables have zone IDs 0, 1, 2, 3.
 
Last edited:
OP
Claud9

Claud9

Active Member
Thread starter
  • Thread Starter
  • Thread Starter
  • #11
Thanks for the code. It is supposed to work as it is or I need to add something?
I have created a new instrument from scratch - 4 groups and exactly the same zone IDs of your example, but is not working and I have exactly the same problems as before.
Also, groups were not playing at all, I had to change this line of your code "
purge_group($i, $Wave)" with this : "purge_group($Wave,1)" in order to have the selected group playing. But as before if I save the instrument and I releoad it no waveform is shown and in order to view the correct waveform I have to select twice each group/zone. The same problem also with saved Snapshots.

Yes, works fine here.



No. That's the proper/only command to load wavetable waveforms into ui_wavetable widget. You have some other problem in the code, then, because it all works just fine here.

Code:
on init
   set_ui_height(2)

   declare $i

   declare ui_menu $Wave
   declare ui_wavetable $WT

    $i := 0
    while ($i < $NUM_GROUPS)
       add_menu_item($Wave, "Group " & $i + 1, $i)
       inc($i)
   end while
  
   make_persistent($Wave)

   set_control_par(get_ui_id($WT), $CONTROL_PAR_WIDTH, 200)
   set_control_par(get_ui_id($WT), $CONTROL_PAR_HEIGHT, 75)
   move_control_px($WT, 158, 2)
end on

function LoadWT()
   set_control_par(get_ui_id($WT), $CONTROL_PAR_WT_ZONE, $Wave)
end function

on persistence_changed
   call LoadWT()
end on

on ui_control ($Wave)
    $i := 0
    while ($i < $NUM_GROUPS)
       purge_group($i, 0)
       inc($i)
   end while
   purge_group($i, $Wave)

   call LoadWT()
end on

In the above example, wavetables have zone IDs 0, 1, 2, 3.
 

EvilDragon

KSP Wizard
It's working fine over here. Yeah I made a typo there in purge_group(), but otherwise it's working just fine over here.
 

Attachments

  • WT Test.rar
    464.6 KB · Views: 24
OP
Claud9

Claud9

Active Member
Thread starter
  • Thread Starter
  • Thread Starter
  • #13
Thanks for sharing, but it's still not working here (pls see attached video). I have tested with both Full version and Player on two different Mac, the problem is always the same: I have to select twice the group in order to see the correct waveform. It's a bug of K6 Mac version?
 

Attachments

  • WT test 2.zip
    990 KB · Views: 7

EvilDragon

KSP Wizard
Yeah that's bizarre, it works totally fine over here...


Can any other Mac users here test the NKI I posted, please?
 

polypx

Hoser
Mac here. Strange behaviour for me as well. It updates if you select the menu item twice, or else after you select you hit the exclamation mark.

Once all four have been selected successfully once it works fine after that.
 

geronimo

Active Member
If we must see a Waveform interface, I see just the Menu, with this Script .
I'm under SIERRA 10.12.6. _

EDIT:sorry, it's work fine with your .NKI _
 
Last edited:
OP
Claud9

Claud9

Active Member
Thread starter
  • Thread Starter
  • Thread Starter
  • #17
If we must see a Waveform interface, I see just the Menu, with this Script .
I'm under SIERRA 10.12.6. _

EDIT:sorry, it's work fine with your .NKI _
Load the .NKI and then try to change the group. The waveform should update only if you select the menu item twice. You have this problem only right after loading the instrument, as polypx wrote after you have correctly selected all groups twice then the waveform is loaded correctly the first time you change group.
 
Last edited:

EvilDragon

KSP Wizard
Weirdity.


Can you try my NKI but completely remove the purging part (and make sure all groups are loaded into memory)? See what happens.

If it works then, I guess it might be that purging somehow influences retrieving the waveform for some reason. Try then adding a short wait(50000) after purging but BEFORE setting the waveform.
 
OP
Claud9

Claud9

Active Member
Thread starter
  • Thread Starter
  • Thread Starter
  • #19
adding wait(50000) made it and now It works fine! remain a mystery why on PC K6 is working without!
 
Top Bottom