- Endpoint_ClearOUT();\r
-}\r
-\r
-/** Sends a MIDI note change event (note on or off) to the MIDI output jack, on the given virtual cable ID and channel.\r
- *\r
- * \param Pitch Pitch of the note to turn on or off\r
- * \param OnOff Set to true if the note is on (being held down), or false otherwise\r
- * \param CableID ID of the virtual cable to send the note change to\r
- * \param Channel MIDI channel number to send the note change event to\r
- */\r
-void SendMIDINoteChange(const uint8_t Pitch, const bool OnOff, const uint8_t CableID, const uint8_t Channel)\r
-{\r
- /* Wait until endpoint ready for more data */\r
- while (!(Endpoint_IsReadWriteAllowed()));\r
-\r
- /* Check if the message should be a Note On or Note Off command */\r
- uint8_t Command = ((OnOff)? MIDI_COMMAND_NOTE_ON : MIDI_COMMAND_NOTE_OFF);\r
-\r
- /* Write the Packet Header to the endpoint */\r
- Endpoint_Write_Byte((CableID << 4) | (Command >> 4));\r
-\r
- /* Write the Note On/Off command with the specified channel, pitch and velocity */\r
- Endpoint_Write_Byte(Command | Channel);\r
- Endpoint_Write_Byte(Pitch);\r
- Endpoint_Write_Byte(MIDI_STANDARD_VELOCITY);\r
+ {\r
+ USB_MIDI_EventPacket_t MIDIEvent;\r
+ \r
+ /* Read the MIDI event packet from the endpoint */\r
+ Endpoint_Read_Stream_LE(&MIDIEvent, sizeof(MIDIEvent));\r
+ \r
+ if (MIDIEvent.Command == (MIDI_COMMAND_NOTE_ON >> 4))\r
+ {\r
+ /* Change LEDs depending on the pitch of the sent note */\r
+ LEDs_SetAllLEDs(MIDIEvent.Data2 > 64 ? LEDS_LED1 : LEDS_LED2);\r
+ }\r
+ else\r
+ {\r
+ /* Turn off all LEDs in response to non-Note On messages */\r
+ LEDs_SetAllLEDs(LEDS_NO_LEDS);\r
+ }\r