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