My Fork of F401RE-USBHost. Add USBHostMIDI functions (originaled by Kaoru Shoji http://mbed.org/users/kshoji/code/USBHostMIDI/)
Dependents: F401RE-USBHostMIDI_RecieveExample
Fork of F401RE-USBHost by
USBHostMIDI/USBHostMIDI.h@24:5281ea9f6e68, 2014-09-18 (annotated)
- Committer:
- hsgw
- Date:
- Thu Sep 18 10:50:22 2014 +0000
- Revision:
- 24:5281ea9f6e68
- Parent:
- 23:9c1d09c6a2b6
- Child:
- 25:c4fdd0b4e643
add other midi status. ; but miscellaneous function and cable event has been disabled.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hsgw | 24:5281ea9f6e68 | 1 | /* USBHostMidi library |
hsgw | 24:5281ea9f6e68 | 2 | * Originaled by k.shoji |
hsgw | 24:5281ea9f6e68 | 3 | * porting by Takuya Urakawa |
hsgw | 24:5281ea9f6e68 | 4 | */ |
hsgw | 24:5281ea9f6e68 | 5 | |
hsgw | 24:5281ea9f6e68 | 6 | /* mbed USBHost Library |
hsgw | 24:5281ea9f6e68 | 7 | * Copyright (c) 2006-2013 ARM Limited |
hsgw | 24:5281ea9f6e68 | 8 | * |
hsgw | 24:5281ea9f6e68 | 9 | * Licensed under the Apache License, Version 2.0 (the "License"); |
hsgw | 24:5281ea9f6e68 | 10 | * you may not use this file except in compliance with the License. |
hsgw | 24:5281ea9f6e68 | 11 | * You may obtain a copy of the License at |
hsgw | 24:5281ea9f6e68 | 12 | * |
hsgw | 24:5281ea9f6e68 | 13 | * http://www.apache.org/licenses/LICENSE-2.0 |
hsgw | 24:5281ea9f6e68 | 14 | * |
hsgw | 24:5281ea9f6e68 | 15 | * Unless required by applicable law or agreed to in writing, software |
hsgw | 24:5281ea9f6e68 | 16 | * distributed under the License is distributed on an "AS IS" BASIS, |
hsgw | 24:5281ea9f6e68 | 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
hsgw | 24:5281ea9f6e68 | 18 | * See the License for the specific language governing permissions and |
hsgw | 24:5281ea9f6e68 | 19 | * limitations under the License. |
hsgw | 24:5281ea9f6e68 | 20 | */ |
hsgw | 24:5281ea9f6e68 | 21 | |
hsgw | 24:5281ea9f6e68 | 22 | #ifndef USBHOSTMIDI_H |
hsgw | 24:5281ea9f6e68 | 23 | #define USBHOSTMIDI_H |
hsgw | 24:5281ea9f6e68 | 24 | |
hsgw | 24:5281ea9f6e68 | 25 | #include "USBHostConf.h" |
hsgw | 24:5281ea9f6e68 | 26 | |
hsgw | 24:5281ea9f6e68 | 27 | #if USBHOST_MIDI |
hsgw | 24:5281ea9f6e68 | 28 | |
hsgw | 24:5281ea9f6e68 | 29 | #include "USBHost.h" |
hsgw | 24:5281ea9f6e68 | 30 | |
hsgw | 24:5281ea9f6e68 | 31 | /** |
hsgw | 24:5281ea9f6e68 | 32 | * A class to communicate a USB MIDI device |
hsgw | 24:5281ea9f6e68 | 33 | */ |
hsgw | 24:5281ea9f6e68 | 34 | class USBHostMIDI : public IUSBEnumerator { |
hsgw | 24:5281ea9f6e68 | 35 | public: |
hsgw | 24:5281ea9f6e68 | 36 | /** |
hsgw | 24:5281ea9f6e68 | 37 | * Constructor |
hsgw | 24:5281ea9f6e68 | 38 | */ |
hsgw | 24:5281ea9f6e68 | 39 | USBHostMIDI(); |
hsgw | 24:5281ea9f6e68 | 40 | |
hsgw | 24:5281ea9f6e68 | 41 | /** |
hsgw | 24:5281ea9f6e68 | 42 | * Check if a USB MIDI device is connected |
hsgw | 24:5281ea9f6e68 | 43 | * |
hsgw | 24:5281ea9f6e68 | 44 | * @returns true if a midi device is connected |
hsgw | 24:5281ea9f6e68 | 45 | */ |
hsgw | 24:5281ea9f6e68 | 46 | bool connected(); |
hsgw | 24:5281ea9f6e68 | 47 | |
hsgw | 24:5281ea9f6e68 | 48 | /** |
hsgw | 24:5281ea9f6e68 | 49 | * Try to connect a midi device |
hsgw | 24:5281ea9f6e68 | 50 | * |
hsgw | 24:5281ea9f6e68 | 51 | * @return true if connection was successful |
hsgw | 24:5281ea9f6e68 | 52 | */ |
hsgw | 24:5281ea9f6e68 | 53 | bool connect(); |
hsgw | 24:5281ea9f6e68 | 54 | |
hsgw | 24:5281ea9f6e68 | 55 | /** |
hsgw | 24:5281ea9f6e68 | 56 | * Attach a callback called when miscellaneous function code is received |
hsgw | 24:5281ea9f6e68 | 57 | * @warning DISABLED |
hsgw | 24:5281ea9f6e68 | 58 | * |
hsgw | 24:5281ea9f6e68 | 59 | * @param ptr function pointer |
hsgw | 24:5281ea9f6e68 | 60 | * prototype: void onMiscellaneousFunctionCode(uint8_t data1, uint8_t data2, uint8_t data3); |
hsgw | 24:5281ea9f6e68 | 61 | */ |
hsgw | 24:5281ea9f6e68 | 62 | inline void attachMiscellaneousFunctionCode(void (*fn)(uint8_t, uint8_t, uint8_t)) { |
hsgw | 24:5281ea9f6e68 | 63 | miscellaneousFunctionCode = fn; |
hsgw | 24:5281ea9f6e68 | 64 | } |
hsgw | 24:5281ea9f6e68 | 65 | |
hsgw | 24:5281ea9f6e68 | 66 | /** |
hsgw | 24:5281ea9f6e68 | 67 | * Attach a callback called when cable event is received |
hsgw | 24:5281ea9f6e68 | 68 | * @warning DISABLED |
hsgw | 24:5281ea9f6e68 | 69 | * |
hsgw | 24:5281ea9f6e68 | 70 | * @param ptr function pointer |
hsgw | 24:5281ea9f6e68 | 71 | * prototype: void onCableEvent(uint8_t data1, uint8_t data2, uint8_t data3); |
hsgw | 24:5281ea9f6e68 | 72 | */ |
hsgw | 24:5281ea9f6e68 | 73 | inline void attachCableEvent(void (*fn)(uint8_t, uint8_t, uint8_t)) { |
hsgw | 24:5281ea9f6e68 | 74 | cableEvent = fn; |
hsgw | 24:5281ea9f6e68 | 75 | } |
hsgw | 24:5281ea9f6e68 | 76 | |
hsgw | 24:5281ea9f6e68 | 77 | /** |
hsgw | 24:5281ea9f6e68 | 78 | * Attach a callback called when system exclusive is received |
hsgw | 24:5281ea9f6e68 | 79 | * |
hsgw | 24:5281ea9f6e68 | 80 | * @param ptr function pointer |
hsgw | 24:5281ea9f6e68 | 81 | * prototype: void onSystemCommonTwoBytes(uint8_t data1, uint8_t data2); |
hsgw | 24:5281ea9f6e68 | 82 | */ |
hsgw | 24:5281ea9f6e68 | 83 | inline void attachSystemCommonTwoBytes(void (*fn)(uint8_t, uint8_t)) { |
hsgw | 24:5281ea9f6e68 | 84 | systemCommonTwoBytes = fn; |
hsgw | 24:5281ea9f6e68 | 85 | } |
hsgw | 24:5281ea9f6e68 | 86 | |
hsgw | 24:5281ea9f6e68 | 87 | /** |
hsgw | 24:5281ea9f6e68 | 88 | * Attach a callback called when system exclusive is received |
hsgw | 24:5281ea9f6e68 | 89 | * |
hsgw | 24:5281ea9f6e68 | 90 | * @param ptr function pointer |
hsgw | 24:5281ea9f6e68 | 91 | * prototype: void onSystemCommonThreeBytes(uint8_t data1, uint8_t data2, uint8_t data3); |
hsgw | 24:5281ea9f6e68 | 92 | */ |
hsgw | 24:5281ea9f6e68 | 93 | inline void attachSystemCommonThreeBytes(void (*fn)(uint8_t, uint8_t, uint8_t)) { |
hsgw | 24:5281ea9f6e68 | 94 | systemCommonThreeBytes = fn; |
hsgw | 24:5281ea9f6e68 | 95 | } |
hsgw | 24:5281ea9f6e68 | 96 | |
hsgw | 24:5281ea9f6e68 | 97 | /** |
hsgw | 24:5281ea9f6e68 | 98 | * Attach a callback called when system exclusive is received |
hsgw | 24:5281ea9f6e68 | 99 | * |
hsgw | 24:5281ea9f6e68 | 100 | * @param ptr function pointer |
hsgw | 24:5281ea9f6e68 | 101 | * prototype: void onSystemExclusive(uint8_t *data, uint16_t length, bool hasNextData); |
hsgw | 24:5281ea9f6e68 | 102 | */ |
hsgw | 24:5281ea9f6e68 | 103 | inline void attachSystemExclusive(void (*fn)(uint8_t *, uint16_t, bool)) { |
hsgw | 24:5281ea9f6e68 | 104 | systemExclusive = fn; |
hsgw | 24:5281ea9f6e68 | 105 | } |
hsgw | 24:5281ea9f6e68 | 106 | |
hsgw | 24:5281ea9f6e68 | 107 | /** |
hsgw | 24:5281ea9f6e68 | 108 | * Attach a callback called when note on is received |
hsgw | 24:5281ea9f6e68 | 109 | * |
hsgw | 24:5281ea9f6e68 | 110 | * @param ptr function pointer |
hsgw | 24:5281ea9f6e68 | 111 | * prototype: void onNoteOn(uint8_t channel, uint8_t note, uint8_t velocity); |
hsgw | 24:5281ea9f6e68 | 112 | */ |
hsgw | 24:5281ea9f6e68 | 113 | inline void attachNoteOn(void (*fn)(uint8_t, uint8_t, uint8_t)) { |
hsgw | 24:5281ea9f6e68 | 114 | noteOn = fn; |
hsgw | 24:5281ea9f6e68 | 115 | } |
hsgw | 24:5281ea9f6e68 | 116 | |
hsgw | 24:5281ea9f6e68 | 117 | /** |
hsgw | 24:5281ea9f6e68 | 118 | * Attach a callback called when note off is received |
hsgw | 24:5281ea9f6e68 | 119 | * |
hsgw | 24:5281ea9f6e68 | 120 | * @param ptr function pointer |
hsgw | 24:5281ea9f6e68 | 121 | * prototype: void onNoteOff(uint8_t channel, uint8_t note, uint8_t velocity); |
hsgw | 24:5281ea9f6e68 | 122 | */ |
hsgw | 24:5281ea9f6e68 | 123 | inline void attachNoteOff(void (*fn)(uint8_t, uint8_t, uint8_t)) { |
hsgw | 24:5281ea9f6e68 | 124 | noteOff = fn; |
hsgw | 24:5281ea9f6e68 | 125 | } |
hsgw | 24:5281ea9f6e68 | 126 | |
hsgw | 24:5281ea9f6e68 | 127 | /** |
hsgw | 24:5281ea9f6e68 | 128 | * Attach a callback called when poly keypress is received |
hsgw | 24:5281ea9f6e68 | 129 | * |
hsgw | 24:5281ea9f6e68 | 130 | * @param ptr function pointer |
hsgw | 24:5281ea9f6e68 | 131 | * prototype: void onPolyKeyPress(uint8_t channel, uint8_t note, uint8_t pressure); |
hsgw | 24:5281ea9f6e68 | 132 | */ |
hsgw | 24:5281ea9f6e68 | 133 | inline void attachPolyKeyPress(void (*fn)(uint8_t, uint8_t, uint8_t)) { |
hsgw | 24:5281ea9f6e68 | 134 | polyKeyPress = fn; |
hsgw | 24:5281ea9f6e68 | 135 | } |
hsgw | 24:5281ea9f6e68 | 136 | |
hsgw | 24:5281ea9f6e68 | 137 | /** |
hsgw | 24:5281ea9f6e68 | 138 | * Attach a callback called when control change is received |
hsgw | 24:5281ea9f6e68 | 139 | * |
hsgw | 24:5281ea9f6e68 | 140 | * @param ptr function pointer |
hsgw | 24:5281ea9f6e68 | 141 | * prototype: void onControlChange(uint8_t channel, uint8_t key, uint8_t value); |
hsgw | 24:5281ea9f6e68 | 142 | */ |
hsgw | 24:5281ea9f6e68 | 143 | inline void attachControlChange(void (*fn)(uint8_t, uint8_t, uint8_t)) { |
hsgw | 24:5281ea9f6e68 | 144 | controlChange = fn; |
hsgw | 24:5281ea9f6e68 | 145 | } |
hsgw | 24:5281ea9f6e68 | 146 | |
hsgw | 24:5281ea9f6e68 | 147 | /** |
hsgw | 24:5281ea9f6e68 | 148 | * Attach a callback called when program change is received |
hsgw | 24:5281ea9f6e68 | 149 | * |
hsgw | 24:5281ea9f6e68 | 150 | * @param ptr function pointer |
hsgw | 24:5281ea9f6e68 | 151 | * prototype: void onProgramChange(uint8_t channel, uint8_t program); |
hsgw | 24:5281ea9f6e68 | 152 | */ |
hsgw | 24:5281ea9f6e68 | 153 | inline void attachProgramChange(void (*fn)(uint8_t, uint8_t)) { |
hsgw | 24:5281ea9f6e68 | 154 | programChange = fn; |
hsgw | 24:5281ea9f6e68 | 155 | } |
hsgw | 24:5281ea9f6e68 | 156 | |
hsgw | 24:5281ea9f6e68 | 157 | /** |
hsgw | 24:5281ea9f6e68 | 158 | * Attach a callback called when channel pressure is received |
hsgw | 24:5281ea9f6e68 | 159 | * |
hsgw | 24:5281ea9f6e68 | 160 | * @param ptr function pointer |
hsgw | 24:5281ea9f6e68 | 161 | * prototype: void onChannelPressure(uint8_t channel, uint8_t pressure); |
hsgw | 24:5281ea9f6e68 | 162 | */ |
hsgw | 24:5281ea9f6e68 | 163 | inline void attachChannelPressure(void (*fn)(uint8_t, uint8_t)) { |
hsgw | 24:5281ea9f6e68 | 164 | channelPressure = fn; |
hsgw | 24:5281ea9f6e68 | 165 | } |
hsgw | 24:5281ea9f6e68 | 166 | |
hsgw | 24:5281ea9f6e68 | 167 | /** |
hsgw | 24:5281ea9f6e68 | 168 | * Attach a callback called when pitch bend is received |
hsgw | 24:5281ea9f6e68 | 169 | * |
hsgw | 24:5281ea9f6e68 | 170 | * @param ptr function pointer |
hsgw | 24:5281ea9f6e68 | 171 | * prototype: void onPitchBend(uint8_t channel, uint16_t value); |
hsgw | 24:5281ea9f6e68 | 172 | */ |
hsgw | 24:5281ea9f6e68 | 173 | inline void attachPitchBend(void (*fn)(uint8_t, uint16_t)) { |
hsgw | 24:5281ea9f6e68 | 174 | pitchBend = fn; |
hsgw | 24:5281ea9f6e68 | 175 | } |
hsgw | 24:5281ea9f6e68 | 176 | |
hsgw | 24:5281ea9f6e68 | 177 | /** |
hsgw | 24:5281ea9f6e68 | 178 | * Attach a callback called when single byte is received |
hsgw | 24:5281ea9f6e68 | 179 | * |
hsgw | 24:5281ea9f6e68 | 180 | * @param ptr function pointer |
hsgw | 24:5281ea9f6e68 | 181 | * prototype: void onSingleByte(uint8_t value); |
hsgw | 24:5281ea9f6e68 | 182 | */ |
hsgw | 24:5281ea9f6e68 | 183 | inline void attachSingleByte(void (*fn)(uint8_t)) { |
hsgw | 24:5281ea9f6e68 | 184 | singleByte = fn; |
hsgw | 24:5281ea9f6e68 | 185 | } |
hsgw | 24:5281ea9f6e68 | 186 | |
hsgw | 24:5281ea9f6e68 | 187 | /** |
hsgw | 24:5281ea9f6e68 | 188 | * Send a cable event with 3 bytes event |
hsgw | 24:5281ea9f6e68 | 189 | * |
hsgw | 24:5281ea9f6e68 | 190 | * @param data1 0-255 |
hsgw | 24:5281ea9f6e68 | 191 | * @param data2 0-255 |
hsgw | 24:5281ea9f6e68 | 192 | * @param data3 0-255 |
hsgw | 24:5281ea9f6e68 | 193 | * @return true if message sent successfully |
hsgw | 24:5281ea9f6e68 | 194 | */ |
hsgw | 24:5281ea9f6e68 | 195 | bool sendMiscellaneousFunctionCode(uint8_t data1, uint8_t data2, uint8_t data3); |
hsgw | 24:5281ea9f6e68 | 196 | |
hsgw | 24:5281ea9f6e68 | 197 | /** |
hsgw | 24:5281ea9f6e68 | 198 | * Send a cable event with 3 bytes event |
hsgw | 24:5281ea9f6e68 | 199 | * |
hsgw | 24:5281ea9f6e68 | 200 | * @param data1 0-255 |
hsgw | 24:5281ea9f6e68 | 201 | * @param data2 0-255 |
hsgw | 24:5281ea9f6e68 | 202 | * @param data3 0-255 |
hsgw | 24:5281ea9f6e68 | 203 | * @return true if message sent successfully |
hsgw | 24:5281ea9f6e68 | 204 | */ |
hsgw | 24:5281ea9f6e68 | 205 | bool sendCableEvent(uint8_t data1, uint8_t data2, uint8_t data3); |
hsgw | 24:5281ea9f6e68 | 206 | |
hsgw | 24:5281ea9f6e68 | 207 | /** |
hsgw | 24:5281ea9f6e68 | 208 | * Send a system common message with 2 bytes event |
hsgw | 24:5281ea9f6e68 | 209 | * |
hsgw | 24:5281ea9f6e68 | 210 | * @param data1 0-255 |
hsgw | 24:5281ea9f6e68 | 211 | * @param data2 0-255 |
hsgw | 24:5281ea9f6e68 | 212 | * @return true if message sent successfully |
hsgw | 24:5281ea9f6e68 | 213 | */ |
hsgw | 24:5281ea9f6e68 | 214 | bool sendSystemCommmonTwoBytes(uint8_t data1, uint8_t data2); |
hsgw | 24:5281ea9f6e68 | 215 | |
hsgw | 24:5281ea9f6e68 | 216 | /** |
hsgw | 24:5281ea9f6e68 | 217 | * Send a system common message with 3 bytes event |
hsgw | 24:5281ea9f6e68 | 218 | * |
hsgw | 24:5281ea9f6e68 | 219 | * @param data1 0-255 |
hsgw | 24:5281ea9f6e68 | 220 | * @param data2 0-255 |
hsgw | 24:5281ea9f6e68 | 221 | * @param data3 0-255 |
hsgw | 24:5281ea9f6e68 | 222 | * @return true if message sent successfully |
hsgw | 24:5281ea9f6e68 | 223 | */ |
hsgw | 24:5281ea9f6e68 | 224 | bool sendSystemCommmonThreeBytes(uint8_t data1, uint8_t data2, uint8_t data3); |
hsgw | 24:5281ea9f6e68 | 225 | |
hsgw | 24:5281ea9f6e68 | 226 | /** |
hsgw | 24:5281ea9f6e68 | 227 | * Send a system exclusive event |
hsgw | 24:5281ea9f6e68 | 228 | * |
hsgw | 24:5281ea9f6e68 | 229 | * @param buffer, starts with 0xF0, and end with 0xf7 |
hsgw | 24:5281ea9f6e68 | 230 | * @param length |
hsgw | 24:5281ea9f6e68 | 231 | * @return true if message sent successfully |
hsgw | 24:5281ea9f6e68 | 232 | */ |
hsgw | 24:5281ea9f6e68 | 233 | bool sendSystemExclusive(uint8_t *buffer, int length); |
hsgw | 24:5281ea9f6e68 | 234 | |
hsgw | 24:5281ea9f6e68 | 235 | /** |
hsgw | 24:5281ea9f6e68 | 236 | * Send a note off event |
hsgw | 24:5281ea9f6e68 | 237 | * |
hsgw | 24:5281ea9f6e68 | 238 | * @param channel 0-15 |
hsgw | 24:5281ea9f6e68 | 239 | * @param note 0-127 |
hsgw | 24:5281ea9f6e68 | 240 | * @param velocity 0-127 |
hsgw | 24:5281ea9f6e68 | 241 | * @return true if message sent successfully |
hsgw | 24:5281ea9f6e68 | 242 | */ |
hsgw | 24:5281ea9f6e68 | 243 | bool sendNoteOff(uint8_t channel, uint8_t note, uint8_t velocity); |
hsgw | 24:5281ea9f6e68 | 244 | |
hsgw | 24:5281ea9f6e68 | 245 | /** |
hsgw | 24:5281ea9f6e68 | 246 | * Send a note on event |
hsgw | 24:5281ea9f6e68 | 247 | * |
hsgw | 24:5281ea9f6e68 | 248 | * @param channel 0-15 |
hsgw | 24:5281ea9f6e68 | 249 | * @param note 0-127 |
hsgw | 24:5281ea9f6e68 | 250 | * @param velocity 0-127 (0 means note off) |
hsgw | 24:5281ea9f6e68 | 251 | * @return true if message sent successfully |
hsgw | 24:5281ea9f6e68 | 252 | */ |
hsgw | 24:5281ea9f6e68 | 253 | bool sendNoteOn(uint8_t channel, uint8_t note, uint8_t velocity); |
hsgw | 24:5281ea9f6e68 | 254 | |
hsgw | 24:5281ea9f6e68 | 255 | /** |
hsgw | 24:5281ea9f6e68 | 256 | * Send a poly keypress event |
hsgw | 24:5281ea9f6e68 | 257 | * |
hsgw | 24:5281ea9f6e68 | 258 | * @param channel 0-15 |
hsgw | 24:5281ea9f6e68 | 259 | * @param note 0-127 |
hsgw | 24:5281ea9f6e68 | 260 | * @param pressure 0-127 |
hsgw | 24:5281ea9f6e68 | 261 | * @return true if message sent successfully |
hsgw | 24:5281ea9f6e68 | 262 | */ |
hsgw | 24:5281ea9f6e68 | 263 | bool sendPolyKeyPress(uint8_t channel, uint8_t note, uint8_t pressure); |
hsgw | 24:5281ea9f6e68 | 264 | |
hsgw | 24:5281ea9f6e68 | 265 | /** |
hsgw | 24:5281ea9f6e68 | 266 | * Send a control change event |
hsgw | 24:5281ea9f6e68 | 267 | * |
hsgw | 24:5281ea9f6e68 | 268 | * @param channel 0-15 |
hsgw | 24:5281ea9f6e68 | 269 | * @param key 0-127 |
hsgw | 24:5281ea9f6e68 | 270 | * @param value 0-127 |
hsgw | 24:5281ea9f6e68 | 271 | * @return true if message sent successfully |
hsgw | 24:5281ea9f6e68 | 272 | */ |
hsgw | 24:5281ea9f6e68 | 273 | bool sendControlChange(uint8_t channel, uint8_t key, uint8_t value); |
hsgw | 24:5281ea9f6e68 | 274 | |
hsgw | 24:5281ea9f6e68 | 275 | /** |
hsgw | 24:5281ea9f6e68 | 276 | * Send a program change event |
hsgw | 24:5281ea9f6e68 | 277 | * |
hsgw | 24:5281ea9f6e68 | 278 | * @param channel 0-15 |
hsgw | 24:5281ea9f6e68 | 279 | * @param program 0-127 |
hsgw | 24:5281ea9f6e68 | 280 | * @return true if message sent successfully |
hsgw | 24:5281ea9f6e68 | 281 | */ |
hsgw | 24:5281ea9f6e68 | 282 | bool sendProgramChange(uint8_t channel, uint8_t program); |
hsgw | 24:5281ea9f6e68 | 283 | |
hsgw | 24:5281ea9f6e68 | 284 | /** |
hsgw | 24:5281ea9f6e68 | 285 | * Send a channel pressure event |
hsgw | 24:5281ea9f6e68 | 286 | * |
hsgw | 24:5281ea9f6e68 | 287 | * @param channel 0-15 |
hsgw | 24:5281ea9f6e68 | 288 | * @param pressure 0-127 |
hsgw | 24:5281ea9f6e68 | 289 | * @return true if message sent successfully |
hsgw | 24:5281ea9f6e68 | 290 | */ |
hsgw | 24:5281ea9f6e68 | 291 | bool sendChannelPressure(uint8_t channel, uint8_t pressure); |
hsgw | 24:5281ea9f6e68 | 292 | |
hsgw | 24:5281ea9f6e68 | 293 | /** |
hsgw | 24:5281ea9f6e68 | 294 | * Send a control change event |
hsgw | 24:5281ea9f6e68 | 295 | * |
hsgw | 24:5281ea9f6e68 | 296 | * @param channel 0-15 |
hsgw | 24:5281ea9f6e68 | 297 | * @param key 0(lower)-8191(center)-16383(higher) |
hsgw | 24:5281ea9f6e68 | 298 | * @return true if message sent successfully |
hsgw | 24:5281ea9f6e68 | 299 | */ |
hsgw | 24:5281ea9f6e68 | 300 | bool sendPitchBend(uint8_t channel, uint16_t value); |
hsgw | 24:5281ea9f6e68 | 301 | |
hsgw | 24:5281ea9f6e68 | 302 | /** |
hsgw | 24:5281ea9f6e68 | 303 | * Send a single byte event |
hsgw | 24:5281ea9f6e68 | 304 | * |
hsgw | 24:5281ea9f6e68 | 305 | * @param data 0-255 |
hsgw | 24:5281ea9f6e68 | 306 | * @return true if message sent successfully |
hsgw | 24:5281ea9f6e68 | 307 | */ |
hsgw | 24:5281ea9f6e68 | 308 | bool sendSingleByte(uint8_t data); |
hsgw | 24:5281ea9f6e68 | 309 | |
hsgw | 24:5281ea9f6e68 | 310 | protected: |
hsgw | 24:5281ea9f6e68 | 311 | //From IUSBEnumerator |
hsgw | 24:5281ea9f6e68 | 312 | virtual void setVidPid(uint16_t vid, uint16_t pid); |
hsgw | 24:5281ea9f6e68 | 313 | 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 |
hsgw | 24:5281ea9f6e68 | 314 | virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used |
hsgw | 24:5281ea9f6e68 | 315 | |
hsgw | 24:5281ea9f6e68 | 316 | private: |
hsgw | 24:5281ea9f6e68 | 317 | USBHost * host; |
hsgw | 24:5281ea9f6e68 | 318 | USBDeviceConnected * dev; |
hsgw | 24:5281ea9f6e68 | 319 | USBEndpoint * bulk_in; |
hsgw | 24:5281ea9f6e68 | 320 | USBEndpoint * bulk_out; |
hsgw | 24:5281ea9f6e68 | 321 | uint32_t size_bulk_in; |
hsgw | 24:5281ea9f6e68 | 322 | uint32_t size_bulk_out; |
hsgw | 24:5281ea9f6e68 | 323 | |
hsgw | 24:5281ea9f6e68 | 324 | bool dev_connected; |
hsgw | 24:5281ea9f6e68 | 325 | |
hsgw | 24:5281ea9f6e68 | 326 | void init(); |
hsgw | 24:5281ea9f6e68 | 327 | |
hsgw | 24:5281ea9f6e68 | 328 | uint8_t buf[64]; |
hsgw | 24:5281ea9f6e68 | 329 | |
hsgw | 24:5281ea9f6e68 | 330 | void rxHandler(); |
hsgw | 24:5281ea9f6e68 | 331 | |
hsgw | 24:5281ea9f6e68 | 332 | uint16_t sysExBufferPos; |
hsgw | 24:5281ea9f6e68 | 333 | uint8_t sysExBuffer[64]; |
hsgw | 24:5281ea9f6e68 | 334 | |
hsgw | 24:5281ea9f6e68 | 335 | void (*miscellaneousFunctionCode)(uint8_t, uint8_t, uint8_t); |
hsgw | 24:5281ea9f6e68 | 336 | void (*cableEvent)(uint8_t, uint8_t, uint8_t); |
hsgw | 24:5281ea9f6e68 | 337 | void (*systemCommonTwoBytes)(uint8_t, uint8_t); |
hsgw | 24:5281ea9f6e68 | 338 | void (*systemCommonThreeBytes)(uint8_t, uint8_t, uint8_t); |
hsgw | 24:5281ea9f6e68 | 339 | void (*systemExclusive)(uint8_t *, uint16_t, bool); |
hsgw | 24:5281ea9f6e68 | 340 | void (*noteOff)(uint8_t, uint8_t, uint8_t); |
hsgw | 24:5281ea9f6e68 | 341 | void (*noteOn)(uint8_t, uint8_t, uint8_t); |
hsgw | 24:5281ea9f6e68 | 342 | void (*polyKeyPress)(uint8_t, uint8_t, uint8_t); |
hsgw | 24:5281ea9f6e68 | 343 | void (*controlChange)(uint8_t, uint8_t, uint8_t); |
hsgw | 24:5281ea9f6e68 | 344 | void (*programChange)(uint8_t, uint8_t); |
hsgw | 24:5281ea9f6e68 | 345 | void (*channelPressure)(uint8_t, uint8_t); |
hsgw | 24:5281ea9f6e68 | 346 | void (*pitchBend)(uint8_t, uint16_t); |
hsgw | 24:5281ea9f6e68 | 347 | void (*singleByte)(uint8_t); |
hsgw | 24:5281ea9f6e68 | 348 | |
hsgw | 24:5281ea9f6e68 | 349 | bool sendMidiBuffer(uint8_t data0, uint8_t data1, uint8_t data2, uint8_t data3); |
hsgw | 24:5281ea9f6e68 | 350 | |
hsgw | 24:5281ea9f6e68 | 351 | int midi_intf; |
hsgw | 24:5281ea9f6e68 | 352 | bool midi_device_found; |
hsgw | 24:5281ea9f6e68 | 353 | |
hsgw | 24:5281ea9f6e68 | 354 | }; |
hsgw | 24:5281ea9f6e68 | 355 | |
hsgw | 24:5281ea9f6e68 | 356 | #endif |
hsgw | 24:5281ea9f6e68 | 357 | |
hsgw | 24:5281ea9f6e68 | 358 | #endif |