Calling Halion from other application


Is there any way to “remote control” a Halion Script from an external program?
I have a piece of external software (written in C#/.NET) that creates a MIDI-Arrangement and is able to send this to an already set up Halion Multi Instrument instance via MIDI.
My software also creates an AudioFile in the same length as the Midi File that should be played simultaneously.
One approach is mix both on audio output level, by routing both the Halion Output and the Audio Output generated by another player to another mixing environment, but I am looking for ways to achieve this only within Halion (with Halion as the only device that feeds the final audio output bus).

I started with two approaches, but got stuck with both of them:

  1. Creating a macro page that has a function to load a new sound: How can I (remotely) specify the filename and call my “loadSomeAudio(filename)” function from the outside? Is it possible to connect a button on a macro page to a midi-control change event for example? If so, is there any way to submit a string (filename) together with such an event?
  2. Code-Generating a new lua script on the fly which has all the needed code and parameters to load the sound in it: How can I (remotely) tell Halion to execute a script? This leads to the same sub-questions as approach 1: Connecting a button to an event and passing parameters.

Is there any solution on these approaches or is there a completely different way I tend to overlook?

Thanks for your help.

Hi Stefan,

Not sure if you can remote control Halion from different application.

Can you load the audio file to a sample zone and set it to one shot mode? Then you could trigger the playback via midi event.

1 Like

Don’t know if you can load script remotely but you can use lue dofile and require. I just quickly tried to read values from a text file and it seems to work.

function onNote(e)
	print("a = ", a, " b = ", b)

Hi Misohoza,
thanks - that’s exactly what I want to do.
But I need to trigger the “load the audio file to a sample zone”-event from outside, thus the idea to have an event listener on program changes which actually loads the wave. Or how could this be done?

This looks good - I could just read the path to the freshly generated WAV file then from a text file - cool! Thanks!

Yes, that was the idea. Use a midi event as a trigger to load or execute an external file (script).

So this is what I tried:

function loadOneShotFile()
    -- External file defines Path to WAV File by function 'fn'
    path = "C:/temp/t-i-exchange.txt"
    filename = ""

    for i, loop in ipairs(fn) do
        filename = loop

    local sample =

    -- print the sample rate and bit depth
    print("Sample Rate: " .. sample.rate)
    print("Bit Depth: " .. sample.bits)

    local zone = this.program:findZones(true)[1]

    if sample.valid then
        zone:setParameter("SampleOsc.Filename", sample.fileName)
        zone:setParameter("SampleOsc.SampleStart", 0)
        zone:setParameter("SampleOsc.SampleEnd", sample.length)
        zone:setParameter("SampleOsc.PlaybackMode", 2)


function onNote(event)
    if(event.note == 24) then loadOneShotFile() end

If I just execute “loadOneShotFile()” it works. But if the event is triggered, I get:
onNote: oneshotloader.lua, Line 11: Function HALion::LuaAudioFile::open is not available in the Processor context.

1 Like

You can try runAsync to execute the function in Controller thread.


Aha! Invoke in Lua - lesson learned, thank you so much!!!
It works like a charm:

function onNote(event)
        event.note == 24
1 Like