# Waveforms 101....problems problems....



## Lindon (Mar 21, 2011)

OK so I thought I'd try the new 4.2 waveform ui_contol, I examined the NI example code in the manual (I thought carefully..) and wrote this:


```
{
display experiment
}

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

    set_control_par($INST_ICON_ID, $CONTROL_PAR_HIDE, $HIDE_WHOLE_CONTROL) 

    declare $idx
    declare $my_note
    declare $play_pos

    declare ui_waveform $my_waveform(5,5)
    attach_zone($my_waveform,0,$UI_WAVEFORM_USE_TABLE)

    set_ui_wf_property ($my_waveform,$UI_WF_PROP_PLAY_CURSOR,0,1)
end on


on note
    ignore_event($EVENT_ID)

    for $idx := 56 to 71
        $my_note := play_note($idx,100,0,$DURATION_QUARTER  )

        $play_pos := get_event_par($my_note,$EVENT_PAR_PLAY_POS)

        message($play_pos)

        set_ui_wf_property($my_waveform,$UI_WF_PROP_PLAY_CURSOR,0,$play_pos)

        wait ($DURATION_QUARTER)

    end for

end on
```

This doesn't work!, - by which I mean the sequence of notes play OK, the waveform sits there on the interface (again OK) but the cursor never shows up....

Clearly I'm missing something...everything works fine if I replace
$my_note with $EVENT_ID (and undocumenting line 1 of the NCB), but on checking $my_note does indeed contain the EVENT_ID of "my_note" however $play_pos is returning 0 (zero) ...:-(

maybe I dont understand how set_ui_wf_property is implemented, anyone have any good experiences wiht this?

Regards

lindon


----------



## Lindon (Mar 21, 2011)

OK got it...

```
for $idx := 56 to 71 
        $my_note := play_note($idx,100,0,$DURATION_QUARTER  ) 

        for $idx2 := 0 to 10000
             $play_pos := get_event_par($my_note,$EVENT_PAR_PLAY_POS) 

             message($play_pos) 

            set_ui_wf_property($my_waveform,$UI_WF_PROP_PLAY_CURSOR,0,$play_pos) 

            wait ($DURATION_QUARTER/10000) 
      end for
end for
```

now to work out how to make it more accurate than $DURATION_QUARTER/10000 ....grrrrr

As I'm here....
Anyone know how zones are "named" as in find_zone(”Test”) where do I see "Test" as an attribute of a zone in the Mapping editor?

and...what does $UI_WF_TABLE_IDX_HIGHLIGHT expect in positions X and Y:

set_ui_wf_property($my_waveform,$UI_WF_TABLE_IDX_HIGHLIGHT,X,Y)

??


----------



## EvilDragon (Mar 22, 2011)

Use the Monitor tab set to Zones to see zone names and IDs. 

About $UI_WF_PROP_TABLE_IDX_HIGHLIGHT, it expects slice index as X, and 0 or 1 (off/on highlight for that slice) for Y.


----------



## Lindon (Mar 22, 2011)

Nope, cant get $UI_WF_PROP_TABLE_IDX_HIGHLIGHT to work in any way...

I have a loop divided into 16 slices and mapped to 16 keys(so 16 "zones")...in the MONITOR(thanks Mario) I see the zones all named "Drums" with 16 slices each numbered from 0 to 15...all sensible so far....

I attach the zones to the waveform thus:

attach_zone($my_waveform, 0, $UI_WAVEFORM_USE_TABLE) 

and the whole of the loops "wave" shows up nicely in the UI, if I change the second param.(currently "0") to any number in the range 0->15 all is still fine, if I change it to an index beyond this, say 16, then quite reasonably the loops "wave" doesnt show the waveform. All this is still OK I think...

now I have a little for loop to play each note(using $idx)....and in it I say this:

set_ui_wf_property($my_waveform, $UI_WF_PROP_TABLE_IDX_HIGHLIGHT, $idx,0)

..no highlighting happens...

I change the last param from 0 to 1....still nothing happens...
I swap params 3 and 4 around, nothing happens...
I change the 0 to 16 or even 10000...still nothing happens...

I've used get_ui_wf_property, and yes I'm setting the value of this index..to no avail...

Maybe I don't understand what this is supposed to do, I want to see the slice highlighted in the waveform for the played note, does this even do this? t

The manual says it: "highlights the indexed slice within the UI waveform"..only with my feeble attempts it doesn't... :( 


Has anyone got a clue how this thing works?


----------

