Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 41 Next »

HALion provides two threads:

  • Parameter changes and the storage of them are handled by the Controller thread.
  • MIDI event processing and sound reproduction happens in the Processor thread.

You can think of these threads as two sections of code that are exectued in concurrency by HALion. Basically, the two threads are needed to split longer lasting function calls from timing critical function calls. The functions that are called in the Controller thread are executed only as fast as required, while the functions that are called in the Processor thread are executed within an ASIO block.

On this page:

The information whether a function can be called in the Controller thread, the Processor thread, or in both threads, can be found on the Reference pages below the description of each function.

It looks like this:

Available in: Controller, Processor.

Script Error - Wrong Thread

If you call a function in the wrong thread, the script module will output an error message.

Example 1

  Example for a script error when calling a function in the wrong thread.
  The onNote callback runs in the Processor thread. openURL runs in the Controller thread.
  Therefore, openURL cannot be called in onNote. The script produces a script error when playing a note.

function onNote(event)      

The output message for the script error of the above example looks like this:

Script Error - Wrong Thread

If this ever happens to you, please review your code and try to place the function call elsewhere in your script, for example. Alternatively, you could use runAsync.

Using runAsync

Through runAsync you get access to the functions of the Controller thread also in the Processor thread. The execution of runAsync takes at least one audio block, or longer, depending on the function which was called. The callback which called runAsync is put on hold until the function has completed. Please be aware of this when using runAsync.

-- use runAsync to call openURL within onNote

function onNote(event)
  runAsync(function() openURL("") end)

Functions of the Processor thread cannot be called in the Controller thread.

Controller Functions

Processor Functions

  • No labels