Reading Midi-Input

So I try to build a Synth Plugin, from code exported out of Gen~(Max MSP). However I have to get the mididata over to the gen~patch, so now I’m looking for a way to get 3 variables for each of the 3 bytes of the midi massage, but I couldn’t find anything on how to read the individual bytes of the incoming midi.

You can read raw data from the juce::MidiMessage with getRawData(). Is that what you mean?

1 Like

I found that but that’s not exactly what I was looking for. I was hoping to read individual bytes directly.

What do you mean ‘directly’? That is exactly what this API is for. any combo of the following things will get you there

const auto myMidiData = { theMidiMessage.getRawData () };
const auto firstByte = myMidiData [0];
const auto secondByte = myMidiData [1];
const auto thirdByte = myMidiData [2];
1 Like

I would advise against using auto foo = { some expression };. This will create an object of type std::initializer_list which is normally unexpected (I think your example is broken as a result).

getRawData() is the recommended method to get at the raw MIDI data. getRawData()[0] will get the first byte, getRawData()[1] will get the second byte, and so on.

1 Like

oh crud! thanks for the catch, and the reminder. :slight_smile: