Docs

TransportHandler


This class can be used to register callbacks that react on certain host tranport events. As of now, these events are supported:

In order to use it, just create an object with Engine.createTransportHandler() and then use the functions to register callbacks.

Execution modes

There are two execution modes for the callbacks: synchronous and asynchronous . Synchronous means that the callback will be executed directly in the audio thread as soon as a state change is detected. This should be used for any logic regarding playback (eg. for implementing custom arpeggiators).
However if you want your UI to react on the host transport state, you must use the asynchronous mode.

You can specify the mode when you pass in the callbacks into the register functions. Be aware that each transport handler has two slots, so you can register two different callbacks for the synchronous and asynchronous execution.

This example will demonstrate all features of this class by implementing a simple metronome that should react to your host.

HiseSnippet 1721.3oc4WstaaTDEd23rkFWLzhpP7yQQHUGvjZW5MABUGmKsVzjXEmVnRHUMd2isG5tyXlc1jZphD+jGi9XvO4QoOB8MnblYu3cC1oFKZ.AVIVdly4Ly27ctLmoiT3BggBok8JGNdDXY+9NcGyUC2bHkwsZukk8G5bnjxCGIjpCgPkUqwinggfmksco6qUxdkksLed88ZQ8obWXxTVVOVvbgGxBXpIy1o42x782g5AGxBxo8Ma11Uv2T3KhP.Uxot0Hp6ynCf8nZ0Vxwx9Ba6wTBYWEUAgV1K2R3Mt6Pww7X8eLKj0yGzCZX0EWn3o2Q36oQrdVqMGx785jdvCsrrc5LgFJESCW0YWlGKa9IzwkMBHSrHOeXuzYAuF4gW84Gd14f2xwv6JNcckrQpIRzX6RNs4JP1mhtf7vJVWqk9sK3ro.0fqVOf9LXGINHyhp2td8ZjaUu9ZeckxUJe8qSNbHKjf+oFBjvwb2gn9hHbbZ7.YHk64CRxwCYtCIGiNUxHe5XiEAfRqe.P3BjLpTFcsgJxQTIJl7Mjs4CXbXcWIfbUVH1ChWwpYfX2Hznd.gxILtOZAoeD2UwDbbVWZTHPXp3sVFo0wr4zHOl.+Et3dUJeZCE7V3lVsG9UM7.tGbbKpbMRkxunRYB9wW3R8ILODkljg0odd6gGh84UaTib25jOOyJxmQZbiZ3+2oFwvbZ6iMRer2ue+s.jQ.uVi29Hj3a6Uk4oWCixmjb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Bu7eWpRxvDGm8hB5hgutl9Y3Xyl5f7kz0uiGWWOVCht.2yL3M3mDgMzisSD1HUXd+yGDeRtjSW7oClF5MjxGaFS9N5Q.49.Gj5HsFy5QwM+A1ql2GEOZteT79tJb6S5pJrvB2EBXGhEeByO4iBwm5A+zA5P+7yuofJmpnWeucvC4TsoqtERSNzFAhHtpPNSo4NP8uviyW9e0ON+7qhYo4CtukT8URwXWVvHeXa9QfO1SiAieT5UMoyVLtdWrE1QCEbladm9AXiyrAC.YdrO0CzFJE1G5jYtZyC.eflO.9Sa9PLviJQdBVPtnw7yEmk+5SbhgKQmLR9uwMck9e4McmKWbbdrGATWo3otwOTRGKeQyL34lmzo3t5wjFVlGOoaxr950sBvJhO00US2eAxOS2lar.17kKfM2bAr4VKfM2dAr4NKfM28LsQeYzFQJQPbpHNQmsMunz1dattObSTu0e.zpy6sH


Class methods

setOnBeatChange

Registers a callback to changes in the musical position (bars / beats).

TransportHandler.setOnBeatChange(bool sync, var f)


Registers a callback that will be executed for every beat. The function must have two parameters:

  1. a counter for the current beat index (int )
  2. whether the beat is the beginning of a new bar (bool )

Be aware that a beat is defined by the denominator of the time signature (so a 6/8 time signature will call this method twice as often as a 3/4 time signature).

setOnSignatureChange

Registers a callback to time signature changes.

TransportHandler.setOnSignatureChange(bool sync, var f)


Registers a callback that will be executed as soon as the time signature changes. It expects a function with two parameters:

  1. Nominator
  2. Denominator

So for a 6/8 time signature, the first parameter will be 6 and the second one will be 8.

The callback you supply here is also executed once at registration (so that it will pick up the current time signature).

setOnTempoChange

Registers a callback to tempo changes.

TransportHandler.setOnTempoChange(bool sync, var f)


Registers a callback that will be executed as soon as the host tempo changes. It expects a function with a single parameter that will contain the tempo value.

It will also be executed once when you register this callback so you can query the current tempo.

setOnTransportChange

Registers a callback to transport state changes (playing / stopping).

TransportHandler.setOnTransportChange(bool sync, var f)


Registers a callback that will be executed as soon as the host playback is being started / stopped.

It expects a function with a single parameter that will contain the transport state as bool value.

This function will also be called once at registration.