Samuel Mokrani
/
USBAudio_HelloWorld
USBAudio Hello World
Diff: main.cpp
- Revision:
- 0:3a00949fdb07
- Child:
- 1:d712dff4f9ca
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Nov 30 09:49:14 2011 +0000 @@ -0,0 +1,34 @@ +// 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"); + } +}