MCPcopy Create free account
hub / github.com/VCVRack/Befaco / decodeSysEx

Function decodeSysEx

src/MidiThing.cpp:16–38  ·  view source on GitHub ↗

! \brief 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. \param inSysEx The SysEx data received from MIDI in. \param outData The output buffer where to store the decrypted message. \param inLength The length of the input buffer.

Source from the content-addressed store, hash-verified

14 Code inspired from Ruin & Wesen's SysEx encoder/decoder - http://ruinwesen.com
15 */
16unsigned decodeSysEx(const uint8_t* inSysEx,
17 uint8_t* outData,
18 unsigned inLength,
19 bool inFlipHeaderBits) {
20 unsigned count = 0;
21 uint8_t msbStorage = 0;
22 uint8_t byteIndex = 0;
23
24 for (unsigned i = 0; i < inLength; ++i) {
25 if ((i % 8) == 0) {
26 msbStorage = inSysEx[i];
27 byteIndex = 6;
28 }
29 else {
30 const uint8_t body = inSysEx[i];
31 const uint8_t shift = inFlipHeaderBits ? 6 - byteIndex : byteIndex;
32 const uint8_t msb = uint8_t(((msbStorage >> shift) & 1) << 7);
33 byteIndex--;
34 outData[count++] = msb | body;
35 }
36 }
37 return count;
38}
39
40struct RoundRobinProcessor {
41 // if a channel (0 - 11) should be updated, return it's index, otherwise return -1

Callers 1

processMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected