Streams USB audio with sound effects applied. Sound effect selected by joystick and intensity altered by tilting the mbed. Output to the mbed-application-board phono jack.
Dependencies: C12832_lcd MMA7660 USBDevice mbed
/* Uses the mbed LPC1768 and mbed-application-board to create a USB audio device * that streams audio from a host computer to headphones or powered speakers. * A couple different sound effects can be applied to the stream in real-time, * and tilting the mbed alters intensity of the effect. * * ECHO * The joystick selects ) | * one of three effect ) STRAIGHT - o - STRAIGHT * modes. ) | * REVERB * * * * \\ || * Tilting the mbed ) ====== \\ || * determines intensity ) \\ || * of the effect. ) * 0% 50% 100% * * The LCD display shows the current effect mode, intesity and buffer level. */
buffer.h@0:bbf6cf0eab95, 2014-03-27 (annotated)
- Committer:
- bw
- Date:
- Thu Mar 27 21:27:04 2014 +0000
- Revision:
- 0:bbf6cf0eab95
Initial.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bw | 0:bbf6cf0eab95 | 1 | /******************************************************************************* |
bw | 0:bbf6cf0eab95 | 2 | * Implements FIFO buffer for glitch-free audio playback. |
bw | 0:bbf6cf0eab95 | 3 | * Bryan Wade |
bw | 0:bbf6cf0eab95 | 4 | * 27 MAR 2014 |
bw | 0:bbf6cf0eab95 | 5 | ******************************************************************************/ |
bw | 0:bbf6cf0eab95 | 6 | #ifndef BUFFER_H |
bw | 0:bbf6cf0eab95 | 7 | #define BUFFER_H |
bw | 0:bbf6cf0eab95 | 8 | |
bw | 0:bbf6cf0eab95 | 9 | #include <stdint.h> |
bw | 0:bbf6cf0eab95 | 10 | #include <stdlib.h> |
bw | 0:bbf6cf0eab95 | 11 | |
bw | 0:bbf6cf0eab95 | 12 | typedef struct buffer_t buffer_t; // Opaque type declaration. |
bw | 0:bbf6cf0eab95 | 13 | |
bw | 0:bbf6cf0eab95 | 14 | // Get a ptr to a new buffer. |
bw | 0:bbf6cf0eab95 | 15 | buffer_t *Buffer_Create(void *ram, size_t size); |
bw | 0:bbf6cf0eab95 | 16 | |
bw | 0:bbf6cf0eab95 | 17 | // Read one sample from buffer. |
bw | 0:bbf6cf0eab95 | 18 | bool Buffer_Read(buffer_t *buffer, int16_t *pDataOut); |
bw | 0:bbf6cf0eab95 | 19 | |
bw | 0:bbf6cf0eab95 | 20 | // Write one sample to buffer. |
bw | 0:bbf6cf0eab95 | 21 | void Buffer_Write(buffer_t *buffer, int16_t DataIn); |
bw | 0:bbf6cf0eab95 | 22 | |
bw | 0:bbf6cf0eab95 | 23 | // Write a block of data to buffer. |
bw | 0:bbf6cf0eab95 | 24 | void Buffer_WriteBlock(buffer_t *buffer, const int16_t *pDataIn, uint32_t length); |
bw | 0:bbf6cf0eab95 | 25 | |
bw | 0:bbf6cf0eab95 | 26 | // Get the current number of samples buffered. |
bw | 0:bbf6cf0eab95 | 27 | int32_t Buffer_GetLevel(buffer_t *buffer); |
bw | 0:bbf6cf0eab95 | 28 | |
bw | 0:bbf6cf0eab95 | 29 | #endif |