Question about UI

Hello, is it possible with a Lua code to trigger the change of a page in the UI playing a specific note? I have 2 switches in the UI that change the Ui from the FX page to the Sample View page, is it possible with a Lua code to trigger the Sample page when I press note 60? I have already tried without any sort of success, please any help is welcome. Thanks!

Hi @clAud9

How did you implement page switching?

It should be possible but you need to have a script parameter for the switch. Using ui variables probably won’t work.

Then just use onNote callback and change the value of the switch parameter when the note is 60.

To switch page I’m using the Template “Decor Text Radio Switch”, I have created a variable Layer1 and created stacks. Please see attached screenshot, the switch is working perfectly when I click it, I’m trying to trigger it also if I play note 60.

You may need to use a script parameter instead of ui variable.

Pages.vstpreset (8.8 KB)

Thanks it works!

I’m still experimenting without succes how to change with a script the value of ADSR from -100% to +100% to 0 to +100%, I have scripted the knob but is not connecting to the parameter…

local layer = this.parent
local zones = layer:findZones()

-- Define the knob parameter to control DCAAttOffset, ranging from 0% to 100%
defineParameter("AttackKnob", nil, 0, 0, 100, function() updateDCAAttack() end)

function updateDCAAttack()
    -- Convert AttackKnob range (0 to 100%) to DCAAttOffset range (0% to +100%)
    local mappedValue = AttackKnob
    
    -- Set the DCAAttOffset for each zone in the layer
    for i, zone in ipairs(zones) do
        zone:setParameter("DCAttOffset", mappedValue)
    end
end```

You have the parameter name misspelled:

zone:setParameter("DCAttOffset", mappedValue)

It should be:

zone:setParameter("DCAAttOffset", mappedValue)

Thanks now is working! I applied the same to the release knob, do you think it’s correct to also apply to decay and sustain knobs, or for those, it’s better to leave the default -100 + 100?

I’m trying to apply the same concept to modify the Octave parameter that by default is -5 +5 to -2 +2 but is not working. I can see the correct values (0 +2 -2) in the menu i have created but is not connecting to the Octave parameter…

local layer = this.parent
local zones = layer:findZones()

-- Define menu parameter for Octave with integer values from -2 to +2
defineParameter("OctaveMenu", nil, 2, {"-2", "-1", "0", "+1", "+2"}, function() updateOctave() end)

-- Update function for Octave
function updateOctave()
   local mappedValue = OctaveMenu
    for i, zone in ipairs(zones) do
        zone:setParameter("Octave", mappedValue)
       end
end

fixed, this is the working code:

local layer = this.parent
local zones = layer:findZones()

-- Define menu parameter for Octave with values -2, -1, 0, +1, +2
defineParameter("OctaveMenu", nil, 3, {"-2", "-1", "0", "+1", "+2"}, function() updateOctave() end)

function updateOctave()
    -- Map OctaveMenu index to the corresponding octave shift values in HALion
    local octaveShiftValues = {-2, -1, 0, 1, 2}
    
    -- Retrieve the value from the OctaveShiftValues array
    local mappedValue = octaveShiftValues[OctaveMenu]

    -- Apply the mapped value to the Pitch.Octave parameter for each zone
    for i, zone in ipairs(zones) do
        zone:setParameter("Pitch.Octave", mappedValue)
    end

    -- Debug output to verify the setting
    print("Setting Pitch.Octave to:", mappedValue)
end

1 Like