I have an Arduino Leonardo and so far I was able to send execute NoteOn and NotOff MIDI events thru built-in microUSB port into my Ubuntu Studio 16.04 LTS laptop just fine based on the MIDIUSB_write example sketch. However I can't find examples sending Program Change messages, I know the midiEventPacket_t struc is meant to build you MIDI message but I don't seem to find detailed description in the library on how to do it. Any help would be appreciated.
Read chapter 4 (pages 16-17) of the MIDI USB specification.
uint8_t m = 0xC0; // ProgramĀ Change
uint8_t c = 0; // MIDI channel 1
uint8_t d1 = 19; // Church organ
uint8_t d2 = 0; // Unused for Program Change
midiEventPacket_t msg = {m >> 4, m | c, d1, d2};
MidiUSB.sendMIDI(msg);
MidiUSB.flush();
Pieter