How to detect bit depth of USB audio stream?

Sub forums for various specialist XMOS applications. e.g. USB audio, motor control and robotics.
Posts: 11
Joined: Tue Dec 20, 2016 4:09 pm

How to detect bit depth of USB audio stream?

Postby kasemann » Tue Dec 20, 2016 4:14 pm


We want to implement a high-res file detection into our USB-Audio device (derived from the xmos app_usb_aud_xk_216_mc example application) – an LED shall indicate to the user whether the audio material streamed fulfills the High-Res-Logo requirements or not (more than 16bits per sample OR Fs>= 88200). Samplerate detection is easy since a function to change PLL-configuration is called each time the samplerate changes (audiohw.xc). I’ve implemented that and the LED already indicates streaming formats above 88.2kHz, but how do I detect the bit-depth of the audio stream? Where in the code is this negotioated between the host and the audio device?


User avatar
XCore Legend
Posts: 1120
Joined: Thu May 27, 2010 10:08 am

Postby infiniteimprobability » Thu Dec 22, 2016 9:33 am

Hi, the place to pick up this info is in audiohw.xc which contains the user modifiable callback on sample rate change. You can find this in sw_usb_audio. Here's where you can take the appropriate action:

Code: Select all

void AudioHwConfig(unsigned samFreq, unsigned mClk, chanend ?c_codec, unsigned dsdMode,
    unsigned sampRes_DAC, unsigned sampRes_ADC)

sampRes_DAC will contain the bit depth (16, 24, 32 etc..)

Who is online

Users browsing this forum: Bogdanveh and 0 guests