Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

Description

Get or set volume for one or all logical channels inside a cluster.

Files

usbd_audio_drv_<codec-name>.h / usbd_audio_drv_<codec-name>.c

Prototype

Arguments

p_audio_drv

Pointer to audio driver structure.

req

Volume request:

USBD_AUDIO_REQ_GET_CUR
USBD_AUDIO_REQ_GET_RES
USBD_AUDIO_REQ_GET_MIN
USBD_AUDIO_REQ_GET_MAX
USBD_AUDIO_REQ_SET_CUR

unit_id

Feature Unit ID.

log_ch_nbr

Logical channel number.

p_vol

Pointer to the volume value to set or get.

Endianness

p_vol uses a little endian memory organization. Hence, you should use µC/LIB macros MEM_VAL_GET_INT16U_LITTLE() and MEM_VAL_SET_INT16U_LITTLE() when reading or writing the volume from/to it. This will ensure data is accessed correctly regarding your CPU endianness.

Returned Value

DEF_OK, if NO error(s) occurred and request is supported.

DEF_FAIL, otherwise.

Callers

Audio Class.

Implementation guidelines

  1. log_ch_nbr allows you to get or set the volume for a specific channel. When log_ch_nbr is 0, you get or set the volume for all channels. Indeed, the logical channel #0 represents the master channel and encompasses all channels.

This listing shows an example usage of this function.

Volume Values Range Conversion (Audio Chip <-> Audio 1.0 spec)

When manipulating volume levels, be aware that you must handle the conversion from the audio codec range to the Audio 1.0 specification range and vice versa. Audio 1.0 indicates that the volume can range from +127.9961 dB (0x7FFF) down to -127.9961 dB (0x8001) in steps of 1/256 dB (0x0001) with an extended value of 0x8000 for -∞dB.

For GET_MIN, GET_MAX, and GET_RES request, respectively, the minimum, maximum and step volume must be translated from the audio codec range to the Audio 1.0 range.

For SET_CUR request, the volume level must be translated from the Audio 1.0 range to the audio codec range.

  • No labels