1
1
// ================================================================================
2
2
// ================================================================================
3
- // MIDI USB class
4
3
4
+ /* *
5
+ MIDI USB class
6
+ */
5
7
#ifndef MIDIUSB_h
6
8
#define MIDIUSB_h
7
9
@@ -88,7 +90,7 @@ typedef struct
88
90
#define MIDI_JACK_EXT 0X02
89
91
90
92
_Pragma (" pack(1)" )
91
-
93
+ // / Midi Audio Control Interface Descriptor
92
94
typedef struct
93
95
{
94
96
uint8_t len; // 9
@@ -123,13 +125,15 @@ typedef struct
123
125
uint8_t jackStrIndex;
124
126
} MIDIJackOutDescriptor;
125
127
128
+ // / MIDI Jack EndPoint Descriptor, common to midi in and out jacks.
126
129
typedef struct
127
130
{
128
131
EndpointDescriptor len; // 9
129
132
uint8_t refresh; // 4
130
133
uint8_t sync;
131
134
} MIDI_EPDescriptor;
132
135
136
+ // / MIDI Jack EndPoint AudioControl Descriptor, common to midi in and out ac jacks.
133
137
typedef struct
134
138
{
135
139
uint8_t len; // 5
@@ -139,6 +143,7 @@ typedef struct
139
143
uint8_t jackID;
140
144
} MIDI_EP_ACDescriptor;
141
145
146
+ // / MIDI Audio Stream Descriptor Interface
142
147
typedef struct
143
148
{
144
149
uint8_t len; // 9
@@ -148,6 +153,7 @@ typedef struct
148
153
uint16_t wTotalLength;
149
154
} MIDI_ASInterfaceDescriptor;
150
155
156
+ // / Top Level MIDI Descriptor used to create a Midi Interface instace \see MIDI_::getInterface()
151
157
typedef struct
152
158
{
153
159
// IAD
@@ -192,32 +198,53 @@ typedef struct
192
198
#define D_CDCCS (_subtype,_d0,_d1 ) { 5 , 0x24 , _subtype, _d0, _d1 }
193
199
#define D_CDCCS4 (_subtype,_d0 ) { 4 , 0x24 , _subtype, _d0 }
194
200
201
+ #ifndef DOXYGEN_ARD
202
+ // the following would confuse doxygen documentation tool, so skip in that case for autodoc build
195
203
_Pragma (" pack()" )
196
204
197
205
#define WEAK __attribute__ ((weak))
198
206
207
+ #endif
208
+
209
+ /* *
210
+ Concrete MIDI implementation of a PluggableUSBModule
211
+ By default, will define one midi in and one midi out enpoints.
212
+ */
199
213
class MIDI_ : public PluggableUSBModule
200
214
{
201
215
// private:
202
216
// RingBuffer *_midi_rx_buffer;
203
217
private:
204
- void accept (void );
205
- EPTYPE_DESCRIPTOR_SIZE epType[2 ];
218
+ void accept (void ); // /< Accepts a midi packet, \see MIDI_::read()
219
+ EPTYPE_DESCRIPTOR_SIZE epType[2 ]; // /< Container that defines the two bulk MIDI IN/OUT endpoints types
206
220
207
221
protected:
208
222
// Implementation of the PUSBListNode
223
+
224
+ // / Creates a MIDIDescriptor midi interface and sollicit USBDevice to send control to it.
225
+ // / \see USBDevice::SendControl()
209
226
int getInterface (uint8_t * interfaceNum);
227
+ // / Current implementation just returns 0
210
228
int getDescriptor (USBSetup& setup);
229
+ // / Optional interface usb setup callback, current implementation returns false
211
230
bool setup (USBSetup& setup);
231
+ // / MIDI Device short name, defaults to "MIDI" and returns a length of 4 chars
212
232
uint8_t getShortName (char * name);
213
233
214
234
public:
235
+ // / Creates a MIDI USB device with 2 endpoints
215
236
MIDI_ (void );
237
+ // / Returns the number of bytes currently available from RX
216
238
uint32_t available (void );
239
+ // / Reads a new MIDI message from USB
217
240
midiEventPacket_t read (void );
241
+ // / Flushes TX midi channel
218
242
void flush (void );
243
+ // / Sends a MIDI message to USB
219
244
void sendMIDI (midiEventPacket_t event);
245
+ // / Sends a MIDI buffer of length size to USB
220
246
size_t write (const uint8_t *buffer, size_t size);
247
+ // / NIY
221
248
operator bool ();
222
249
};
223
250
extern MIDI_ MidiUSB;
0 commit comments