Samuel Mokrani
/
USBAudio_HelloWorld
USBAudio Hello World
main.cpp
- Committer:
- samux
- Date:
- 2011-11-30
- Revision:
- 0:3a00949fdb07
- Child:
- 1:d712dff4f9ca
File content as of revision 0:3a00949fdb07:
// Hello World example for the USBAudio library #include "mbed.h" #include "USBAudio.h" Serial pc(USBTX, USBRX); // frequency: 48 kHz #define FREQ 48000 // 1 channel: mono #define NB_CHA 1 // length of an audio packet: each ms, we receive 48 * 16bits ->48 * 2 bytes. as there is one channel, the length will be 48 * 2 * 1 #define LENGTH_PACKET 48 * 2 * 1 // USBAudio USBAudio audio(FREQ, NB_CHA); int main() { uint8_t buf[LENGTH_PACKET]; while (1) { // read an audio packet audio.read(buf); // print packet received pc.printf("recv: "); for(int i = 0; i < LENGTH_PACKET; i++) { pc.printf("%d ", buf[i]); } pc.printf("\r\n"); } }