r/cubase • • 3d ago

How to Microtune Halion with Lua Script (EDO)

Finally figured out how to make HALion microtonal

• After loading/creating an instrument select the "Program" tab in the right side column.

• This opens a browser type of window with the name of your patch/instrument.

• Right click on the patch/instrument name > New > MIDI Module > Lua Script

• Go the the "MIDI Module" tab in the "Edit" group

• A Lua Script module should now be visible

• Click the tilted 'e' and paste the Lua script below into the blank 'Edit script' window (modify the local refNote and stepsFromRef as you wish)

• Click [OK] and the tuning is live

The sample code below is an example for 31 EDO

If you wanted to do 19 EDO, change the 31 in the script below to 19

-- Choose MIDI note for center (Ex: MIDI 69 = A4 = 440Hz)
local refNote = 69 

function onNote(event)

    local stepsFromRef = event.note - refNote

-- Choose an EDO (Ex: (1200 / 31) is 31 EDO)
    local targetCents = stepsFromRef * (1200 / 31)

    local standardCents = stepsFromRef * 100

    local tuneOffsetCents = targetCents - standardCents

    local halionTuneFactor = tuneOffsetCents / 100

    local id = playNote(event.note, event.velocity, 0, event.layer)
    changeTune(id, halionTuneFactor)
end

I been trying to figure this out forever and FINALLY found success.

5 Upvotes

0 comments sorted by