12 bit NRPN

Hi there,

I’m trying to control my Kiwi Juno-106 with NRPNs but unfortunately I haven’t figured out how to properly configure it…

It supports 12 bit controls (0-4096) and it combines 7 bits of the MSB and 5 of the LSB. See the extract from the manual below.

I tried to modify the code below for hours to try to get it work but with no success unfortunately. I must confess bit shifting/combining is unknown territory for me… I’m also not able to monitor the synth’s output because it sends only 7 bit CCs…
I got the code from this topic: https://forum.electra.one/t/nrpns-bits-and-bytes/3319. Props to the autors.

deviceId = 1
device= devices.get(deviceId)
devPort = device:getPort ()
channel = device:getChannel ()


function sendNrpn(ValueObject, value)

    local message = ValueObject:getMessage ()
    local parameterNumber = message:getParameterNumber ()

    local parameterMSB = (parameterNumber >> 7) & 0x7F
    local parameterLSB = parameterNumber & 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(devPort, msg)
    end
end

Does anybody know how to solve this problem ?

Can you test this preset:
Kiwi 106 NRPN

I tried setting up a standard NRPN fader to control Overall Volume there (7). I am curious if it changes the volume when you twist the knob. I am not expecting that it will work on 100%, but you should hear some changes of the volume. If not, we need to tweak it a little bit more.