arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
USBAudioConfig Struct Reference

Configuration for USB Audio (inherits sample_rate / channels / bits_per_sample from AudioInfo). More...

#include <USBAudioConfig.h>

Inheritance diagram for USBAudioConfig:
AudioInfo

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 charmanufacturer = "Audio Tools"
 
uint8_t max_power_ma = 100
 
uint16_t pid = 0x4002
 
const charproduct = "USB Audio"
 
sample_rate_t sample_rate = DEFAULT_SAMPLE_RATE
 Sample Rate: e.g 44100.
 
bool self_powered = true
 
const charserial = "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
 

Detailed Description

Configuration for USB Audio (inherits sample_rate / channels / bits_per_sample from AudioInfo).

Member Function Documentation

◆ clear()

virtual void clear ( )
inlinevirtualinherited

◆ copyFrom()

void copyFrom ( AudioInfo  info)
inlineinherited

Same as set.

◆ equals()

bool equals ( AudioInfo  alt)
inlineinherited

Returns true if alt values are the same like the current values.

◆ equalsExSampleRate()

bool equalsExSampleRate ( AudioInfo  alt)
inlineinherited

Checks if only the sample rate is different.

◆ logInfo()

virtual void logInfo ( const char source = "")
inlinevirtualinherited

◆ operator bool()

operator bool ( )
inlineinherited

Returns true if all components are defined (no component is 0)

◆ operator!=() [1/2]

bool operator!= ( AudioInfo  alt)
inlineinherited

Returns true if alt values are the different from the current values.

◆ operator!=() [2/2]

bool operator!= ( const USBAudioConfig other)
inline

◆ operator==() [1/2]

bool operator== ( AudioInfo  alt)
inlineinherited

Returns true if alt values are the same like the current values.

◆ operator==() [2/2]

bool operator== ( const USBAudioConfig other)
inline

◆ set()

void set ( AudioInfo  info)
inlineinherited

Copies the values from info.

◆ setAudioInfo()

void setAudioInfo ( AudioInfo  info)
inlineinherited

Same as set.

Member Data Documentation

◆ begin_usb

bool begin_usb = false

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

uint8_t bits_per_sample = DEFAULT_BITS_PER_SAMPLE
inherited

Number of bits per sample (int16_t = 16 bits)

◆ channels

uint16_t channels = DEFAULT_CHANNELS
inherited

Number of channels: 2=stereo, 1=mono.

◆ enable_ep_in

bool enable_ep_in = true

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 14 discrete rates (8 kHz – 192 kHz). The host can change the rate via SET_CUR, and the descriptor wMaxPacketSize covers 192 kHz.

◆ ep_fb

uint8_t ep_fb = 0x84

ISO IN (explicit feedback, RX-only mode)

◆ ep_in

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.

◆ ep_int

uint8_t ep_int = 0x85

INT IN (AC status/change notifications)

◆ ep_out

uint8_t ep_out = 0x03

ISO OUT (host → device, playback/speaker)

◆ fifo_packets

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.

◆ itf_num_ac

uint8_t itf_num_ac = 0

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

uint16_t pid = 0x4002

◆ product

const char* product = "USB Audio"

◆ sample_rate

sample_rate_t sample_rate = DEFAULT_SAMPLE_RATE
inherited

Sample Rate: e.g 44100.

◆ self_powered

bool self_powered = true

◆ serial

const char* serial = "000001"

◆ terminal_id

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_linear_buffer_rx

bool use_linear_buffer_rx = true

Use a flat contiguous buffer for RX instead of a circular FIFO. Required when the downstream audio driver uses DMA.

◆ use_linear_buffer_tx

bool use_linear_buffer_tx = true

Use a flat contiguous buffer for TX instead of a circular FIFO. Required when the upstream audio driver uses DMA.

◆ vid

uint16_t vid = 0xCafe

◆ 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: