]>
git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/tests/usb/device/audio/main.cpp
1 // Playback example with the USBAUDIO library
14 // length computed: each ms, we receive 48 * 16bits ->48 * 2 bytes. as there are two channels, the length will be 48 * 2 * 2
15 #define LENGTH_AUDIO_PACKET_SPK (FREQ_SPK / 500) * NB_CHA_SPK
16 #define LENGTH_AUDIO_PACKET_MIC (FREQ_MIC / 500) * NB_CHA_MIC
19 USBAudio
audio(FREQ_SPK
, NB_CHA_SPK
, FREQ_MIC
, NB_CHA_MIC
, 0xab45, 0x0378);
23 int buf_in
[LENGTH_AUDIO_PACKET_SPK
/sizeof(int)];
24 int buf_out
[LENGTH_AUDIO_PACKET_MIC
/sizeof(int)];
25 int * stream_out
= buf_in
;
26 int * stream_in
= buf_out
;
30 // read and write one audio packet each frame
31 audio
.readWrite((uint8_t *)stream_in
, (uint8_t *)stream_out
);
35 stream_in
= stream_out
;