...
The audio class provides several structures that can be used to build an audio function topology. These structures relate to units, terminals and streams. They will be declared and initialized in usbd_audio_dev_cfg.h
and usbd_audio_dev_cfg.c
files. presents Table - User Configurable Structures for Creating Audio Function Topology presents all configurable structures and the associated function that will use the structure. Functions are described in Class Instance Configuration section.
Panel |
---|
borderWidth | 0 |
---|
title | Table - User Configurable Structures for Creating Audio Function Topology |
---|
|
|
Info |
---|
The use of these structures makes the audio function topology highly configurable. It allows to describe any type of audio topology. |
...
- Two Inputs terminals
- Two Ouput terminals
- Two Feature units
- Two AudioStreaming interfaces
gives Figure - usbd_audio_dev_cfg.c - Typical Topologies Example gives a visual representation of the possible topologies that can be built with the 6 terminals and units.
Anchor |
---|
| Figure - usbd_audio_dev_cfg.c - Typical Topologies Example |
---|
| Figure - usbd_audio_dev_cfg.c - Typical Topologies Example |
---|
|
Panel |
---|
borderWidth | 0 |
---|
title | Figure - usbd_audio_dec_cfg.c - Typical Topologies Example |
---|
|
Image Added |
Terminals
Info |
---|
All terminals must have a unique ID within a given audio function. The terminals ID assignment is handled by the audio class using the functions USBD_Audio_IT_Assoc and USBD_Audio_OT_Assoc . |
Input Terminal
presents Table - USBD_AUDIO_IT_CFG Structure Fields Description presents the Input terminal structure. Refer to audio 1.0 specification, section "4.3.2.1 Input Terminal Descriptor" for more details about certain fields.
Anchor |
---|
| Table - USBD_AUDIO_IT_CFG Structure Fields Description |
---|
| Table - USBD_AUDIO_IT_CFG Structure Fields Description |
---|
|
...
Panel |
---|
borderWidth | 0 |
---|
title | Table - USBD_AUDIO_IT_CFG Structure Fields Description |
---|
|
Field | Description | Example of value | Available Predefined Value |
---|
TerminalType | Terminal type. |
|
Output Terminal
USBD_AUDIO_TERMINAL_TYPE_MIC | There are many terminal type defined by Audio 1.0 Terminal Types specification. Thus, there are many predefined values available in usbd_audio.h . Some of them typical for IT are:
USBD_AUDIO_TERMINAL_TYPE_USB_STREAMING USBD_AUDIO_TERMINAL_TYPE_IT_UNDEFINED USBD_AUDIO_TERMINAL_TYPE_MIC USBD_AUDIO_TERMINAL_TYPE_DESKTOP_MIC USBD_AUDIO_TERMINAL_TYPE_OMNI_DIR_MIC USBD_AUDIO_TERMINAL_TYPE_PERSONAL_MIC USBD_AUDIO_TERMINAL_TYPE_MIC_ARRAY USBD_AUDIO_TERMINAL_TYPE_PROC_MIC_ARRAY Refer to usbd_audio.h for the complete list. | LogChNbr | Number of logical output channels in the terminal output. | USBD_AUDIO_MONO | USBD_AUDIO_MONO
USBD_AUDIO_STEREO
USBD_AUDIO_5_1
USBD_AUDIO_7_1 | LogChCfg | Spatial location of logical channel. | USBD_AUDIO_SPATIAL_LOCATION_LEFT_FRONT | A OR combination of:
USBD_AUDIO_SPATIAL_LOCATION_LEFT_FRONT
USBD_AUDIO_SPATIAL_LOCATION_RIGHT_FRONT
USBD_AUDIO_SPATIAL_LOCATION_CENTER_FRONT
USBD_AUDIO_SPATIAL_LOCATION_LFE
USBD_AUDIO_SPATIAL_LOCATION_LEFT_SURROUND
USBD_AUDIO_SPATIAL_LOCATION_RIGHT_SURROUND
USBD_AUDIO_SPATIAL_LOCATION_LEFT_CENTER
USBD_AUDIO_SPATIAL_LOCATION_RIGHT_CENTER
USBD_AUDIO_SPATIAL_LOCATION_SURROUND
USBD_AUDIO_SPATIAL_LOCATION_SIDE_LEFT
USBD_AUDIO_SPATIAL_LOCATION_SIDE_RIGHT
USBD_AUDIO_SPATIAL_LOCATION_TOP | CopyProtEn | Enables or disables Copy Protection. | DEF_DISABLED | DEF_DISABLED
DEF_ENABLED | CopyProtLevel | Copy Protection Level. | USBD_AUDIO_CPL_NONE | USBD_AUDIO_CPL_NONE
USBD_AUDIO_CPL0
USBD_AUDIO_CPL1
USBD_AUDIO_CPL2 | StrPtr | Pointer to a string describing the Input Terminal. | "IT Microphone" | - |
|
Output Terminal
Table - USBD_AUDIO_OT_CFG Structure Fields Description presents the Output terminal structure. Refer to audio 1.0 specification, section "4.3.2.2 Output Terminal Descriptor" for more details about certain fields.
Anchor |
---|
| Table - USBD_AUDIO_OT_CFG Structure Fields Description |
---|
| Table - USBD_AUDIO_OT_CFG Structure Fields Description |
---|
|
Panel |
---|
borderWidth | 0 |
---|
title | Table - USBD_AUDIO_OT_CFG Structure Fields Description |
---|
|
Field | Description | Example of value | Available Predefined Value |
---|
TerminalType | Terminal type. | USBD_AUDIO_TERMINAL_TYPE_USB_STREAMING | There are many terminal type defined by Audio 1.0 Terminal Types specification.
Thus, there are many predefined values available in usbd_audio.h . Some of them typical for OT are:
USBD_AUDIO_TERMINAL_TYPE_USB_STREAMING USBD_AUDIO_TERMINAL_TYPE_SPEAKER USBD_AUDIO_TERMINAL_TYPE_HEADPHONES USBD_AUDIO_TERMINAL_TYPE_HEAD_MOUNTED USBD_AUDIO_TERMINAL_TYPE_DESKTOP_SPEAKER USBD_AUDIO_TERMINAL_TYPE_ROOM_SPEAKER USBD_AUDIO_TERMINAL_TYPE_COMM_SPEAKER USBD_AUDIO_TERMINAL_TYPE_LOW_FREQ_SPEAKER
Refer to usbd_audio.h for the complete list. | SourceID | Unit or Terminal ID to which Terminal is connected to. | 7 | - | CopyProtEn | Enables or disables Copy Protection. | DEF_DISABLED | DEF_DISABLED
DEF_ENABLED | StrPtr | Pointer to a string describing the Output Terminal. | "OT Speaker" | - |
|
Units
Info |
---|
All units must have a unique ID within a given audio function. The units ID assignment is handled by the audio class using the functions USBD_Audio_FU_Assoc , USBD_Audio_MU_Assoc() and USBD_Audio_SU_Assoc. |
Feature Unit
presents Table - USBD_AUDIO_FU_CFG Structure Fields Description presents the Feature Unit structure. Refer to audio 1.0 specification, section "4.3.2.5 Feature Unit Descriptor" for more details about certain fields.
Anchor |
---|
| Table - USBD_AUDIO_FU_CFG Structure Fields Description |
---|
| Table - USBD_AUDIO_FU_CFG Structure Fields Description |
---|
|
Panel |
---|
borderWidth | 0 |
---|
title | Table - USBD_AUDIO_FU_CFG Structure Fields Description |
---|
|
Field | Description | Example of value | Available Predefined Value |
---|
LogChNbr | Number of logical channels. | USBD_AUDIO_STEREO | USBD_AUDIO_MONO
USBD_AUDIO_STEREO
USBD_AUDIO_5_1
USBD_AUDIO_7_1 | LogChCtrlPtr | Pointer to Feature Unit Controls table | &FU_LogChCtrlTbl[0u] | - | StrPtr | Pointer to a string describing the Feature Unit. | "FU Microphone" | - |
|
LogChCtrlPtr
points to a table of 16-bit unsigned integers. These integers are used as bitmaps to describe which Feature Unit controls are supported by a certain logical channel. Refer to for to Table - Units and Terminals Description, Controls and Requests for the complete list of Feature Unit controls. An audio stream encodes several logical channels forming a cluster. For instance, in a stereo stream, left and right channel are two logical channels. Each Feature Unit can apply a certain control to a specific logical channel or to all channels at once. The master channel is used to designate all channels. The code snippet below shows an example of Feature Unit controls table. The table index represents the logical channel number.
Anchor |
---|
| Listing - Example of Feature Unit Controls Configuration |
---|
| Listing - Example of Feature Unit Controls Configuration |
---|
|
Code Block |
---|
language | cpp |
---|
linenumbers | true |
---|
|
CPU_INT16U FU_LogChCtrlTbl[] = {
(USBD_AUDIO_FU_CTRL_MUTE | USBD_AUDIO_FU_CTRL_VOL), (1)
USBD_AUDIO_FU_CTRL_NONE, (2)
USBD_AUDIO_FU_CTRL_NONE (3)
}; |
Mixer Unit
...
Panel |
---|
|
(1) Controls supported by the master channel. In this example, mute and volume controls are supported. If the host sends a class-specific request to mute, muting will be applied on left and right channels at the same time. All the possible #define for Feature Unit controls are available in usbd_audio.h . (2) Controls supported by the logical channel #1, i.e. left channel. Here, USBD_AUDIO_FU_CTRL_NONE indicates that no controls are supported for the left channel. For example, the host cannot change the volume on the left channel only. It has to change it via the master channel. (3) Controls supported by the logical channel #2, i.e. right channel. As for the left channel, no controls are supported. |
Mixer Unit
Table - USBD_AUDIO_MU_CFG Structure Fields Description presents the Mixer Unit structure. Refer to audio 1.0 specification, section "4.3.2.3 Mixer Unit Descriptor" for more details about certain fields.
Anchor |
---|
| Table - USBD_AUDIO_MU_CFG Structure Fields Description |
---|
| Table - USBD_AUDIO_MU_CFG Structure Fields Description |
---|
|
Panel |
---|
borderWidth | 0 |
---|
title | Table - USBD_AUDIO_MU_CFG Structure Fields Description |
---|
|
Field | Description | Example of value | Available Predefined Value |
---|
NbrInPins | Number of Input Pins. | 3 | - | LogInChNbr | Number of logical input channels. | (3 * USBD_AUDIO_STEREO) | USBD_AUDIO_MONO
USBD_AUDIO_STEREO
USBD_AUDIO_5_1
USBD_AUDIO_7_1 | LogOutChNbr | Number of logical output channels. | USBD_AUDIO_STEREO | USBD_AUDIO_MONO
USBD_AUDIO_STEREO
USBD_AUDIO_5_1
USBD_AUDIO_7_1 | LogOutChCfg | Spatial location of logical output channels. | (USBD_AUDIO_SPATIAL_LOCATION_LEFT_FRONT |
USBD_AUDIO_SPATIAL_LOCATION_RIGHT_FRONT) | A OR combination of:
USBD_AUDIO_SPATIAL_LOCATION_LEFT_FRONT
USBD_AUDIO_SPATIAL_LOCATION_RIGHT_FRONT
USBD_AUDIO_SPATIAL_LOCATION_CENTER_FRONT
USBD_AUDIO_SPATIAL_LOCATION_LFE
USBD_AUDIO_SPATIAL_LOCATION_LEFT_SURROUND
USBD_AUDIO_SPATIAL_LOCATION_RIGHT_SURROUND
USBD_AUDIO_SPATIAL_LOCATION_LEFT_CENTER
USBD_AUDIO_SPATIAL_LOCATION_RIGHT_CENTER
USBD_AUDIO_SPATIAL_LOCATION_SURROUND
USBD_AUDIO_SPATIAL_LOCATION_SIDE_LEFT
USBD_AUDIO_SPATIAL_LOCATION_SIDE_RIGHT
USBD_AUDIO_SPATIAL_LOCATION_TOP | StrPtr | Pointer to a string describing the Mixer Unit. | "Mixer unit 11" | - |
|
The total number of logical input channels ( LogInChNbr
) is equal to the addition of all logical input channels that composes each input pin. For instance, if a Mixer Unit has 3 inputs pins with the following logical input channels characteristics:
...
Info |
---|
A Mixer Unit can have programmable and non-programmable mixing controls. If you need to set some programmable mixing controls, you need to use the function USBD_Audio_MU_MixingCtrlSet during the audio function initialization. |
Selector Unit
presents 106037317 presents the Selector Unit structure. Refer to audio 1.0 specification, section "4.3.2.4 Selector Unit Descriptor" for more details about certain fields.
Anchor |
---|
| Table - USBD_AUDIO_SU_CFG Structure Fields Description |
---|
| Table - USBD_AUDIO_SU_CFG Structure Fields Description |
---|
|
Panel |
---|
borderWidth | 0 |
---|
title | Table - USBD_AUDIO_SU_CFG Structure Fields Description |
---|
|
Field | Description | Example of value |
---|
NbrInPins | Number of Input Pins. | 2 | StrPtr | Pointer to a string describing the Selector Unit. | "Selector unit 12" |
|
Streams
General Stream Configuration
presents Table - USBD_AUDIO_STREAM_CFG Structure Fields Description presents the general stream configuration structure. .
Anchor |
---|
| Table - USBD_AUDIO_STREAM_CFG Structure Fields Description |
---|
| Table - USBD_AUDIO_STREAM_CFG Structure Fields Description |
---|
|
Panel |
---|
borderWidth | 0 |
---|
title | Table - USBD_AUDIO_STREAM_CFG Structure Fields Description |
---|
|
Field | Description | Example of value | Available Predefined Value |
---|
MaxBufNbr | Maximum number of buffers allocated for the given stream. | 40 | USBD_AUDIO_STREAM_NBR_BUF_6 USBD_AUDIO_STREAM_NBR_BUF_12 USBD_AUDIO_STREAM_NBR_BUF_18 USBD_AUDIO_STREAM_NBR_BUF_24 USBD_AUDIO_STREAM_NBR_BUF_30 USBD_AUDIO_STREAM_NBR_BUF_36 USBD_AUDIO_STREAM_NBR_BUF_42 | CorrPeriodMs | Period at which the built-in stream correction must be possibly applied. Expressed in milliseconds. For this field and the two followings, refer to section Stream Correction for more details about the built-in correction for playback and record streams. | 2 | - |
|
AudioStreaming Interface
presents 106037317 presents the AudioStreaming interface configuration structure. Each AudioStreaming interface has one unique associated isochronous endpoint. Hence, there is a one-to-one relation between an AudioStreaming interface and its associated endpoint.
Anchor |
---|
| Table - USBD_AUDIO_AS_ALT_CFG Structure Fields Description |
---|
| Table - USBD_AUDIO_AS_ALT_CFG Structure Fields Description |
---|
|
Panel |
---|
borderWidth | 0 |
---|
title | Table - USBD_AUDIO_AS_ALT_CFG Structure Fields Description |
---|
|
Field | Description | Example of value | Available Predefined Value |
---|
AudioStreaming Interface Information | Dly | The Delay holds a value that is a measure for the delay that is introduced in the audio data stream due to internal processing of the signal within the audio function. The delay unit is expressed in number of frames (i.e. in ms). Refer to 'USB Device Class Definition for Audio Devices, Release 1.0, March 18, 1998', section 4.5.2 for more details about class-specific AudioStreaming descriptor. | 1 | - | FmtTag | Audio data format supported by this interface. | USBD_AUDIO_DATA_FMT_TYPE_I_PCM | Only formats supported by Type I are possible:
USBD_AUDIO_DATA_FMT_TYPE_I_PCM
USBD_AUDIO_DATA_FMT_TYPE_I_PCM8
USBD_AUDIO_DATA_FMT_TYPE_I_IEEE_FLOAT
USBD_AUDIO_DATA_FMT_TYPE_I_ALAW
USBD_AUDIO_DATA_FMT_TYPE_I_MULAW | Type I Format Information. Refer to 'USB Device Class Definition for Audio Data Formats, Release 1.0, March 18, 1998', section '2.2.5 Type I Format Type Descriptor' for more details about the following fields. | NbrCh | Number of physical channels in the audio data stream. | USBD_AUDIO_STEREO | USBD_AUDIO_MONO
USBD_AUDIO_STEREO
USBD_AUDIO_5_1
USBD_AUDIO_7_1 | SubframeSize | Number of bytes occupied by one audio subframe. | USBD_AUDIO_FMT_TYPE_I_SUBFRAME_SIZE_2 | USBD_AUDIO_FMT_TYPE_I_SUBFRAME_SIZE_1
USBD_AUDIO_FMT_TYPE_I_SUBFRAME_SIZE_2
USBD_AUDIO_FMT_TYPE_I_SUBFRAME_SIZE_3
USBD_AUDIO_FMT_TYPE_I_SUBFRAME_SIZE_4 | BitRes | Effectively used bits in an audio subframe. | USBD_AUDIO_FMT_TYPE_I_BIT_RESOLUTION_16 | USBD_AUDIO_FMT_TYPE_I_BIT_RESOLUTION_8
USBD_AUDIO_FMT_TYPE_I_BIT_RESOLUTION_16
USBD_AUDIO_FMT_TYPE_I_BIT_RESOLUTION_24
USBD_AUDIO_FMT_TYPE_I_BIT_RESOLUTION_32 | NbrSamplingFreq | Number of discrete sampling frequencies. A value of 0 indicates a continuous sampling frequency range. A value between 1 and 255 indicates a certain number of discrete sampling frequencies supported by the isochronous data endpoint. | 2 | USBD_AUDIO_FMT_TYPE_I_SAM_FREQ_CONTINUOUS
or number of discrete sampling frequencies. | LowerSamplingFreq | Lower bound in Hz of the continuous sampling frequency range. Valid only for continuous sampling frequency. | 0 | USBD_AUDIO_FMT_TYPE_I_SAMFREQ_8KHZ
USBD_AUDIO_FMT_TYPE_I_SAMFREQ_11KHZ
USBD_AUDIO_FMT_TYPE_I_SAMFREQ_16KHZ
USBD_AUDIO_FMT_TYPE_I_SAMFREQ_22KHZ
USBD_AUDIO_FMT_TYPE_I_SAMFREQ_32KHZ
USBD_AUDIO_FMT_TYPE_I_SAMFREQ_44_1KHZ
USBD_AUDIO_FMT_TYPE_I_SAMFREQ_48KHZ
USBD_AUDIO_FMT_TYPE_I_SAMFREQ_88_2KHZ
USBD_AUDIO_FMT_TYPE_I_SAMFREQ_96KHZ | UpperSamplingFreq | Upper bound in Hz of the continuous sampling frequency range. Valid only for continuous sampling frequency. | 0 | USBD_AUDIO_FMT_TYPE_I_SAMFREQ_8KHZ
USBD_AUDIO_FMT_TYPE_I_SAMFREQ_11KHZ
USBD_AUDIO_FMT_TYPE_I_SAMFREQ_16KHZ
USBD_AUDIO_FMT_TYPE_I_SAMFREQ_22KHZ
USBD_AUDIO_FMT_TYPE_I_SAMFREQ_32KHZ
USBD_AUDIO_FMT_TYPE_I_SAMFREQ_44_1KHZ
USBD_AUDIO_FMT_TYPE_I_SAMFREQ_48KHZ
USBD_AUDIO_FMT_TYPE_I_SAMFREQ_88_2KHZ
USBD_AUDIO_FMT_TYPE_I_SAMFREQ_96KHZ | SamplingFreqTblPtr | Pointer to table of discrete sampling frequencies. Valid only for discrete sampling frequencies. | &AS_SamFreqTbl[0u] | - | AudioStreaming Endpoint Information | Standard Endpoint Information | EP_DirIn | Flag indicating if the direction is IN. | DEF_YES | DEF_NO
DEF_YES | EP_SynchType | Synchronization type supported by Isochronous endpoint. | USBD_EP_TYPE_SYNC_ASYNC | USBD_EP_TYPE_SYNC_NONE
USBD_EP_TYPE_SYNC_ASYNC
USBD_EP_TYPE_SYNC_ADAPTIVE
USBD_EP_TYPE_SYNC_SYNC | Class-Specific Endpoint Information. Refer to audio 1.0 specification, section 4.6.1.2 for more details about these fields. | EP_Attrib | Class specific controls supported by isochronous endpoint. | USBD_AUDIO_AS_EP_CTRL_SAMPLING_FREQ | A OR combination of:
USBD_AUDIO_AS_EP_CTRL_SAMPLING_FREQ
USBD_AUDIO_AS_EP_CTRL_PITCH
USBD_AUDIO_AS_EP_CTRL_MAX_PKT_ONLY or simply USBD_AUDIO_AS_EP_CTRL_NONE if no controls are supported. | EP_LockDlyUnits | Indicates the units used for the LockDly field.This field and the following works together. These fields relate to 'bLockDelayUnits' and 'wLockDelay' fields of Class-Specific AS Isochronous Audio Data Endpoint Descriptor. 'bLockDelayUnits' and 'wLockDelay' indicate to the Host how long it takes for the clock recovery circuitry of this endpoint to lock and reliably produce or consume the audio data stream. Only applicable for synchronous and adaptive endpoints. | USBD_AUDIO_AS_EP_LOCK_DLY_UND | USBD_AUDIO_AS_EP_LOCK_DLY_UND
USBD_AUDIO_AS_EP_LOCK_DLY_MS
USBD_AUDIO_AS_EP_LOCK_DLY_PCM | EP_LockDly | Indicates the time it takes this endpoint to reliably lock its internal clock recovery circuitry. Units used depend on the value of the LockDlyUnits field. | 0 | - | Synch Endpoint Information | EP_SynchRefresh | Refresh rate of the feedback endpoint (also called Synch endpoint). Feedback endpoint refresh rate represents the exponent of power of 2 ms. The value must be between 1 (2 ms) and 9 (512 ms). This field is valid only if the endpoint is an asynchronous OUT endpoint or an adaptive IN endpoint, | 0 | - |
|
The table pointed by SamplingFreqTblPtr
can be declared as shown below:
Anchor |
---|
| Listing - Example of Table Declaration of Discrete Number of Supported Sampling Frequencies |
---|
| Listing - Example of Table Declaration of Discrete Number of Supported Sampling Frequencies |
---|
|
Code Block |
---|
language | cpp |
---|
linenumbers | true |
---|
|
CPU_INT32U AS_SamFreqTbl[] = {
USBD_AUDIO_FMT_TYPE_I_SAMFREQ_44_1KHZ,
USBD_AUDIO_FMT_TYPE_I_SAMFREQ_48KHZ
}; |
106037317 presents the structure used to gather information about all alternate settings configuration for a given AudioStreaming interface. Anchor |
---|
| Table - USBD_AUDIO_AS_IF_CFG Structure Fields Description |
---|
| Table - USBD_AUDIO_AS_IF_CFG Structure Fields Description |
---|
|
Panel |
---|
borderWidth | 0 |
---|
title | Table - USBD_AUDIO_AS_IF_CFG Structure Fields Description |
---|
|
Field | Description | Example of value |
---|
AS_CfgPtrTbl | Table of pointers to USBD_AUDIO_AS_ALT_CFG structure. Refer to 106037317 for more details about USBD_AUDIO_AS_ALT_CFG structure. | &USBD_AS_IF1_Alt_SpeakerCfgTbl[0u], | AS_CfgAltSettingNbr | Nbr of alternate settings for given AS IF | 3 |
|
Table pointed by AS_CfgPtrTbl
can be declared as shown below:
Anchor |
---|
| Listing - Example of Table Declaration of AudioStreaming Alternate Setting Interfaces |
---|
| Listing - Example of Table Declaration of AudioStreaming Alternate Setting Interfaces |
---|
|
Code Block |
---|
language | cpp |
---|
linenumbers | true |
---|
|
USBD_AUDIO_AS_ALT_CFG *USBD_AS_IF1_Alt_SpeakerCfgTbl[] = { (1)
&USBD_AS_IF1_Alt1_SpeakerCfg,
&USBD_AS_IF1_Alt2_SpeakerCfg,
&USBD_AS_IF1_Alt3_SpeakerCfg,
}; |
Panel |
---|
|
(1) The table indicates that the AudioStreaming interface describing a speaker has three possible alternate settings. The host PC will choose one of them when opening the speaker stream based on the resources allocated by the PC for thus AudioStreaming interface. |