This is early stages of my project, the idea of this project is to be able to mix a guitar with windows sounds in reverse such as instrumental background music or trance music perhaps or maybe another fellow guitarist you may have downloaded from the internet. Microphone or guitar pin is p19 I would use a microphone for drums:) and that it for the moment, the code makes the mbed act as usb speaker that excepts a guitar or microphone input, but with a twist it all in reverse like a guitar reverse effects pedal but only you can mix anything you can get from the internet or any windows sound.
USBDevice/USBMIDI/USBMIDI.h@0:7610d342c76e, 2012-01-08 (annotated)
- Committer:
- mbed2f
- Date:
- Sun Jan 08 17:28:24 2012 +0000
- Revision:
- 0:7610d342c76e
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed2f | 0:7610d342c76e | 1 | /* Copyright (c) 2010-2011 mbed.org, MIT License |
mbed2f | 0:7610d342c76e | 2 | * |
mbed2f | 0:7610d342c76e | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
mbed2f | 0:7610d342c76e | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
mbed2f | 0:7610d342c76e | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
mbed2f | 0:7610d342c76e | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
mbed2f | 0:7610d342c76e | 7 | * Software is furnished to do so, subject to the following conditions: |
mbed2f | 0:7610d342c76e | 8 | * |
mbed2f | 0:7610d342c76e | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
mbed2f | 0:7610d342c76e | 10 | * substantial portions of the Software. |
mbed2f | 0:7610d342c76e | 11 | * |
mbed2f | 0:7610d342c76e | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
mbed2f | 0:7610d342c76e | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
mbed2f | 0:7610d342c76e | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
mbed2f | 0:7610d342c76e | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
mbed2f | 0:7610d342c76e | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
mbed2f | 0:7610d342c76e | 17 | */ |
mbed2f | 0:7610d342c76e | 18 | |
mbed2f | 0:7610d342c76e | 19 | #ifndef USBMIDI_H |
mbed2f | 0:7610d342c76e | 20 | #define USBMIDI_H |
mbed2f | 0:7610d342c76e | 21 | |
mbed2f | 0:7610d342c76e | 22 | /* These headers are included for child class. */ |
mbed2f | 0:7610d342c76e | 23 | #include "USBEndpoints.h" |
mbed2f | 0:7610d342c76e | 24 | #include "USBDescriptor.h" |
mbed2f | 0:7610d342c76e | 25 | #include "USBDevice_Types.h" |
mbed2f | 0:7610d342c76e | 26 | |
mbed2f | 0:7610d342c76e | 27 | #include "USBDevice.h" |
mbed2f | 0:7610d342c76e | 28 | #include "MIDIMessage.h" |
mbed2f | 0:7610d342c76e | 29 | |
mbed2f | 0:7610d342c76e | 30 | #define DEFAULT_CONFIGURATION (1) |
mbed2f | 0:7610d342c76e | 31 | |
mbed2f | 0:7610d342c76e | 32 | /** |
mbed2f | 0:7610d342c76e | 33 | * USBMIDI example |
mbed2f | 0:7610d342c76e | 34 | * |
mbed2f | 0:7610d342c76e | 35 | * @code |
mbed2f | 0:7610d342c76e | 36 | * #include "mbed.h" |
mbed2f | 0:7610d342c76e | 37 | * #include "USBMIDI.h" |
mbed2f | 0:7610d342c76e | 38 | * |
mbed2f | 0:7610d342c76e | 39 | * USBMIDI midi; |
mbed2f | 0:7610d342c76e | 40 | * |
mbed2f | 0:7610d342c76e | 41 | * int main() { |
mbed2f | 0:7610d342c76e | 42 | * while (1) { |
mbed2f | 0:7610d342c76e | 43 | * for(int i=48; i<83; i++) { // send some messages! |
mbed2f | 0:7610d342c76e | 44 | * midi.write(MIDIMessage::NoteOn(i)); |
mbed2f | 0:7610d342c76e | 45 | * wait(0.25); |
mbed2f | 0:7610d342c76e | 46 | * midi.write(MIDIMessage::NoteOff(i)); |
mbed2f | 0:7610d342c76e | 47 | * wait(0.5); |
mbed2f | 0:7610d342c76e | 48 | * } |
mbed2f | 0:7610d342c76e | 49 | * } |
mbed2f | 0:7610d342c76e | 50 | * } |
mbed2f | 0:7610d342c76e | 51 | * @endcode |
mbed2f | 0:7610d342c76e | 52 | */ |
mbed2f | 0:7610d342c76e | 53 | class USBMIDI: public USBDevice { |
mbed2f | 0:7610d342c76e | 54 | public: |
mbed2f | 0:7610d342c76e | 55 | |
mbed2f | 0:7610d342c76e | 56 | /** |
mbed2f | 0:7610d342c76e | 57 | * Constructor |
mbed2f | 0:7610d342c76e | 58 | * |
mbed2f | 0:7610d342c76e | 59 | * @param vendor_id Your vendor_id |
mbed2f | 0:7610d342c76e | 60 | * @param product_id Your product_id |
mbed2f | 0:7610d342c76e | 61 | * @param product_release Your preoduct_release |
mbed2f | 0:7610d342c76e | 62 | */ |
mbed2f | 0:7610d342c76e | 63 | USBMIDI(uint16_t vendor_id = 0x0700, uint16_t product_id = 0x0101, uint16_t product_release = 0x0001); |
mbed2f | 0:7610d342c76e | 64 | |
mbed2f | 0:7610d342c76e | 65 | /** |
mbed2f | 0:7610d342c76e | 66 | * Send a MIDIMessage |
mbed2f | 0:7610d342c76e | 67 | * |
mbed2f | 0:7610d342c76e | 68 | * @param m The MIDIMessage to send |
mbed2f | 0:7610d342c76e | 69 | */ |
mbed2f | 0:7610d342c76e | 70 | void write(MIDIMessage m); |
mbed2f | 0:7610d342c76e | 71 | |
mbed2f | 0:7610d342c76e | 72 | /** |
mbed2f | 0:7610d342c76e | 73 | * Attach a callback for when a MIDIEvent is received |
mbed2f | 0:7610d342c76e | 74 | * |
mbed2f | 0:7610d342c76e | 75 | * @param fptr function pointer |
mbed2f | 0:7610d342c76e | 76 | */ |
mbed2f | 0:7610d342c76e | 77 | void attach(void (*fptr)(MIDIMessage)); |
mbed2f | 0:7610d342c76e | 78 | |
mbed2f | 0:7610d342c76e | 79 | |
mbed2f | 0:7610d342c76e | 80 | protected: |
mbed2f | 0:7610d342c76e | 81 | virtual bool EP2_OUT_callback(); |
mbed2f | 0:7610d342c76e | 82 | virtual bool USBCallback_setConfiguration(uint8_t configuration); |
mbed2f | 0:7610d342c76e | 83 | /* |
mbed2f | 0:7610d342c76e | 84 | * Get string product descriptor |
mbed2f | 0:7610d342c76e | 85 | * |
mbed2f | 0:7610d342c76e | 86 | * @returns pointer to the string product descriptor |
mbed2f | 0:7610d342c76e | 87 | */ |
mbed2f | 0:7610d342c76e | 88 | virtual uint8_t * stringIproductDesc(); |
mbed2f | 0:7610d342c76e | 89 | |
mbed2f | 0:7610d342c76e | 90 | /* |
mbed2f | 0:7610d342c76e | 91 | * Get string interface descriptor |
mbed2f | 0:7610d342c76e | 92 | * |
mbed2f | 0:7610d342c76e | 93 | * @returns pointer to the string interface descriptor |
mbed2f | 0:7610d342c76e | 94 | */ |
mbed2f | 0:7610d342c76e | 95 | virtual uint8_t * stringIinterfaceDesc(); |
mbed2f | 0:7610d342c76e | 96 | |
mbed2f | 0:7610d342c76e | 97 | /* |
mbed2f | 0:7610d342c76e | 98 | * Get configuration descriptor |
mbed2f | 0:7610d342c76e | 99 | * |
mbed2f | 0:7610d342c76e | 100 | * @returns pointer to the configuration descriptor |
mbed2f | 0:7610d342c76e | 101 | */ |
mbed2f | 0:7610d342c76e | 102 | virtual uint8_t * configurationDesc(); |
mbed2f | 0:7610d342c76e | 103 | |
mbed2f | 0:7610d342c76e | 104 | private: |
mbed2f | 0:7610d342c76e | 105 | void (*midi_evt)(MIDIMessage); |
mbed2f | 0:7610d342c76e | 106 | |
mbed2f | 0:7610d342c76e | 107 | }; |
mbed2f | 0:7610d342c76e | 108 | |
mbed2f | 0:7610d342c76e | 109 | #endif |
mbed2f | 0:7610d342c76e | 110 |