Convert CC#0 to NRPN Cutoff for MC303 and CC#1 to NRPN resonance

We want to create a MIDI converter, which translates the Modwheel Event to a NRPN.

Copy the SDCC skeleton into a new directory, open the main.c file and enhance the hooks like described below. Thereafter type "make" in the command shell, and upload the new project.hex file to the core.

/////////////////////////////////////////////////////////////////////////////
//  This function is called by MIOS when a complete MIDI event has been received
/////////////////////////////////////////////////////////////////////////////
void MPROC_NotifyReceivedEvnt(
  unsigned char evnt0, unsigned char evnt1, unsigned char evnt2) __wparam
{
  // check MIDI channel, it should be 0 (-> channel #1)
  if( (evnt0 & 0x0f) == 0 ) {

    switch( evnt0 & 0xf0 ) {
      case 0x80: // Note-Off: 3 bytes
      case 0x90: // Note-On: 3 bytes
      case 0xa0: // Aftertouch: 3 bytes
      case 0xe0: // Pitchbend: 3 bytes
        MIOS_MIDI_TxBufferPut(evnt0);
        MIOS_MIDI_TxBufferPut(evnt1);
        MIOS_MIDI_TxBufferPut(evnt2);
        break;
      case 0xc0: // Program Change: 2 bytes
      case 0xd0: // Poly Aftertouch: 2 bytes
        MIOS_MIDI_TxBufferPut(evnt0);
        MIOS_MIDI_TxBufferPut(evnt1);
        break;

      case 0xb0: // CC: 3 bytes
	// check for CC #0 at Channel #1
	if     ( evnt0 == 0xb0 && evnt1 == 0x00 )
	  MyFun_Send_MC303_NRPN(evnt0, 0x20, evnt2); // send NRPN LSB = 0x20 (CutOff)
	else if(  evnt0 == 0xb0 && evnt1 == 0x01 )
	  MyFun_Send_MC303_NRPN(evnt0, 0x20, evnt2); // send NRPN LSB = 0x20 (Resonance)
	else {
	  // just forward CC without change
          MIOS_MIDI_TxBufferPut(evnt0);
          MIOS_MIDI_TxBufferPut(evnt1);
          MIOS_MIDI_TxBufferPut(evnt2);
	}

      default:
        // note: status messages (>= 0xf0) must be handled within MPROC_NotifyReceivedByte)
        break;
     }
  }
}
>

As you've propably noticed, the function "MyFun_Send_MC303_NRPN" is called. This function sends a NRPN event, customized for the MC303:

void MyFun_Send_MC303_NRPN(
  unsigned char evnt0, unsigned char nrpn_lsb, unsigned char value)
{
  MIOS_MIDI_TxBufferPut(evnt0);    // send Bn
  MIOS_MIDI_TxBufferPut(0x63);     // Send NRPN MSB 01 (0x63 0x01)
  MIOS_MIDI_TxBufferPut(0x01);
  MIOS_MIDI_TxBufferPut(0x62);     // Send NRPN LSB  (0x62 )
  MIOS_MIDI_TxBufferPut(nrpn_lsb);
  MIOS_MIDI_TxBufferPut(0x06);     // send NRPN MSB value (0x06 )
  MIOS_MIDI_TxBufferPut(value);
}

If SysEx or Realtime messages should be forwarded as well, then you need to enhance the MPROC_NotifyReceivedByte() function like shown in this example

A list of available MIOS function can be found here.



Last update: 2018-05-10

Copyright 1998-2018, Thorsten Klose. All rights reserved.