|
arduino-audio-tools
|
Configuration for USB Audio (inherits sample_rate / channels / bits_per_sample from AudioInfo). More...
#include <USBAudioConfig.h>
Public Member Functions | |
| virtual void | clear () |
| void | copyFrom (AudioInfo info) |
| Same as set. | |
| bool | equals (AudioInfo alt) |
| Returns true if alt values are the same like the current values. | |
| bool | equalsExSampleRate (AudioInfo alt) |
| Checks if only the sample rate is different. | |
| virtual void | logInfo (const char *source="") |
| operator bool () | |
| Returns true if all components are defined (no component is 0) | |
| bool | operator!= (AudioInfo alt) |
| Returns true if alt values are the different from the current values. | |
| bool | operator!= (const USBAudioConfig &other) |
| bool | operator== (AudioInfo alt) |
| Returns true if alt values are the same like the current values. | |
| bool | operator== (const USBAudioConfig &other) |
| void | set (AudioInfo info) |
| Copies the values from info. | |
| void | setAudioInfo (AudioInfo info) |
| Same as set. | |
Public Attributes | |
| bool | begin_usb = false |
| uint8_t | bits_per_sample = DEFAULT_BITS_PER_SAMPLE |
| Number of bits per sample (int16_t = 16 bits) | |
| uint16_t | channels = DEFAULT_CHANNELS |
| Number of channels: 2=stereo, 1=mono. | |
| bool | enable_ep_in = true |
| device → host (capture / microphone) | |
| bool | enable_ep_in_flow_control = true |
| bool | enable_ep_out = true |
| host → device (playback / speaker) | |
| bool | enable_feedback_ep = true |
| Enable isochronous feedback endpoint so the host can adjust its clock. | |
| bool | enable_interrupt_ep = false |
| bool | enable_multi_sample_rate = false |
| uint8_t | ep_fb = 0x84 |
| ISO IN (explicit feedback, RX-only mode) | |
| uint8_t | ep_in = 0x83 |
| ISO IN (device → host, capture/microphone) | |
| uint8_t | ep_int = 0x85 |
| INT IN (AC status/change notifications) | |
| uint8_t | ep_out = 0x03 |
| ISO OUT (host → device, playback/speaker) | |
| uint8_t | fifo_packets = 16 |
| uint8_t | itf_num_ac = 0 |
| const char * | manufacturer = "Audio Tools" |
| uint8_t | max_power_ma = 100 |
| uint16_t | pid = 0x4002 |
| const char * | product = "USB Audio" |
| sample_rate_t | sample_rate = DEFAULT_SAMPLE_RATE |
| Sample Rate: e.g 44100. | |
| bool | self_powered = true |
| const char * | serial = "000001" |
| uint8_t | terminal_id = 1 |
| bool | use_linear_buffer_rx = true |
| bool | use_linear_buffer_tx = true |
| uint16_t | vid = 0xCafe |
| bool | volume_active = false |
Configuration for USB Audio (inherits sample_rate / channels / bits_per_sample from AudioInfo).
Returns true if alt values are the same like the current values.
Checks if only the sample rate is different.
Reimplemented in I2SConfigESP32, I2SConfigESP32V1, I2SConfigStd, and I2SConfigZephyr.
Returns true if alt values are the different from the current values.
|
inline |
Returns true if alt values are the same like the current values.
|
inline |
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.
|
inherited |
Number of bits per sample (int16_t = 16 bits)
|
inherited |
Number of channels: 2=stereo, 1=mono.
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 isochronous feedback endpoint so the host can adjust its clock.
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.
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 14 discrete rates (8 kHz – 192 kHz). The host can change the rate via SET_CUR, and the descriptor wMaxPacketSize covers 192 kHz.
| uint8_t ep_fb = 0x84 |
ISO IN (explicit feedback, RX-only mode)
| uint8_t ep_in = 0x83 |
ISO IN (device → host, capture/microphone)
Addresses must not conflict with other USB interfaces (e.g. CDC uses 0x81, 0x82, 0x02). The defaults below are safe for CDC + Audio composite devices.
| uint8_t ep_int = 0x85 |
INT IN (AC status/change notifications)
| uint8_t ep_out = 0x03 |
ISO OUT (host → device, playback/speaker)
| uint8_t fifo_packets = 16 |
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.
| uint8_t itf_num_ac = 0 |
Interface number of the Audio Control interface. Increment when other USB functions (CDC, HID …) occupy lower numbers.
| uint8_t max_power_ma = 100 |
| uint16_t pid = 0x4002 |
|
inherited |
Sample Rate: e.g 44100.
| uint8_t terminal_id = 1 |
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.
Use a flat contiguous buffer for RX instead of a circular FIFO. Required when the downstream audio driver uses DMA.
Use a flat contiguous buffer for TX instead of a circular FIFO. Required when the upstream audio driver uses DMA.
| uint16_t vid = 0xCafe |
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.