NRPN Possible Bug

Further to my post about issues I’m having with Bass Station 2 and NRPNs

I think I’ve found the cause and a possible bug

When sending NRPNs electra will send a pair of messages CC98 and CC99 to indicate which parameter is going to be adjusted

Electra then sends CC6 and a CC38 messages for values. However, it doesn’t appear to be setting these pair of messages correctly. According to MIDI NRPN and RPN by Phil Rees CC38 is an optional message for refinement of the main value which is sent in CC6.

So if I setup an NRPN which only has 4 possible values (0-3). Electra will always send CC6 as zero with the CC38 sent with a value of 0 - 3. This is irrespective of the MSB first / LSB first setting

In the case of the Bass Station 2. it is only monitoring the CC6 value which is always received as zero.

Doing a bit more googling it seems that some manufacturers particularly Novation use NRPNs to give themselves more midi controllable parameters but when the value to be communicated is 7 bit they are omitting the CC38

I can work around this using Lua.

@NewIgnis has a suggested solution in the thread below using virtual controls

This means that electra will send out the messages in the correct format for the Bass Station 2

I can then write code in a midi.OnControlChange event to direct messages from the Bass Station 2 back to the virtual controls

This gives me bidirectional control of the Bass Station 2 NRPNs

Hi @RobinC , how did you implement the Lua function? I tried this:

function sendNrpn(parameter, value)
    local parameterMSB = (parameter >> 7) & 0x7F
    local parameterLSB = parameter & 0x7F
    local valueMSB = (value >> 7) & 0x7F
    local valueLSB = value & 0x7F

    local messages = {
        {channel = 1, type = CONTROL_CHANGE, data1 = 99, data2 = parameterMSB},
        {channel = 1, type = CONTROL_CHANGE, data1 = 98, data2 = parameterLSB},
        {channel = 1, type = CONTROL_CHANGE, data1 = 6, data2 = valueMSB},
        {channel = 1, type = CONTROL_CHANGE, data1 = 38, data2 = valueLSB}
    }

    for i,msg in ipairs(messages) do
        midi.sendMessage(port, msg)
    end
end

But I keep getting this error:

bad argument #1 to 'sendMessage' (number expected, got nil)

However none of the parameters are actually nil (I checked by printing everything out before sending it, and I am kind of stumped.

Nevermind, I got it to work. Turns out I was using a bad value for the port… duh. In case someone else needs to send NRPN messages, here is the implementation in Lua:

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
end

glad you got it solved

1 Like