FastLED 3.9.15
Loading...
Searching...
No Matches

◆ decodeSysEx()

unsigned decodeSysEx ( const byte * inSysEx,
byte * outData,
unsigned inLength,
bool inFlipHeaderBits )

Decode System Exclusive messages. SysEx messages are encoded to guarantee transmission of data bytes higher than 127 without breaking the MIDI protocol. Use this static method to reassemble your received message.

Parameters
inSysExThe SysEx data received from MIDI in.
outDataThe output buffer where to store the decrypted message.
inLengthThe length of the input buffer.
inFlipHeaderBitsTrue for Korg and other who store MSB in reverse order
Returns
The length of the output buffer.
See also
encodeSysEx
getSysExArrayLength Code inspired from Ruin & Wesen's SysEx encoder/decoder - http://ruinwesen.com

Definition at line 87 of file MIDI.cpp.

91{
92 unsigned count = 0;
93 byte msbStorage = 0;
94 byte byteIndex = 0;
95
96 for (unsigned i = 0; i < inLength; ++i)
97 {
98 if ((i % 8) == 0)
99 {
100 msbStorage = inSysEx[i];
101 byteIndex = 6;
102 }
103 else
104 {
105 const byte body = inSysEx[i];
106 const byte shift = inFlipHeaderBits ? 6 - byteIndex : byteIndex;
107 const byte msb = byte(((msbStorage >> shift) & 1) << 7);
108 byteIndex--;
109 outData[count++] = msb | body;
110 }
111 }
112 return count;
113}
uint8_t byte
Definition midi_Defs.h:36