Update the playhead positions of multiple ui_waveform elements

rossc
rossc Member Posts: 10 Member
edited February 2022 in Scripting Workshop

I have an instrument with multiple waveform UI elements. I can update the playhead position of a single waveform element using the code seen in the reference manual:

on note

	while ($NOTE_HELD = 1)

		$playPos := get_event_par($EVENT_ID, $EVENT_PAR_PLAY_POS)

		set_ui_wf_property($layer1RiseWf, $UI_WF_PROP_PLAY_CURSOR, 0, $playPos)

		wait(10000)

	end while

end on

How can I update the playhead position of multiple zone's waveforms, all of which are playing simultaneously?

Thanks! 😁

Answers

  • EvilDragon
    EvilDragon Moderator Posts: 1,022 mod

    You would do that in listener callback, not in note callback.

  • rossc
    rossc Member Posts: 10 Member

    @EvilDragon I've placed the waveform-updater code into a listener callback as below.

    on listener
    	if ($PLAYED_VOICES_INST # 0)
    		$playPos := get_event_par($eventID, $EVENT_PAR_PLAY_POS)
    		set_ui_wf_property($layer1RiseWf, $UI_WF_PROP_PLAY_CURSOR, 0, $playPos)
    	end if
    end on
    

    The $eventID variable is being given the value of $EVENT_ID in the on note callback. However, as you can imagine, this will only update the playhead position for a single waveform. How can I adapt this to set the playhead position for the waveforms of multiple samples simultaneously? Do I have to get multiple event IDs?

  • EvilDragon
    EvilDragon Moderator Posts: 1,022 mod

    Yes, you would need to play an event for each layer in that case.

  • rossc
    rossc Member Posts: 10 Member

    @EvilDragon How can I play an event for each layer?

  • EvilDragon
    EvilDragon Moderator Posts: 1,022 mod

    Combination of play_note() and set_event_par_arr() along with $EVENT_PAR_ALLOW_GROUP.

Back To Top