# View waveform in kontakt GUI



## pjbridger (Jan 11, 2013)

I am trying to create a kontakt instrument for a loop which has displays the waveform and slices within the GUI 

This function is already in use in several libraries including Damage and the big fish KLI series

Does anyone know where to start with creating a script like this?

My scripting level is pretty low at the moment and I'm not sure where to start

Any advice would be appreciated
:D [/u]


----------



## pjbridger (Jan 15, 2013)

Due to some advice from mk282

I have been able to do some much better searching on this topic,

It has revealed these threads by Lindon and jdawg

http://www.vi-control.net/forum/viewtop ... uiwaveform

http://www.vi-control.net/forum/viewtop ... uiwaveform

I have created a small script to show the wave form using these sources,

The script is great for my uses, but i would like the play marker to follow the sample playback when a key is pressed and also the zone markers to be visible on the waveform,

Can anyone help me with this?



> on init
> make_perfview
> 
> 
> ...



I found this script which I think should show the zones but it doesnt seem to work for me?




> on init
> declare ui_waveform $Waveform(6,6)
> attach_zone ($Waveform,find_zone(”Test”),$UI_WAVEFORM_USE_SLICES)
> end on


----------



## polypx (Jan 15, 2013)

you need to find the ID of your zone using find_zone 
$which_zone := find_zone("Test")

The $UI_WAVEFORM_USE_TABLE and $UI_WAVEFORM_USE_MIDI_DRAG flags will only
work if $UI_WAVEFORM_USE_SLICES is already set:
attach_zone($my_waveform,$which_zone,$UI_WAVEFORM_USE_SLICES) 

and then set the use table flag:
attach_zone($my_waveform,$which_zone,$UI_WAVEFORM_USE_TABLE) 


In this, and in your second example, "Test" needs to be the name of the sample without extension.


----------



## pjbridger (Jan 15, 2013)

Thank you very much for your reply Polypx,

I have amended the code, but it still does not seem to be working,

This is what I added,



> on init
> 
> make_perfview
> 
> ...



the test file im using is called Gibbo Message Alert :!: 

Apologies if i have done this completely wrong,

I am a real beginner :oops:


----------



## polypx (Jan 15, 2013)

Try this, replacing "sine880" with the name of your waveform. Be careful, it has to be exactly the correct spelling.


```
on init
make_perfview
declare $play_pos
declare ui_waveform $my_waveform (4, 4)
declare $which_zone
$which_zone := find_zone("sine880")
attach_zone ($my_waveform, $which_zone, 0)
attach_zone($my_waveform, $which_zone,$UI_WAVEFORM_USE_SLICES .or. $UI_WAVEFORM_USE_TABLE)
end on


on note
while ($NOTE_HELD = 1)
$play_pos := get_event_par($EVENT_ID,$EVENT_PAR_PLAY_POS)
set_ui_wf_property($my_waveform,$UI_WF_PROP_PLAY_CURSOR, 0,$play_pos)
wait (10000)
end while
end on
```

The $UI_WAVEFORM_USE_TABLE flag will only work if $UI_WAVEFORM_USE_SLICES is already set.


Also, make sure no other scripts are present when you're testing this, since they can interfere with the waveform cursor.


----------



## pjbridger (Jan 15, 2013)

Thank you so so much!

That works perfectly,

Thank you for taking the time to help me with my problem, I am extremely grateful,

:D


----------



## StayOnIt4Life23 (Apr 20, 2013)

Can you do a (find_zone) by (group name)? B/C I have 100s of loops that I'm setting up! But I would like to use one script in my resource folder to do this! Please Help. Thanks


----------



## d.healey (Jul 2, 2016)

StayOnIt4Life23 said:


> Can you do a (find_zone) by (group name)? B/C I have 100s of loops that I'm setting up! But I would like to use one script in my resource folder to do this! Please Help. Thanks


I've just been doing a similar thing so although this thread is old I thought I'd post my solution here for anyone else who stumbles across it. This is how I find the zone ID for a specific note for a specific group ID.


```
taskfunc kt.get_zone_id(note_num, group) -> return

  declare $id

  $id := play_note(note_num, 1, 0, 1) //Play blip note
  change_vol($id, -200000, 0) //Silence note

  tcm.wait(1) //Wait a mo

  set_event_par_arr($id, $EVENT_PAR_ALLOW_GROUP, 0, $ALL_GROUPS) //Disallow all groups
  set_event_par_arr($id, $EVENT_PAR_ALLOW_GROUP, 1, group) //Enable passed group

  return := get_event_par($id, $EVENT_PAR_ZONE_ID)

end taskfunc
```


----------



## MirtKlaar (May 9, 2018)

My problem is how to move the ui_waveform. Everytimes I use the move_control_px command the ui_waveform goes in the correct position I wish but with iths dimensions very small like a button size :(


----------



## EvilDragon (May 9, 2018)

You need to adjust width/height in pixels as well, when changing the x, y position in pixels.


----------



## MirtKlaar (May 10, 2018)

Thank you Evil, I suspected something that


----------



## DidierN (Nov 10, 2018)

Hi, i want to change de waveform view for each zone.
Works perfect for one zone only.
How i can made for each zone please.
Best Regards,
Didier.

This is my code.

declare $play_pos
declare ui_waveform $my_waveform (4, 7)
declare $which_zone
$which_zone := find_zone("Seven - Ethnic - 01_ms0_036_c1")
attach_zone ($my_waveform, $which_zone, 0)
attach_zone($my_waveform, $which_zone,$UI_WAVEFORM_USE_SLICES .or. $UI_WAVEFORM_USE_TABLE)


----------



## EvilDragon (Nov 10, 2018)

Just use a different zone ID in attach_zone (in your code, $which_zone variable), depending on which zone you want to show up.


----------



## DidierN (Nov 10, 2018)

Thanks a lot EvilDragon.
I have 8 differents zone for different samples.
Then i don't understand with code i have to add.
Could you please make me a exemple for 2 different zones.
Best Regards,
Didier.


----------



## EvilDragon (Nov 10, 2018)

Do you want to show them on the same ui_waveform, or multiple? In case of multiple ui_waveforms, it's easy, just attach a different zone to each one.

Also you don't need to use attach_zone() twice like you did above - that's completely unnecessary. Just the second one will do.


----------



## DidierN (Nov 10, 2018)

Thanks again.
So, i want to see my waveform 1 if i play c1(the zone) and i want to see my waveform 2 if i play c#1, etc..Not see all the waveform at the same time, juste see my waveform that i play.


----------

