dhgdh
Dependencies: MAX44000 PWM_Tone_Library nexpaq_mdk
Fork of LED_Demo by
mbd_os/libraries/USBHost/USBHostMIDI/USBHostMIDI.h@9:6bb35cef007d, 2016-10-22 (annotated)
- Committer:
- cyberjoey
- Date:
- Sat Oct 22 01:31:58 2016 +0000
- Revision:
- 9:6bb35cef007d
- Parent:
- 1:55a6170b404f
WORKING
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nexpaq | 1:55a6170b404f | 1 | /* Copyright (c) 2014 mbed.org, MIT License |
nexpaq | 1:55a6170b404f | 2 | * |
nexpaq | 1:55a6170b404f | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
nexpaq | 1:55a6170b404f | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
nexpaq | 1:55a6170b404f | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
nexpaq | 1:55a6170b404f | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
nexpaq | 1:55a6170b404f | 7 | * Software is furnished to do so, subject to the following conditions: |
nexpaq | 1:55a6170b404f | 8 | * |
nexpaq | 1:55a6170b404f | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
nexpaq | 1:55a6170b404f | 10 | * substantial portions of the Software. |
nexpaq | 1:55a6170b404f | 11 | * |
nexpaq | 1:55a6170b404f | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
nexpaq | 1:55a6170b404f | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
nexpaq | 1:55a6170b404f | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
nexpaq | 1:55a6170b404f | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
nexpaq | 1:55a6170b404f | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
nexpaq | 1:55a6170b404f | 17 | */ |
nexpaq | 1:55a6170b404f | 18 | |
nexpaq | 1:55a6170b404f | 19 | #ifndef USBHOSTMIDI_H |
nexpaq | 1:55a6170b404f | 20 | #define USBHOSTMIDI_H |
nexpaq | 1:55a6170b404f | 21 | |
nexpaq | 1:55a6170b404f | 22 | #include "USBHostConf.h" |
nexpaq | 1:55a6170b404f | 23 | |
nexpaq | 1:55a6170b404f | 24 | #if USBHOST_MIDI |
nexpaq | 1:55a6170b404f | 25 | |
nexpaq | 1:55a6170b404f | 26 | #include "USBHost.h" |
nexpaq | 1:55a6170b404f | 27 | |
nexpaq | 1:55a6170b404f | 28 | /** |
nexpaq | 1:55a6170b404f | 29 | * A class to communicate a USB MIDI device |
nexpaq | 1:55a6170b404f | 30 | */ |
nexpaq | 1:55a6170b404f | 31 | class USBHostMIDI : public IUSBEnumerator { |
nexpaq | 1:55a6170b404f | 32 | public: |
nexpaq | 1:55a6170b404f | 33 | /** |
nexpaq | 1:55a6170b404f | 34 | * Constructor |
nexpaq | 1:55a6170b404f | 35 | */ |
nexpaq | 1:55a6170b404f | 36 | USBHostMIDI(); |
nexpaq | 1:55a6170b404f | 37 | |
nexpaq | 1:55a6170b404f | 38 | /** |
nexpaq | 1:55a6170b404f | 39 | * Check if a USB MIDI device is connected |
nexpaq | 1:55a6170b404f | 40 | * |
nexpaq | 1:55a6170b404f | 41 | * @returns true if a midi device is connected |
nexpaq | 1:55a6170b404f | 42 | */ |
nexpaq | 1:55a6170b404f | 43 | bool connected(); |
nexpaq | 1:55a6170b404f | 44 | |
nexpaq | 1:55a6170b404f | 45 | /** |
nexpaq | 1:55a6170b404f | 46 | * Try to connect a midi device |
nexpaq | 1:55a6170b404f | 47 | * |
nexpaq | 1:55a6170b404f | 48 | * @return true if connection was successful |
nexpaq | 1:55a6170b404f | 49 | */ |
nexpaq | 1:55a6170b404f | 50 | bool connect(); |
nexpaq | 1:55a6170b404f | 51 | |
nexpaq | 1:55a6170b404f | 52 | /** |
nexpaq | 1:55a6170b404f | 53 | * Attach a callback called when miscellaneous function code is received |
nexpaq | 1:55a6170b404f | 54 | * |
nexpaq | 1:55a6170b404f | 55 | * @param ptr function pointer |
nexpaq | 1:55a6170b404f | 56 | * prototype: void onMiscellaneousFunctionCode(uint8_t data1, uint8_t data2, uint8_t data3); |
nexpaq | 1:55a6170b404f | 57 | */ |
nexpaq | 1:55a6170b404f | 58 | inline void attachMiscellaneousFunctionCode(void (*fn)(uint8_t, uint8_t, uint8_t)) { |
nexpaq | 1:55a6170b404f | 59 | miscellaneousFunctionCode = fn; |
nexpaq | 1:55a6170b404f | 60 | } |
nexpaq | 1:55a6170b404f | 61 | |
nexpaq | 1:55a6170b404f | 62 | /** |
nexpaq | 1:55a6170b404f | 63 | * Attach a callback called when cable event is received |
nexpaq | 1:55a6170b404f | 64 | * |
nexpaq | 1:55a6170b404f | 65 | * @param ptr function pointer |
nexpaq | 1:55a6170b404f | 66 | * prototype: void onCableEvent(uint8_t data1, uint8_t data2, uint8_t data3); |
nexpaq | 1:55a6170b404f | 67 | */ |
nexpaq | 1:55a6170b404f | 68 | inline void attachCableEvent(void (*fn)(uint8_t, uint8_t, uint8_t)) { |
nexpaq | 1:55a6170b404f | 69 | cableEvent = fn; |
nexpaq | 1:55a6170b404f | 70 | } |
nexpaq | 1:55a6170b404f | 71 | |
nexpaq | 1:55a6170b404f | 72 | /** |
nexpaq | 1:55a6170b404f | 73 | * Attach a callback called when system exclusive is received |
nexpaq | 1:55a6170b404f | 74 | * |
nexpaq | 1:55a6170b404f | 75 | * @param ptr function pointer |
nexpaq | 1:55a6170b404f | 76 | * prototype: void onSystemCommonTwoBytes(uint8_t data1, uint8_t data2); |
nexpaq | 1:55a6170b404f | 77 | */ |
nexpaq | 1:55a6170b404f | 78 | inline void attachSystemCommonTwoBytes(void (*fn)(uint8_t, uint8_t)) { |
nexpaq | 1:55a6170b404f | 79 | systemCommonTwoBytes = fn; |
nexpaq | 1:55a6170b404f | 80 | } |
nexpaq | 1:55a6170b404f | 81 | |
nexpaq | 1:55a6170b404f | 82 | /** |
nexpaq | 1:55a6170b404f | 83 | * Attach a callback called when system exclusive is received |
nexpaq | 1:55a6170b404f | 84 | * |
nexpaq | 1:55a6170b404f | 85 | * @param ptr function pointer |
nexpaq | 1:55a6170b404f | 86 | * prototype: void onSystemCommonThreeBytes(uint8_t data1, uint8_t data2, uint8_t data3); |
nexpaq | 1:55a6170b404f | 87 | */ |
nexpaq | 1:55a6170b404f | 88 | inline void attachSystemCommonThreeBytes(void (*fn)(uint8_t, uint8_t, uint8_t)) { |
nexpaq | 1:55a6170b404f | 89 | systemCommonThreeBytes = fn; |
nexpaq | 1:55a6170b404f | 90 | } |
nexpaq | 1:55a6170b404f | 91 | |
nexpaq | 1:55a6170b404f | 92 | /** |
nexpaq | 1:55a6170b404f | 93 | * Attach a callback called when system exclusive is received |
nexpaq | 1:55a6170b404f | 94 | * |
nexpaq | 1:55a6170b404f | 95 | * @param ptr function pointer |
nexpaq | 1:55a6170b404f | 96 | * prototype: void onSystemExclusive(uint8_t *data, uint16_t length, bool hasNextData); |
nexpaq | 1:55a6170b404f | 97 | */ |
nexpaq | 1:55a6170b404f | 98 | inline void attachSystemExclusive(void (*fn)(uint8_t *, uint16_t, bool)) { |
nexpaq | 1:55a6170b404f | 99 | systemExclusive = fn; |
nexpaq | 1:55a6170b404f | 100 | } |
nexpaq | 1:55a6170b404f | 101 | |
nexpaq | 1:55a6170b404f | 102 | /** |
nexpaq | 1:55a6170b404f | 103 | * Attach a callback called when note on is received |
nexpaq | 1:55a6170b404f | 104 | * |
nexpaq | 1:55a6170b404f | 105 | * @param ptr function pointer |
nexpaq | 1:55a6170b404f | 106 | * prototype: void onNoteOn(uint8_t channel, uint8_t note, uint8_t velocity); |
nexpaq | 1:55a6170b404f | 107 | */ |
nexpaq | 1:55a6170b404f | 108 | inline void attachNoteOn(void (*fn)(uint8_t, uint8_t, uint8_t)) { |
nexpaq | 1:55a6170b404f | 109 | noteOn = fn; |
nexpaq | 1:55a6170b404f | 110 | } |
nexpaq | 1:55a6170b404f | 111 | |
nexpaq | 1:55a6170b404f | 112 | /** |
nexpaq | 1:55a6170b404f | 113 | * Attach a callback called when note off is received |
nexpaq | 1:55a6170b404f | 114 | * |
nexpaq | 1:55a6170b404f | 115 | * @param ptr function pointer |
nexpaq | 1:55a6170b404f | 116 | * prototype: void onNoteOff(uint8_t channel, uint8_t note, uint8_t velocity); |
nexpaq | 1:55a6170b404f | 117 | */ |
nexpaq | 1:55a6170b404f | 118 | inline void attachNoteOff(void (*fn)(uint8_t, uint8_t, uint8_t)) { |
nexpaq | 1:55a6170b404f | 119 | noteOff = fn; |
nexpaq | 1:55a6170b404f | 120 | } |
nexpaq | 1:55a6170b404f | 121 | |
nexpaq | 1:55a6170b404f | 122 | /** |
nexpaq | 1:55a6170b404f | 123 | * Attach a callback called when poly keypress is received |
nexpaq | 1:55a6170b404f | 124 | * |
nexpaq | 1:55a6170b404f | 125 | * @param ptr function pointer |
nexpaq | 1:55a6170b404f | 126 | * prototype: void onPolyKeyPress(uint8_t channel, uint8_t note, uint8_t pressure); |
nexpaq | 1:55a6170b404f | 127 | */ |
nexpaq | 1:55a6170b404f | 128 | inline void attachPolyKeyPress(void (*fn)(uint8_t, uint8_t, uint8_t)) { |
nexpaq | 1:55a6170b404f | 129 | polyKeyPress = fn; |
nexpaq | 1:55a6170b404f | 130 | } |
nexpaq | 1:55a6170b404f | 131 | |
nexpaq | 1:55a6170b404f | 132 | /** |
nexpaq | 1:55a6170b404f | 133 | * Attach a callback called when control change is received |
nexpaq | 1:55a6170b404f | 134 | * |
nexpaq | 1:55a6170b404f | 135 | * @param ptr function pointer |
nexpaq | 1:55a6170b404f | 136 | * prototype: void onControlChange(uint8_t channel, uint8_t key, uint8_t value); |
nexpaq | 1:55a6170b404f | 137 | */ |
nexpaq | 1:55a6170b404f | 138 | inline void attachControlChange(void (*fn)(uint8_t, uint8_t, uint8_t)) { |
nexpaq | 1:55a6170b404f | 139 | controlChange = fn; |
nexpaq | 1:55a6170b404f | 140 | } |
nexpaq | 1:55a6170b404f | 141 | |
nexpaq | 1:55a6170b404f | 142 | /** |
nexpaq | 1:55a6170b404f | 143 | * Attach a callback called when program change is received |
nexpaq | 1:55a6170b404f | 144 | * |
nexpaq | 1:55a6170b404f | 145 | * @param ptr function pointer |
nexpaq | 1:55a6170b404f | 146 | * prototype: void onProgramChange(uint8_t channel, uint8_t program); |
nexpaq | 1:55a6170b404f | 147 | */ |
nexpaq | 1:55a6170b404f | 148 | inline void attachProgramChange(void (*fn)(uint8_t, uint8_t)) { |
nexpaq | 1:55a6170b404f | 149 | programChange = fn; |
nexpaq | 1:55a6170b404f | 150 | } |
nexpaq | 1:55a6170b404f | 151 | |
nexpaq | 1:55a6170b404f | 152 | /** |
nexpaq | 1:55a6170b404f | 153 | * Attach a callback called when channel pressure is received |
nexpaq | 1:55a6170b404f | 154 | * |
nexpaq | 1:55a6170b404f | 155 | * @param ptr function pointer |
nexpaq | 1:55a6170b404f | 156 | * prototype: void onChannelPressure(uint8_t channel, uint8_t pressure); |
nexpaq | 1:55a6170b404f | 157 | */ |
nexpaq | 1:55a6170b404f | 158 | inline void attachChannelPressure(void (*fn)(uint8_t, uint8_t)) { |
nexpaq | 1:55a6170b404f | 159 | channelPressure = fn; |
nexpaq | 1:55a6170b404f | 160 | } |
nexpaq | 1:55a6170b404f | 161 | |
nexpaq | 1:55a6170b404f | 162 | /** |
nexpaq | 1:55a6170b404f | 163 | * Attach a callback called when pitch bend is received |
nexpaq | 1:55a6170b404f | 164 | * |
nexpaq | 1:55a6170b404f | 165 | * @param ptr function pointer |
nexpaq | 1:55a6170b404f | 166 | * prototype: void onPitchBend(uint8_t channel, uint16_t value); |
nexpaq | 1:55a6170b404f | 167 | */ |
nexpaq | 1:55a6170b404f | 168 | inline void attachPitchBend(void (*fn)(uint8_t, uint16_t)) { |
nexpaq | 1:55a6170b404f | 169 | pitchBend = fn; |
nexpaq | 1:55a6170b404f | 170 | } |
nexpaq | 1:55a6170b404f | 171 | |
nexpaq | 1:55a6170b404f | 172 | /** |
nexpaq | 1:55a6170b404f | 173 | * Attach a callback called when single byte is received |
nexpaq | 1:55a6170b404f | 174 | * |
nexpaq | 1:55a6170b404f | 175 | * @param ptr function pointer |
nexpaq | 1:55a6170b404f | 176 | * prototype: void onSingleByte(uint8_t value); |
nexpaq | 1:55a6170b404f | 177 | */ |
nexpaq | 1:55a6170b404f | 178 | inline void attachSingleByte(void (*fn)(uint8_t)) { |
nexpaq | 1:55a6170b404f | 179 | singleByte = fn; |
nexpaq | 1:55a6170b404f | 180 | } |
nexpaq | 1:55a6170b404f | 181 | |
nexpaq | 1:55a6170b404f | 182 | /** |
nexpaq | 1:55a6170b404f | 183 | * Send a cable event with 3 bytes event |
nexpaq | 1:55a6170b404f | 184 | * |
nexpaq | 1:55a6170b404f | 185 | * @param data1 0-255 |
nexpaq | 1:55a6170b404f | 186 | * @param data2 0-255 |
nexpaq | 1:55a6170b404f | 187 | * @param data3 0-255 |
nexpaq | 1:55a6170b404f | 188 | * @return true if message sent successfully |
nexpaq | 1:55a6170b404f | 189 | */ |
nexpaq | 1:55a6170b404f | 190 | bool sendMiscellaneousFunctionCode(uint8_t data1, uint8_t data2, uint8_t data3); |
nexpaq | 1:55a6170b404f | 191 | |
nexpaq | 1:55a6170b404f | 192 | /** |
nexpaq | 1:55a6170b404f | 193 | * Send a cable event with 3 bytes event |
nexpaq | 1:55a6170b404f | 194 | * |
nexpaq | 1:55a6170b404f | 195 | * @param data1 0-255 |
nexpaq | 1:55a6170b404f | 196 | * @param data2 0-255 |
nexpaq | 1:55a6170b404f | 197 | * @param data3 0-255 |
nexpaq | 1:55a6170b404f | 198 | * @return true if message sent successfully |
nexpaq | 1:55a6170b404f | 199 | */ |
nexpaq | 1:55a6170b404f | 200 | bool sendCableEvent(uint8_t data1, uint8_t data2, uint8_t data3); |
nexpaq | 1:55a6170b404f | 201 | |
nexpaq | 1:55a6170b404f | 202 | /** |
nexpaq | 1:55a6170b404f | 203 | * Send a system common message with 2 bytes event |
nexpaq | 1:55a6170b404f | 204 | * |
nexpaq | 1:55a6170b404f | 205 | * @param data1 0-255 |
nexpaq | 1:55a6170b404f | 206 | * @param data2 0-255 |
nexpaq | 1:55a6170b404f | 207 | * @return true if message sent successfully |
nexpaq | 1:55a6170b404f | 208 | */ |
nexpaq | 1:55a6170b404f | 209 | bool sendSystemCommmonTwoBytes(uint8_t data1, uint8_t data2); |
nexpaq | 1:55a6170b404f | 210 | |
nexpaq | 1:55a6170b404f | 211 | /** |
nexpaq | 1:55a6170b404f | 212 | * Send a system common message with 3 bytes event |
nexpaq | 1:55a6170b404f | 213 | * |
nexpaq | 1:55a6170b404f | 214 | * @param data1 0-255 |
nexpaq | 1:55a6170b404f | 215 | * @param data2 0-255 |
nexpaq | 1:55a6170b404f | 216 | * @param data3 0-255 |
nexpaq | 1:55a6170b404f | 217 | * @return true if message sent successfully |
nexpaq | 1:55a6170b404f | 218 | */ |
nexpaq | 1:55a6170b404f | 219 | bool sendSystemCommmonThreeBytes(uint8_t data1, uint8_t data2, uint8_t data3); |
nexpaq | 1:55a6170b404f | 220 | |
nexpaq | 1:55a6170b404f | 221 | /** |
nexpaq | 1:55a6170b404f | 222 | * Send a system exclusive event |
nexpaq | 1:55a6170b404f | 223 | * |
nexpaq | 1:55a6170b404f | 224 | * @param buffer, starts with 0xF0, and end with 0xf7 |
nexpaq | 1:55a6170b404f | 225 | * @param length |
nexpaq | 1:55a6170b404f | 226 | * @return true if message sent successfully |
nexpaq | 1:55a6170b404f | 227 | */ |
nexpaq | 1:55a6170b404f | 228 | bool sendSystemExclusive(uint8_t *buffer, int length); |
nexpaq | 1:55a6170b404f | 229 | |
nexpaq | 1:55a6170b404f | 230 | /** |
nexpaq | 1:55a6170b404f | 231 | * Send a note off event |
nexpaq | 1:55a6170b404f | 232 | * |
nexpaq | 1:55a6170b404f | 233 | * @param channel 0-15 |
nexpaq | 1:55a6170b404f | 234 | * @param note 0-127 |
nexpaq | 1:55a6170b404f | 235 | * @param velocity 0-127 |
nexpaq | 1:55a6170b404f | 236 | * @return true if message sent successfully |
nexpaq | 1:55a6170b404f | 237 | */ |
nexpaq | 1:55a6170b404f | 238 | bool sendNoteOff(uint8_t channel, uint8_t note, uint8_t velocity); |
nexpaq | 1:55a6170b404f | 239 | |
nexpaq | 1:55a6170b404f | 240 | /** |
nexpaq | 1:55a6170b404f | 241 | * Send a note on event |
nexpaq | 1:55a6170b404f | 242 | * |
nexpaq | 1:55a6170b404f | 243 | * @param channel 0-15 |
nexpaq | 1:55a6170b404f | 244 | * @param note 0-127 |
nexpaq | 1:55a6170b404f | 245 | * @param velocity 0-127 (0 means note off) |
nexpaq | 1:55a6170b404f | 246 | * @return true if message sent successfully |
nexpaq | 1:55a6170b404f | 247 | */ |
nexpaq | 1:55a6170b404f | 248 | bool sendNoteOn(uint8_t channel, uint8_t note, uint8_t velocity); |
nexpaq | 1:55a6170b404f | 249 | |
nexpaq | 1:55a6170b404f | 250 | /** |
nexpaq | 1:55a6170b404f | 251 | * Send a poly keypress event |
nexpaq | 1:55a6170b404f | 252 | * |
nexpaq | 1:55a6170b404f | 253 | * @param channel 0-15 |
nexpaq | 1:55a6170b404f | 254 | * @param note 0-127 |
nexpaq | 1:55a6170b404f | 255 | * @param pressure 0-127 |
nexpaq | 1:55a6170b404f | 256 | * @return true if message sent successfully |
nexpaq | 1:55a6170b404f | 257 | */ |
nexpaq | 1:55a6170b404f | 258 | bool sendPolyKeyPress(uint8_t channel, uint8_t note, uint8_t pressure); |
nexpaq | 1:55a6170b404f | 259 | |
nexpaq | 1:55a6170b404f | 260 | /** |
nexpaq | 1:55a6170b404f | 261 | * Send a control change event |
nexpaq | 1:55a6170b404f | 262 | * |
nexpaq | 1:55a6170b404f | 263 | * @param channel 0-15 |
nexpaq | 1:55a6170b404f | 264 | * @param key 0-127 |
nexpaq | 1:55a6170b404f | 265 | * @param value 0-127 |
nexpaq | 1:55a6170b404f | 266 | * @return true if message sent successfully |
nexpaq | 1:55a6170b404f | 267 | */ |
nexpaq | 1:55a6170b404f | 268 | bool sendControlChange(uint8_t channel, uint8_t key, uint8_t value); |
nexpaq | 1:55a6170b404f | 269 | |
nexpaq | 1:55a6170b404f | 270 | /** |
nexpaq | 1:55a6170b404f | 271 | * Send a program change event |
nexpaq | 1:55a6170b404f | 272 | * |
nexpaq | 1:55a6170b404f | 273 | * @param channel 0-15 |
nexpaq | 1:55a6170b404f | 274 | * @param program 0-127 |
nexpaq | 1:55a6170b404f | 275 | * @return true if message sent successfully |
nexpaq | 1:55a6170b404f | 276 | */ |
nexpaq | 1:55a6170b404f | 277 | bool sendProgramChange(uint8_t channel, uint8_t program); |
nexpaq | 1:55a6170b404f | 278 | |
nexpaq | 1:55a6170b404f | 279 | /** |
nexpaq | 1:55a6170b404f | 280 | * Send a channel pressure event |
nexpaq | 1:55a6170b404f | 281 | * |
nexpaq | 1:55a6170b404f | 282 | * @param channel 0-15 |
nexpaq | 1:55a6170b404f | 283 | * @param pressure 0-127 |
nexpaq | 1:55a6170b404f | 284 | * @return true if message sent successfully |
nexpaq | 1:55a6170b404f | 285 | */ |
nexpaq | 1:55a6170b404f | 286 | bool sendChannelPressure(uint8_t channel, uint8_t pressure); |
nexpaq | 1:55a6170b404f | 287 | |
nexpaq | 1:55a6170b404f | 288 | /** |
nexpaq | 1:55a6170b404f | 289 | * Send a control change event |
nexpaq | 1:55a6170b404f | 290 | * |
nexpaq | 1:55a6170b404f | 291 | * @param channel 0-15 |
nexpaq | 1:55a6170b404f | 292 | * @param key 0(lower)-8191(center)-16383(higher) |
nexpaq | 1:55a6170b404f | 293 | * @return true if message sent successfully |
nexpaq | 1:55a6170b404f | 294 | */ |
nexpaq | 1:55a6170b404f | 295 | bool sendPitchBend(uint8_t channel, uint16_t value); |
nexpaq | 1:55a6170b404f | 296 | |
nexpaq | 1:55a6170b404f | 297 | /** |
nexpaq | 1:55a6170b404f | 298 | * Send a single byte event |
nexpaq | 1:55a6170b404f | 299 | * |
nexpaq | 1:55a6170b404f | 300 | * @param data 0-255 |
nexpaq | 1:55a6170b404f | 301 | * @return true if message sent successfully |
nexpaq | 1:55a6170b404f | 302 | */ |
nexpaq | 1:55a6170b404f | 303 | bool sendSingleByte(uint8_t data); |
nexpaq | 1:55a6170b404f | 304 | |
nexpaq | 1:55a6170b404f | 305 | protected: |
nexpaq | 1:55a6170b404f | 306 | //From IUSBEnumerator |
nexpaq | 1:55a6170b404f | 307 | virtual void setVidPid(uint16_t vid, uint16_t pid); |
nexpaq | 1:55a6170b404f | 308 | virtual bool parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol); //Must return true if the interface should be parsed |
nexpaq | 1:55a6170b404f | 309 | virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used |
nexpaq | 1:55a6170b404f | 310 | |
nexpaq | 1:55a6170b404f | 311 | private: |
nexpaq | 1:55a6170b404f | 312 | USBHost * host; |
nexpaq | 1:55a6170b404f | 313 | USBDeviceConnected * dev; |
nexpaq | 1:55a6170b404f | 314 | USBEndpoint * bulk_in; |
nexpaq | 1:55a6170b404f | 315 | USBEndpoint * bulk_out; |
nexpaq | 1:55a6170b404f | 316 | uint32_t size_bulk_in; |
nexpaq | 1:55a6170b404f | 317 | uint32_t size_bulk_out; |
nexpaq | 1:55a6170b404f | 318 | |
nexpaq | 1:55a6170b404f | 319 | bool dev_connected; |
nexpaq | 1:55a6170b404f | 320 | |
nexpaq | 1:55a6170b404f | 321 | void init(); |
nexpaq | 1:55a6170b404f | 322 | |
nexpaq | 1:55a6170b404f | 323 | uint8_t buf[64]; |
nexpaq | 1:55a6170b404f | 324 | |
nexpaq | 1:55a6170b404f | 325 | void rxHandler(); |
nexpaq | 1:55a6170b404f | 326 | |
nexpaq | 1:55a6170b404f | 327 | uint16_t sysExBufferPos; |
nexpaq | 1:55a6170b404f | 328 | uint8_t sysExBuffer[64]; |
nexpaq | 1:55a6170b404f | 329 | |
nexpaq | 1:55a6170b404f | 330 | void (*miscellaneousFunctionCode)(uint8_t, uint8_t, uint8_t); |
nexpaq | 1:55a6170b404f | 331 | void (*cableEvent)(uint8_t, uint8_t, uint8_t); |
nexpaq | 1:55a6170b404f | 332 | void (*systemCommonTwoBytes)(uint8_t, uint8_t); |
nexpaq | 1:55a6170b404f | 333 | void (*systemCommonThreeBytes)(uint8_t, uint8_t, uint8_t); |
nexpaq | 1:55a6170b404f | 334 | void (*systemExclusive)(uint8_t *, uint16_t, bool); |
nexpaq | 1:55a6170b404f | 335 | void (*noteOff)(uint8_t, uint8_t, uint8_t); |
nexpaq | 1:55a6170b404f | 336 | void (*noteOn)(uint8_t, uint8_t, uint8_t); |
nexpaq | 1:55a6170b404f | 337 | void (*polyKeyPress)(uint8_t, uint8_t, uint8_t); |
nexpaq | 1:55a6170b404f | 338 | void (*controlChange)(uint8_t, uint8_t, uint8_t); |
nexpaq | 1:55a6170b404f | 339 | void (*programChange)(uint8_t, uint8_t); |
nexpaq | 1:55a6170b404f | 340 | void (*channelPressure)(uint8_t, uint8_t); |
nexpaq | 1:55a6170b404f | 341 | void (*pitchBend)(uint8_t, uint16_t); |
nexpaq | 1:55a6170b404f | 342 | void (*singleByte)(uint8_t); |
nexpaq | 1:55a6170b404f | 343 | |
nexpaq | 1:55a6170b404f | 344 | bool sendMidiBuffer(uint8_t data0, uint8_t data1, uint8_t data2, uint8_t data3); |
nexpaq | 1:55a6170b404f | 345 | |
nexpaq | 1:55a6170b404f | 346 | int midi_intf; |
nexpaq | 1:55a6170b404f | 347 | bool midi_device_found; |
nexpaq | 1:55a6170b404f | 348 | |
nexpaq | 1:55a6170b404f | 349 | }; |
nexpaq | 1:55a6170b404f | 350 | |
nexpaq | 1:55a6170b404f | 351 | #endif /* USBHOST_MIDI */ |
nexpaq | 1:55a6170b404f | 352 | |
nexpaq | 1:55a6170b404f | 353 | #endif /* USBHOSTMIDI_H */ |