diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2012-04-25 18:28:56 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2012-04-25 18:28:56 +0000 |
commit | e875d7cf9f31fe9ac586718850a433f2851b5e19 (patch) | |
tree | 6646b7317aeb0a802a6eb0e2f09c8fa9c1df6f0d /LUFA/Drivers/USB/Class/Common/MIDIClassCommon.h | |
parent | 5b5b73ce582d2afa40218e44b45a97ec6c6ce9cf (diff) | |
download | lufa-e875d7cf9f31fe9ac586718850a433f2851b5e19.tar.gz lufa-e875d7cf9f31fe9ac586718850a433f2851b5e19.tar.bz2 lufa-e875d7cf9f31fe9ac586718850a433f2851b5e19.zip |
Changed MIDI event structure MIDI_EventPacket_t to use a single field for the combined virtual cable index and command ID, to prevent bitfield packing issues on some architectures (thanks to Darren Gibbs).
Diffstat (limited to 'LUFA/Drivers/USB/Class/Common/MIDIClassCommon.h')
-rw-r--r-- | LUFA/Drivers/USB/Class/Common/MIDIClassCommon.h | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/LUFA/Drivers/USB/Class/Common/MIDIClassCommon.h b/LUFA/Drivers/USB/Class/Common/MIDIClassCommon.h index 60b0908f3..25b80b7d4 100644 --- a/LUFA/Drivers/USB/Class/Common/MIDIClassCommon.h +++ b/LUFA/Drivers/USB/Class/Common/MIDIClassCommon.h @@ -84,8 +84,20 @@ * addresses are zero-indexed. This converts a natural MIDI channel number into the logical channel address. * * \param[in] channel MIDI channel number to address. + * + * \return Constructed MIDI channel ID. */ #define MIDI_CHANNEL(channel) ((channel) - 1) + + /** Constructs a MIDI event ID from a given MIDI command and a virtual MIDI cable index. This can then be + * used to create and decode \ref MIDI_EventPacket_t MIDI event packets. + * + * \param[in] virtualcable Index of the virtual MIDI cable the event relates to + * \param[in] command MIDI command to send through the virtual MIDI cable + * + * \return Constructed MIDI event ID. + */ + #define MIDI_EVENT(virtualcable, command) ((virtualcable << 4) | (command >> 4)) /* Enums: */ /** Enum for the possible MIDI jack types in a MIDI device jack descriptor. */ @@ -290,8 +302,7 @@ */ typedef struct { - unsigned Command : 4; /**< Upper nibble of the MIDI command being sent or received in the event packet. */ - unsigned CableNumber : 4; /**< Virtual cable number of the event being sent or received in the given MIDI interface. */ + uint8_t Event; /**< MIDI event type, constructed with the \ref MIDI_EVENT() macro. */ uint8_t Data1; /**< First byte of data in the MIDI event. */ uint8_t Data2; /**< Second byte of data in the MIDI event. */ |