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

midi2Processor

Andrew Mee edited this page Nov 23, 2021 · 5 revisions

midi2Processor

Processing of MIDI 1.0 and 2.0 Channel voice messages use the same processing function.

midi2Processor(uint8_t numPERequests)

numPERequests represents the amount simultaneous PE streams that can be handled if the Device does not handle Property Exchange Requests set numPERequest to 0.

Common Methods

void processUMP(uint32_t UMP)

Process incoming UMP messages broken up into 32bit words.

Common Channel Voice Message Handlers

These are the common handles for UMP Messages recieved and processed by processUMP.

midi2Processor makes no distinction between different Protocols. This means that Channel Voice Messages (e.g. Note On) handlers are called the same way regardless if is a MIDI 1.0 Channel Voice Message (Message Type 2) or a MIDI 2.0 Channel Voice Message (Message Type 4). MIDI 1.0 Channel Voice Message values are scaled to match MIDI 2.0 Messages.

This also means that it can Process both types of Channel Voice Messages simultaneously.

Jitter Reduction Messages are also handled using handlers for those Messages. It is up to the application to manage the combination of JR messages and other UMP messages.

inline void setNoteOff(void (*fptr)(uint8_t group, uint8_t channel, uint8_t noteNumber, uint16_t velocity, uint8_t attributeType, uint16_t attributeData))

Set the callable function when a Note Off is processed by processUMP

void midiOff(uint8_t group, uint8_t channel, uint8_t noteNumber, uint16_t velocity, uint8_t attributeType, uint16_t attributeData){
  Serial.print("->MIDI Off: CH"); Serial.print(channel);
  Serial.print(" Note:"); Serial.print(noteNumber);
  Serial.print(" Velocity:"); Serial.println(velocity);
}

midi2Processor MIDI2 (0);
MIDI2.setNoteOff(midiOff);

inline void setMidiNoteOn(void (*fptr)(uint8_t group, uint8_t channel, uint8_t noteNumber, uint16_t velocity, uint8_t attributeType, uint16_t attributeData))

inline void setControlChange(void (*fptr)(uint8_t group, uint8_t channel, uint8_t index, uint32_t value))

inline void setRPN(void (*fptr)(uint8_t group, uint8_t channel,uint8_t bank, uint8_t index, uint32_t value))

This message is only triggered when a MIDI 2.0 RPN message is sent. This is not triggered when a MIDI 1.0 RPN message is sent. Those messages are processed using the function set by setControlChange.

inline void setNRPN(void (*fptr)(uint8_t group, uint8_t channel,uint8_t bank, uint8_t index, uint32_t value))

This message is only triggered when a MIDI 2.0 NRPN message is sent. This is not triggered when a MIDI 1.0 NRPN message is sent. Those messages are processed using the function set by setControlChange.

inline void setRelativeNRPN(void (*fptr)(uint8_t group, uint8_t channel,uint8_t bank, uint8_t index, int32_t value)

MIDI 2.0 Channel Voice Message only.

inline void setRelativeRPN(void (*fptr)(uint8_t group, uint8_t channel,uint8_t bank, uint8_t index, int32_t value))

MIDI 2.0 Channel Voice Message only.

inline void setPolyPressure(void (*fptr)(uint8_t group, uint8_t channel, uint8_t noteNumber, uint32_t pressure))

inline void setChannelPressure(void (*fptr)(uint8_t group, uint8_t channel, uint32_t pressure))

inline void setPitchBend(void (*fptr)(uint8_t group, uint8_t channel, uint32_t value))

inline void setProgramChange(void (*fptr)(uint8_t group, uint8_t channel, uint8_t program, bool bankValid, uint8_t bank, uint8_t index))

MIDI 1.0 Program Change Messages the bankValid is always false.

Common System Message Handlers

inline void setTimingCode(void (*fptr)(uint8_t group,uint8_t timeCode))

inline void setSongSelect(void (*fptr)(uint8_t group,uint8_t song))

inline void setSongPositionPointer(void (*fptr)(uint8_t group,uint16_t positio))

inline void setTuneRequest(void (*fptr)(uint8_t group))

inline void setTimingClock(void (*fptr)(uint8_t group))

inline void setSeqStart(void (*fptr)(uint8_t group))

inline void setSeqCont(void (*fptr)(uint8_t group))

inline void setSeqStop(void (*fptr)(uint8_t group))

inline void setActiveSense(void (*fptr)(uint8_t group))

inline void setSystemReset(void (*fptr)(uint8_t group))

Common SysEx Handlers

inline void setRawSysEx(void (*fptr)(uint8_t group, uint8_t* sysex ,uint16_t length, uint8_t state))

And SysEx generated from either MIDI-CI resposes or from direct Method calls are sent here Message are often chunked. as such the state argument contains information if this is a whole SysEx message or partial. Leading 0xF0 and ending 0xF7 bytes are never sent.

  • 0 - Complete SysEx message
  • 1 - Start of a SysEx message
  • 2 - Continue a SysEx message
  • 3 - Last part of a SysEx message
//Example of Sending a SysEx Message out to a MIDI 1.0 Byte stream on Arduino
void rawSysex(uint8_t group, uint8_t *sysex ,uint16_t length, uint8_t state){
   if (state < 2){
    Serial1.write((char)SYSEX_START);
  }
    
  for(int i=0; i < length; i++){
    Serial.write((char)(sysex[i] & 0x7F));
  }

  if (state == 0 || state==3){
    Serial.write((char)SYSEX_STOP);
  }
}

midi2Processor MIDI2 (0);
MIDI2.setRawSysEx(rawSysex);

inline void setRecvUnknownSysEx(void (*fptr)(uint8_t group, umpSysex7Internal * syExMess, uint8_t s7Byte))

Handle Manufacturer Defined SysEx. Note that this does not pass handle Universal SysEx Messages.

Clone this wiki locally