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.

Dependencies:   mbed

Committer:
mbed2f
Date:
Sun Jan 08 17:28:24 2012 +0000
Revision:
0:7610d342c76e

        

Who changed what in which revision?

UserRevisionLine numberNew 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 USBSERIAL_H
mbed2f 0:7610d342c76e 20 #define USBSERIAL_H
mbed2f 0:7610d342c76e 21
mbed2f 0:7610d342c76e 22 #include "USBCDC.h"
mbed2f 0:7610d342c76e 23 #include "Stream.h"
mbed2f 0:7610d342c76e 24 #include "CircBuffer.h"
mbed2f 0:7610d342c76e 25
mbed2f 0:7610d342c76e 26
mbed2f 0:7610d342c76e 27 /**
mbed2f 0:7610d342c76e 28 * USBSerial example
mbed2f 0:7610d342c76e 29 *
mbed2f 0:7610d342c76e 30 * @code
mbed2f 0:7610d342c76e 31 * #include "mbed.h"
mbed2f 0:7610d342c76e 32 * #include "USBSerial.h"
mbed2f 0:7610d342c76e 33 *
mbed2f 0:7610d342c76e 34 * //Virtual serial port over USB
mbed2f 0:7610d342c76e 35 * USBSerial serial;
mbed2f 0:7610d342c76e 36 *
mbed2f 0:7610d342c76e 37 * int main(void) {
mbed2f 0:7610d342c76e 38 *
mbed2f 0:7610d342c76e 39 * while(1)
mbed2f 0:7610d342c76e 40 * {
mbed2f 0:7610d342c76e 41 * serial.printf("I am a virtual serial port\n");
mbed2f 0:7610d342c76e 42 * wait(1);
mbed2f 0:7610d342c76e 43 * }
mbed2f 0:7610d342c76e 44 * }
mbed2f 0:7610d342c76e 45 * @endcode
mbed2f 0:7610d342c76e 46 */
mbed2f 0:7610d342c76e 47 class USBSerial: public USBCDC, public Stream {
mbed2f 0:7610d342c76e 48 public:
mbed2f 0:7610d342c76e 49
mbed2f 0:7610d342c76e 50 /**
mbed2f 0:7610d342c76e 51 * Constructor
mbed2f 0:7610d342c76e 52 *
mbed2f 0:7610d342c76e 53 * @param vendor_id Your vendor_id (default: 0x1f00)
mbed2f 0:7610d342c76e 54 * @param product_id Your product_id (default: 0x2012)
mbed2f 0:7610d342c76e 55 * @param product_release Your preoduct_release (default: 0x0001)
mbed2f 0:7610d342c76e 56 *
mbed2f 0:7610d342c76e 57 */
mbed2f 0:7610d342c76e 58 USBSerial(uint16_t vendor_id = 0x1f00, uint16_t product_id = 0x2012, uint16_t product_release = 0x0001): USBCDC(vendor_id, product_id, product_release), buf(128){ };
mbed2f 0:7610d342c76e 59
mbed2f 0:7610d342c76e 60
mbed2f 0:7610d342c76e 61 /**
mbed2f 0:7610d342c76e 62 * Send a character. You can use puts, printf.
mbed2f 0:7610d342c76e 63 *
mbed2f 0:7610d342c76e 64 * @param c character to be sent
mbed2f 0:7610d342c76e 65 * @returns true if there is no error, false otherwise
mbed2f 0:7610d342c76e 66 */
mbed2f 0:7610d342c76e 67 virtual int _putc(int c);
mbed2f 0:7610d342c76e 68
mbed2f 0:7610d342c76e 69 /**
mbed2f 0:7610d342c76e 70 * Read a character: blocking
mbed2f 0:7610d342c76e 71 *
mbed2f 0:7610d342c76e 72 * @returns character read
mbed2f 0:7610d342c76e 73 */
mbed2f 0:7610d342c76e 74 virtual int _getc();
mbed2f 0:7610d342c76e 75
mbed2f 0:7610d342c76e 76 /**
mbed2f 0:7610d342c76e 77 * Check the number of bytes available.
mbed2f 0:7610d342c76e 78 *
mbed2f 0:7610d342c76e 79 * @returns the number of bytes available
mbed2f 0:7610d342c76e 80 */
mbed2f 0:7610d342c76e 81 uint8_t available();
mbed2f 0:7610d342c76e 82
mbed2f 0:7610d342c76e 83 /**
mbed2f 0:7610d342c76e 84 * Write a block of data.
mbed2f 0:7610d342c76e 85 *
mbed2f 0:7610d342c76e 86 * For more efficiency, a block of size 64 (maximum size of a bulk endpoint) has to be written.
mbed2f 0:7610d342c76e 87 *
mbed2f 0:7610d342c76e 88 * @param buf pointer on data which will be written
mbed2f 0:7610d342c76e 89 * @param size size of the buffer. The maximum size of a block is limited by the size of the endpoint (64 bytes)
mbed2f 0:7610d342c76e 90 *
mbed2f 0:7610d342c76e 91 * @returns true if successfull
mbed2f 0:7610d342c76e 92 */
mbed2f 0:7610d342c76e 93 bool writeBlock(uint8_t * buf, uint16_t size);
mbed2f 0:7610d342c76e 94
mbed2f 0:7610d342c76e 95 /**
mbed2f 0:7610d342c76e 96 * Attach a member function to call when a packet is received.
mbed2f 0:7610d342c76e 97 *
mbed2f 0:7610d342c76e 98 * @param tptr pointer to the object to call the member function on
mbed2f 0:7610d342c76e 99 * @param mptr pointer to the member function to be called
mbed2f 0:7610d342c76e 100 */
mbed2f 0:7610d342c76e 101 template<typename T>
mbed2f 0:7610d342c76e 102 void attach(T* tptr, void (T::*mptr)(void)) {
mbed2f 0:7610d342c76e 103 if((mptr != NULL) && (tptr != NULL)) {
mbed2f 0:7610d342c76e 104 rx.attach(tptr, mptr);
mbed2f 0:7610d342c76e 105 }
mbed2f 0:7610d342c76e 106 }
mbed2f 0:7610d342c76e 107
mbed2f 0:7610d342c76e 108 /**
mbed2f 0:7610d342c76e 109 * Attach a callback called when a packet is received
mbed2f 0:7610d342c76e 110 *
mbed2f 0:7610d342c76e 111 * @param fptr function pointer
mbed2f 0:7610d342c76e 112 */
mbed2f 0:7610d342c76e 113 void attach(void (*fn)(void)) {
mbed2f 0:7610d342c76e 114 if(fn != NULL) {
mbed2f 0:7610d342c76e 115 rx.attach(fn);
mbed2f 0:7610d342c76e 116 }
mbed2f 0:7610d342c76e 117 }
mbed2f 0:7610d342c76e 118
mbed2f 0:7610d342c76e 119
mbed2f 0:7610d342c76e 120 protected:
mbed2f 0:7610d342c76e 121 virtual bool EP2_OUT_callback();
mbed2f 0:7610d342c76e 122
mbed2f 0:7610d342c76e 123 private:
mbed2f 0:7610d342c76e 124 FunctionPointer rx;
mbed2f 0:7610d342c76e 125 CircBuffer<uint8_t> buf;
mbed2f 0:7610d342c76e 126 };
mbed2f 0:7610d342c76e 127
mbed2f 0:7610d342c76e 128 #endif