I am trying to programmatically send MIDI NPRN messages from a E1 preset, but get a lua runtime error when the code executes a midi.sendNprn() MIDI function call.
Here’s my code:
local nprn = (stringNum + 7) << 7 + paramSelected
print (string.format("Sending nprn %s, value: %s", nprn, midiValue))
-- midi.sendControlChange(PORT_2, 1, 99, stringNum + 7) -- NPRN MSB
-- midi.sendControlChange(PORT_2, 1, 98, paramSelected) -- NPRN LSB
-- midi.sendControlChange(PORT_2, 1, 6, midiValue >> 7) -- DATA MSB
-- midi.sendControlChange(PORT_2, 1, 38, midiValue & 0x7F) -- DATA LSB
midi.sendNprn(PORT_2, 1, nprn, midiValue, false, false)
E1 logs this (line 59 is the midi.sendNprn() line):
16:27:16.611 lua: Sending nprn 1152, value: 1.0
16:27:16.622 error running function 'onChange': ctrlv2/slots/b00/p04/main.lua:59: attempt to call a nil value (field 'sendNprn')
If I comment out the midi.sendNprn line, and uncomment the equivalent individual sendControlChange lines, it works as expected.
For reference here’s the currently documented midi.sendNprn() function, at the time of writing:
