Adding Port + Channel Controls to a Preset

Hello!
I am trying to add the ability to Changes Ports and Midi Channels to my “EMU Proteus 2” Preset I am starting to make. It is MultiTimbral to have the ability to change channels on the fly and update the control parameters is ideal.

I took what I were essential from the Arp Preset but I get an error.

-- Channels
local ALL_CHANNELS = 0

-- User input variables
--
local state = {
    -- Port In
    portIn = PORT_1,

    -- MIDI channel in
    channelIn = 1,

    -- Port out
    portOut = PORT_1,

    -- MIDI channel out
    channelOut = 1,
}


-- Runtime variables
--
local runtime = {
    -- Indicates that user changed settings of ports/channels
    ioChangeIsPending = true,

}

-- Map of parameters used in the preset
--
local parameters = {
    portIn = { PT_VIRTUAL, 11 },
    channelIn = { PT_VIRTUAL, 12 },
    portOut = { PT_VIRTUAL, 13 },
    channelOut = { PT_VIRTUAL, 14 },
}


-- Initialize the preset

-- Reconfigure all IO ports according to the UI config
--
function reconfigureIoPorts()
    state.portIn = getParameter(parameters.portIn)
    state.channelIn = getParameter(parameters.channelIn)
    state.portOut = getParameter(parameters.portOut)
    state.channelOut = getParameter(parameters.channelOut)
end



            -- Reflect any changes to the Input/Output 
            if runtime.ioChangeIsPending then
                reconfigureIoPorts()
                runtime.ioChangeIsPending = false
            end


-- Check input port and channel
--
function isInputMatching(port, channel)
    if state.portIn ~= port then
        return false
    end

    if (channel ~= ALL_CHANNELS) and (channel ~= state.channelIn) then
        return false
    end

    return true
end


-- Function callbacks

-- Callback to change the input port
--
function setIoPort(valueObject, value)
    runtime.ioChangeIsPending = true
end

ERROR:
loadLuaModule: error loading file: filename=ctrlv2/slots/p001.lua, error=ctrlv2/slots/p001.lua:44: attempt to call a nil value (global ‘getParameter’)

Thank you,
Michael

@martin
I’ve been coming along way on the preset and really getting a decent grasp on LUA and how it helps do a lot extra with the E1. However, I keep running into hang ups sending SysEx data over specific ports and channels over the Electra One. I keep trying to take apart a few working templates to no success. Really want to take advantage of the E-mu Proteus Multitimbral settings but currently the E1 preset sends the commands out of all Channels.

It would be great if there was a Global Midi Routing setting built into the E1 that could take over priority of a preset.

Happy to share the E1 Project File:
E-mu Proteus 2.eproj (110.8 KB)