examples/device/audio_4_channel_mic/README.md
A USB Audio Class 2.0 (UAC2) microphone that streams four channels of locally generated test audio to the host.
| Interface | Class driver |
|---|---|
| 0–1 | UAC2 audio (control + streaming), 4-channel microphone input |
Notable tusb_config.h settings:
#define CFG_TUD_AUDIO 1
#define CFG_TUD_AUDIO_FUNC_1_SAMPLE_RATE 48000
#define CFG_TUD_AUDIO_ENABLE_EP_IN 1
#define CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX 4
#define CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX 2 // 16-bit
#define CFG_TUD_AUDIO_EP_IN_FLOW_CONTROL 1
#define CFG_TUD_AUDIO_EP_SZ_IN TUD_AUDIO_EP_SIZE(TUD_OPT_HIGH_SPEED, CFG_TUD_AUDIO_FUNC_1_SAMPLE_RATE, CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX, CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX)
#define CFG_TUD_AUDIO_FUNC_1_EP_IN_SZ_MAX CFG_TUD_AUDIO_EP_SZ_IN
CMake:
mkdir build && cd build
cmake -DBOARD=raspberry_pi_pico ..
cmake --build .
Make:
make BOARD=raspberry_pi_pico all
A FreeRTOS build is in examples/device/audio_4_channel_mic_freertos — identical UAC2 4-channel microphone, with the device, audio (1 ms IN-endpoint writes), and LED-blink work split across FreeRTOS tasks.
The device appears as a USB microphone with four channels. On Linux, list it with arecord -l and capture with arecord (for example arecord -D hw:CARD=MicNode4Ch -c 4 -f S16_LE -r 48000 test.wav). The included src/plot_audio_samples.py records and plots the generated waveforms (requires sounddevice and matplotlib).