midi.sendSysex question, multiple parameterNumbers

Hi Guys, can the midi.sendSysex command send out multiple parameterNumbers like the JSON code can take as arguments?

In LUA, midi.sendSysex (PORT_1, { 0x43, 0x10, 0x5E, 0x60, 0x00, 0x03, 0x00, value })

Can the ‘value’ LUA piece above be crafted to splice two parameterNumbers together like I can in JSON:
“data”: [
“type”: “value”,
“rules”: [
“parameterNumber”: 94,
“type”: “sysex”,
“parameterBitPosition”: 0,
“byteBitPosition”: 3,
“bitWidth”: 3
“type”: “sysex”,
“parameterNumber”: 95,
“parameterBitPosition”: 0,
“byteBitPosition”: 0,
“bitWidth”: 3

Yes it can. As you see, the payload in the sendSysex statement is a table where each element represents the value of a byte pair (the value does not need to be in hex format, by the way). You can use any constant or function in here. Also the value belonging to a parameter.

Some sysex commands require you for instance to add a device ID, a MIDI channel or a checksum to a sysex. These too are just set up as elements in the payload table.

Just note that the data you supply to the midi.sendSysex() should not include the F0 and
F7 bytes.

1 Like

as you are in Lua you can assemble array of the bytes as you wish. see the example below. It is just important to keep bytes in 7bit number range.

    -- you need to know what device to use
    local yourDeviceId = 1

    -- get values of the parameters
    local parameter94 = parameterMap.get(yourDeviceId, PT_SYSEX, 94)
    local parameter95 = parameterMap.get(yourDeviceId, PT_SYSEX, 95)

    -- perform bitwise operations to compose the byte value
    -- note, this replicates your JSON example
    local byteValue = ((parameter94 & 0x07) << 3) | (parameter95 & 0x07)

    -- you can optionally check if the byteValue is in 7bit range
    assert(byteValue == (byteValue & 0x7F))

    -- you can optionally just trim it to 7bit range
    byteValue = byteValue & 0x7F

    -- send the message out
    midi.sendSysex (PORT_1, { 0x43, 0x10, 0x5E, 0x60, 0x00, 0x03, 0x00, byteValue })

Thanks for the example Martin, I haven’t ever used any of the bitwise operations and an example teaches me better than anything else!
NewIgnus, I can see now that I’m going to have to go at it differently than the JSON code, I was hoping there was a shortcut. I need parameterMap.get’s to snag the values first.
Oldgearguy, thanks. I do know not to include the F0 and F7 bytes, they’re excluded from my midi-sendSysex example.

1 Like