Skip to content
This repository was archived by the owner on Apr 8, 2024. It is now read-only.

midiBsToUMP

Andrew Mee edited this page Sep 5, 2021 · 2 revisions

midiBsToUMP

Class used for translating between a raw MIDI 1.0 Byte stream and UMP

Public variables

uint8_t defaultGroup = 0;

This allows the application to set the group used when creating UMP messages.

bool outputMIDI2 = false;

By default midiBsToUMP will output MIDI 1.0 Channel voice message (Message Type 2). Set this to true to output MIDI 2 Channel Voice Messages (Message Type 4).

This uses the Translation methods described in Universal MIDI Packet (UMP) Format and MIDI 2.0 Protocol Version 1.0.

This means it attempts to convert RPN and NRPN Control Change messages into UMP RPN and NRPN messages. This may cause some issues with Some devices that do not sent LSB Data vale (CC #38).

Common methods

void midi1BytestreamParse(uint8_t midi1Byte)

Process incoming MIDI 1.0 Byte stream

bool availableUMP()

Check if there are available UMP packets after processing the Byte Stream

uint32_t readUMP()

Return a 32Bit word for a UMP Packet. A Bystream conversion may create several UMP packets.

Example: Using midiBsToUMP to Create UMP SysEx7 Messages (message Type 3)

midi2Processor output any Sysex it creates via the function declared by setRawSysEx handler. The SysEx is streamed as the raw SysEx data streams seen in MIDI 1.0 Byte Streams. It is possible to convert to UMP using midiBsToUMP.

void rawSysex(uint8_t group, uint8_t *sysex ,uint16_t length, uint8_t state){
  Sysex2UMP.defaultGroup = group;
  
  if (state < 2){
    Sysex2UMP.midi1BytestreamParse((uint8_t)SYSEX_START);
  }
 
  for(int i=0; i < length; i++){
   Sysex2UMP.midi1BytesteamParse(sysex[i]);
    while(Sysex2UMP.availableUMP()){
      uint32_t ump = Sysex2UMP.readUMP();
      seedOutUMPWordToADevice(ump);
    }
  }

  if (state == 0 || state==3){
   Sysex2UMP.midi1BytesteamParse((uint8_t)SYSEX_STOP);
    while(Sysex2UMP.availableMIDI1()){
      uint32_t ump = Sysex2UMP.readMIDI1();
      seedOutUMPWordToADevice(ump);
    }
  }
}

midi2Processor MIDI2 (0,2,2);
midiBsToUMP Sysex2UMP;
MIDI2.setRawSysEx(rawSysex);
MIDI2.sendDiscoveryRequest(0, 1);

Clone this wiki locally