Configuration for USB Audio (inherits sample_rate / channels / bits_per_sample from AudioInfo).
More...
#include <USBAudioConfig.h>
Configuration for USB Audio (inherits sample_rate / channels / bits_per_sample from AudioInfo).
◆ clear()
◆ copyFrom()
◆ equals()
Returns true if alt values are the same like the current values.
◆ equalsExSampleRate()
Checks if only the sample rate is different.
◆ logInfo()
| virtual void logInfo |
( |
const char * |
source = "" | ) |
|
|
inlinevirtualinherited |
◆ operator bool()
Returns true if all components are defined (no component is 0)
◆ operator!=() [1/2]
Returns true if alt values are the different from the current values.
◆ operator!=() [2/2]
◆ operator==() [1/2]
Returns true if alt values are the same like the current values.
◆ operator==() [2/2]
◆ set()
Copies the values from info.
◆ setAudioInfo()
◆ begin_usb
When true (default), beginUSB() calls USB.begin() automatically. Set to false for composite USB (e.g. Audio + CDC): register all interfaces first, then call USB.begin() yourself.
◆ bits_per_sample
Number of bits per sample (int16_t = 16 bits)
◆ channels
Number of channels: 2=stereo, 1=mono.
◆ enable_ep_in
device → host (capture / microphone)
◆ enable_ep_in_flow_control
| bool enable_ep_in_flow_control = true |
Enable UAC2 IN-endpoint flow control: vary the per-frame isochronous packet size so non-integer sample-per-frame rates are delivered at the exact average rate. Without it the device sends a fixed (rounded-up) packet every frame, which makes e.g. 44100 Hz run at 45000 Hz effective (45 samples/ms instead of the required 44.1 average).
◆ enable_ep_out
| bool enable_ep_out = true |
host → device (playback / speaker)
◆ enable_feedback_ep
| bool enable_feedback_ep = true |
Enable isochronous feedback endpoint so the host can adjust its clock.
◆ enable_interrupt_ep
| bool enable_interrupt_ep = false |
Enable the AC interrupt IN endpoint for device-initiated volume, mute, and sample-rate change notifications. Without it the host must poll via GET_CUR; the controls might still work, just without push updates.
◆ enable_multi_sample_rate
| bool enable_multi_sample_rate = false |
When false (default): the clock source is fixed at sample_rate. The descriptor reports an internal fixed clock, and GET_RANGE returns only the configured rate. This avoids complex host negotiation. When true: the clock source is programmable and GET_RANGE returns the discrete rates listed in supported_sample_rates below. The host can change the rate via SET_CUR, and the descriptor wMaxPacketSize covers the highest rate in that list.
◆ ep_fb
ISO IN (explicit feedback, RX-only mode)
◆ ep_in
ISO IN (device → host, capture/microphone)
Addresses must not conflict with other USB interfaces. On most platforms the -1 default (see USB_AUDIO_EP_* at the top of this file) lets the platform subclass allocate a free endpoint dynamically, which avoids conflicts automatically – including with CDC. Signed so a negative value (the -1 default on platforms without a fixed hardware endpoint) can be told apart from a real address: the platform subclass treats < 0 as "allocate dynamically" and any value you set >= 0 as a pinned address.
◆ ep_int
INT IN (AC status/change notifications)
◆ ep_out
ISO OUT (host → device, playback/speaker)
◆ fifo_packets
| uint8_t fifo_packets = 32 |
Depth of the audio FIFO expressed as a number of 1 ms packets. Larger values reduce the risk of underrun/overrun at the cost of latency. 32 packets (~32 ms at 44.1 kHz stereo 16-bit, ~6 kB RAM) is the minimum reliable value for RP2040 at 133 MHz: the I2S DMA write can block for 2-3 ms, and 16 packets leave no margin for those stalls.
◆ itf_num_ac
Interface number of the Audio Control interface. Increment when other USB functions (CDC, HID …) occupy lower numbers.
◆ manufacturer
| const char* manufacturer = "Audio Tools" |
◆ max_power_ma
| uint8_t max_power_ma = 100 |
◆ pid
◆ product
| const char* product = "USB Audio" |
◆ sample_rate
◆ self_powered
◆ serial
| const char* serial = "000001" |
◆ supported_sample_rates
| std::vector<uint32_t> supported_sample_rates |
Initial value:= {8000, 11025, 16000, 22050,
24000, 32000, 44100, 48000}
Discrete sample rates advertised in the Clock Source GET_RANGE response when enable_multi_sample_rate is true (ignored otherwise). Isochronous packet/buffer sizing for multi-rate mode is based on the LAST entry, so keep this sorted ascending – the host will never actually select a rate the GET_RANGE response didn't offer, so sizing for anything past the last entry would just waste buffer/FIFO space (and on MCUs with small USB FIFO RAM, such as ESP32-S2/S3's DWC2 peripheral, packets sized for an unreachably high rate can exceed the endpoint's available FIFO capacity entirely, silently breaking isochronous reception even though endpoint allocation and transfer arming both report success). Override before begin() to advertise a different set, e.g. just {44100, 48000}.
◆ terminal_id
Terminal ID reported to Zephyr usbd_uac2 callbacks (ignored on TinyUSB). TX_MODE: Output Terminal ID (device → host, ISO IN). RX_MODE: Input Terminal ID (host → device, ISO OUT). Must match the UAC2 node topology in the board device tree.
◆ vid
◆ volume_active
| bool volume_active = false |
When true we will process the volume and mute settings in the audio stream. When false we will not process the volume and mute settings but just provide the data for external processing.
The documentation for this struct was generated from the following file: