Arduino MIDI Remapper - Part 4 - NRPN Messages

XB5 messages on MIDI-OX
Fig.1 - XB5 NRPN messages (MIDI-OX)

In Part 3 I got the Arduino to change the CC (control change) messages coming from the XB5 organ, to control the drawbars settings in the B4000+. In this post we look at controlling the effects using the XB5s pushbuttons.

The effects buttons generate NRPNs (Non Registered Parameter Numbers). There is no ‘standard’ for NRPN messages and the way they are used varies between manufacturers and instruments. Fig.1 shows the messages generated when the Leslie effect is switched on then off again. It takes three messages to send the effect change. CC messages are used to send the MSB (Most Significant Byte) and LSB (Least Significant Byte) of the NRPN. Another CC message is then used to send the value for the effect change. The XB5 uses a value of 7Fh when switching an effect on and a value of 00h when switching it off. Note that with the XB5, a CC code of 62h signifies the MSB of the NRPN, whereas MIDI-OX has annotated it as the LSB. This illustrates the inconsistency in the way NRPN codes are used!

The callbacks in the Arduino code (a function of the MIDI library I used) can only deal with one CC message at a time, but the XB5 is sending three messages for each effect modification. This makes things complicated. However, in reality we only need to concern ourselves with two of these messages, since the NRPN MSB from the organ is always zero, so can be ignored.

Examining the messages in Fig.1 we can see that in the 2nd line the number of the NRPN is being sent (09) and for the XB5 this represents the Leslie effect. In the next line a message is sent containing the data value for the effect, in this case 7Fh, meaning ‘Leslie ON’. I decided on the following method of interpreting the messages in the program:

Read CC message.
If message is NRPN LSB, set a flag and save the NRPN number.
If a message is “Data Entry”, check flag to see if the NRPN message has previously been received.
If flag is set, then save the “Data Entry” value, check the last NRPN number then send the appropriate CC message to the B4000+ along with the data value.

I implemented the Leslie ON/OFF remapping in the Arduino code and used MIDI-OX for testing and debugging, before confirming correct operation with the XB5 and B4000+. A snippet of the resulting code is shown below.

 
void handleMidiEventControlChange(byte inChannel, byte inControlNumber, byte inControlValue) 
{
  if (inControlNumber!=5)     //Use this to filter out a given CC message
  {
    if (inControlNumber==92)
    {
      inControlNumber=4;      //Change CC number for Leslie speed control
    }   
    if (inControlNumber==99)
    {
      NRPNcode = inControlValue;
      NRPNflag = 1;      //Set flag to indicate that an NRPN message has been recieved
    } 
    if (inControlNumber==6)
    {
      // Process NRPN message
      data = inControlValue;
      if (NRPNflag==1)
      {
        //Check NRPN code
        if (NRPNcode==9)      //Is it Leslie on/off?
        {
          inControlNumber=83;
          inControlValue=data;
        } 
      }
      NRPNflag = 0;   //Reset NRPN flag
    }
    if ((inControlNumber==80)||(inControlNumber==81)||(inControlNumber==82))    //Check if it is drawbar setting
    {
      index = (inControlNumber-80)*81 + inControlValue;
      inControlNumber = byte1[index];
      inControlValue = byte2[index];
    }
    MIDI.sendControlChange(inControlNumber, inControlValue, inChannel);
  }
}
Note that there is a menu setting on the XB5 that enables NRPN operation, and this must be switched ON. Although this is meant to be a global setting, I have found that it ‘forgets’ the setting when the organ is switched off. This means having to change it each time the organ is switched on, which is a little annoying.

The next step will be to work on the code to map more of the NRPN messages coming from the XB5 organ to control further functions in the B4000+ sound module, e.g. vibrato, chorus, percussion (2nd & 3rd harmonic) etc.

Continued in Part 5

Disclaimer: This is my personal blog. Views expressed in my posts are my own and not of my employer. The information provided comes with no warranty. I cannot be held responsible for the content of external websites. Any practical work you undertake is done at your own risk. Please make health and safety your number one priority.



 

Comments