I’ve been using the sendNrpn() method posted by someone else for a long time. The Lua version has been broken for a while. The webUI version does work.
function sendNrpn(port, channel, parameter, value)
local parameterMSB = (parameter >> 7) & 0x7F
local parameterLSB = parameter & 0x7F
local valueMSB = (value >> 7) & 0x7F
local valueLSB = value & 0x7F
local messages = {
{channel = channel, type = CONTROL_CHANGE, controllerNumber = 99, value = parameterMSB},
{channel = channel, type = CONTROL_CHANGE, controllerNumber = 98, value = parameterLSB},
{channel = channel, type = CONTROL_CHANGE, controllerNumber = 6, value = valueMSB},
{channel = channel, type = CONTROL_CHANGE, controllerNumber = 38, value = valueLSB}
}
for i, msg in ipairs(messages) do
midi.sendMessage(port, msg)
end
sendNrpn is fixed in the upcoming release. I have added extra parameters to change order of bytes and including the reset bytes. The documentation will be updated.