Skip to content

Commit 1e85837

Browse files
committed
audio: midi: improve API documentation
Improve the API documentation for Universal MIDI Packets definitions: - Add link to the reference document, and make it referenceable in doxygen - Use BIT_MASK macro instead of hexadecimal litterals to better convey the length of various fields within UMP packets - Add more cross-references where possible - Use @remark when applicable Signed-off-by: Titouan Christophe <[email protected]>
1 parent 8f2d3e7 commit 1e85837

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

include/zephyr/audio/midi.h

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,22 @@ extern "C" {
1919
* @ingroup audio_interface
2020
* @since 4.1
2121
* @version 0.1.0
22-
* @see ump112: "Universal MIDI Packet (UMP) Format and MIDI 2.0 Protocol"
23-
* Document version 1.1.2
2422
* @{
2523
*/
2624

25+
/**
26+
* @defgroup ump112 Universal MIDI Packet (UMP) Format and MIDI 2.0 Protocol
27+
* @ingroup midi_ump
28+
* @{
29+
* @details Definitions based on the following document
30+
* <a href="https://drive.google.com/file/d/1l2L5ALHj4K9hw_LalQ2jJZBMXDxc9Uel/view">
31+
* Universal MIDI Packet (UMP) Format and MIDI 2.0 Protocol
32+
* With MIDI 1.0 Protocol in UMP Format - Document version 1.1.2
33+
* (MIDI Association Document: M2-104-UM)
34+
* </a>
35+
* @}
36+
*/
37+
2738
/**
2839
* @brief Universal MIDI Packet container
2940
*/
@@ -59,6 +70,7 @@ struct midi_ump {
5970
/**
6071
* @brief Message Type field of a Universal MIDI Packet
6172
* @param[in] ump Universal MIDI Packet
73+
* @see midi_ump_mt
6274
*/
6375
#define UMP_MT(ump) \
6476
((ump).data[0] >> 28)
@@ -86,14 +98,15 @@ struct midi_ump {
8698
* @param[in] ump Universal MIDI Packet
8799
*/
88100
#define UMP_GROUP(ump) \
89-
(((ump).data[0] >> 24) & 0x0f)
101+
(((ump).data[0] >> 24) & BIT_MASK(4))
90102

91103
/**
92104
* @brief Status byte of a MIDI channel voice or system message
93105
* @param[in] ump Universal MIDI Packet (containing a MIDI1 event)
106+
* @see midi_ump_sys
94107
*/
95108
#define UMP_MIDI_STATUS(ump) \
96-
(((ump).data[0] >> 16) & 0xff)
109+
(((ump).data[0] >> 16) & BIT_MASK(8))
97110
/**
98111
* @brief Command of a MIDI channel voice message
99112
* @param[in] ump Universal MIDI Packet (containing a MIDI event)
@@ -106,19 +119,19 @@ struct midi_ump {
106119
* @param[in] ump Universal MIDI Packet (containing a MIDI event)
107120
*/
108121
#define UMP_MIDI_CHANNEL(ump) \
109-
(UMP_MIDI_STATUS(ump) & 0x0f)
122+
(UMP_MIDI_STATUS(ump) & BIT_MASK(4))
110123
/**
111124
* @brief First parameter of a MIDI1 channel voice or system message
112125
* @param[in] ump Universal MIDI Packet (containing a MIDI1 message)
113126
*/
114127
#define UMP_MIDI1_P1(ump) \
115-
(((ump).data[0] >> 8) & 0x7f)
128+
(((ump).data[0] >> 8) & BIT_MASK(7))
116129
/**
117130
* @brief Second parameter of a MIDI1 channel voice or system message
118131
* @param[in] ump Universal MIDI Packet (containing a MIDI1 message)
119132
*/
120133
#define UMP_MIDI1_P2(ump) \
121-
((ump).data[0] & 0x7f)
134+
((ump).data[0] & BIT_MASK(7))
122135

123136
/**
124137
* @brief Initialize a UMP with a MIDI1 channel voice message
@@ -143,9 +156,8 @@ struct midi_ump {
143156
* @defgroup midi_ump_cmd MIDI commands
144157
* @ingroup midi_ump
145158
* @see ump112: 7.3 MIDI 1.0 Channel Voice Messages
146-
*
147-
* When UMP_MT(x)=UMP_MT_MIDI1_CHANNEL_VOICE or UMP_MT_MIDI2_CHANNEL_VOICE, then
148-
* UMP_MIDI_COMMAND(x) may be one of:
159+
* @remark When UMP_MT(x)=UMP_MT_MIDI1_CHANNEL_VOICE or UMP_MT_MIDI2_CHANNEL_VOICE,
160+
* then UMP_MIDI_COMMAND(x) may be one of:
149161
* @{
150162
*/
151163
#define UMP_MIDI_NOTE_OFF 0x8 /**< Note Off (p1=note number, p2=velocity) */
@@ -180,7 +192,8 @@ struct midi_ump {
180192
* @ingroup midi_ump
181193
* @see ump112: 7.6 System Common and System Real Time Messages
182194
*
183-
* When UMP_MT(x)=UMP_MT_SYS_RT_COMMON, UMP_MIDI_STATUS(x) may be one of:
195+
* @remark When UMP_MT(x)=UMP_MT_SYS_RT_COMMON,
196+
* then UMP_MIDI_STATUS(x) may be one of:
184197
* @{
185198
*/
186199
#define UMP_SYS_MIDI_TIME_CODE 0xf1 /**< MIDI Time Code (no param) */

0 commit comments

Comments
 (0)