[wdmaudiodev] Re: USB 24bits audiostream descriptors

  • From: Marco Trapman <Marco.Trapman@xxxxxxxxxxx>
  • To: "wdmaudiodev@xxxxxxxxxxxxx" <wdmaudiodev@xxxxxxxxxxxxx>
  • Date: Thu, 19 Dec 2013 09:43:44 +0000

Thank you for your reply Tim. I added the 0x10000000 because my compiler gives 
a shift count to large error when I do not.

You are right about the packet size, thanks for the pointer.

Best regards,

Marco Trapman


From: wdmaudiodev-bounce@xxxxxxxxxxxxx 
[mailto:wdmaudiodev-bounce@xxxxxxxxxxxxx] On Behalf Of Tim Roberts
Sent: Wednesday, December 18, 2013 19:27
To: wdmaudiodev@xxxxxxxxxxxxx
Subject: [wdmaudiodev] Re: USB 24bits audiostream descriptors

Marco Trapman wrote:
I am working on a demo for an USB headset and I have a question about the audio 
endpoint descriptors of the USB. I have a working 8-48kHz 16bit audio stream 
and I can select any sample frequency in the windows properties of an audio 
device. I use the following descriptors:

I don't have an answer for your formatting question, but I do have two other 
minor points:



  (uint8)((AUDIO_LSR_MIN_SAMPLE_FREQUENCY) & 0xFF),                             
      // uint8 first byte minumum sample frequency
  (uint8)((AUDIO_LSR_MIN_SAMPLE_FREQUENCY >> 8) & 0xFF),                        
      // uint8 second byte minumum sample frequency
  (uint8)(((0x10000000 | AUDIO_LSR_MIN_SAMPLE_FREQUENCY) >> 16) & 0xFF),        
      // uint8 third byte minumum sample frequency
  (uint8)((AUDIO_LSR_MAX_SAMPLE_FREQUENCY) & 0xFF),                             
      // uint8 first byte maximum sample frequency
  (uint8)((AUDIO_LSR_MAX_SAMPLE_FREQUENCY >> 8) & 0xFF),                        
      // uint8 second byte maximum sample frequency
  (uint8)(((0x10000000 | AUDIO_LSR_MAX_SAMPLE_FREQUENCY) >> 16) & 0xFF),        
      // uint8 third byte maximum sample

My internal C compiler flagged 2 warnings here.  Your "0x10000000" constants 
are both useless.  When you shift right by 16 and "and" with 0xFF, that bit 
will not survive.



// Interface 2: Speaker, alternate setting 1. Audio endpoint descriptor.
static const UsbAudioEndpointDescriptorType UsbIfd2StdEndpoint =
{
  sizeof(UsbAudioEndpointDescriptorType),                                       
      // uint8 bLength;
  USB_DT_ENDPOINT,                                                              
      // uint8 bDescriptorType;
  USB_DIR_OUT | USB_EP_AUDIO_RX,                                                
      // uint8 bEndpointAddress;
  0x01,                                                                         
      // uint8 bmAttributes;
  ((AUDIO_LSR_MAX_SAMPLE_FREQUENCY / 1000) * AUDIO_LSR_SAMPLE_SIZE) * 
AUDIO_LSR_NOC,  // uint16 wMaxPacketSize;
  0x01,                                                                         
      // uint8 bInterval;
  0x00,                                                                         
      // uint8 bRefresh;
  0x00,                                                                         
      // uint8 bSynchAddress;
};

It is worth pointing out that your computation for max packet size is not 
sufficiently flexible.  It would fail, for example, for any frequency that is 
not a multiple of 1,000, such as 44100.  Further, it isn't wise to make the max 
packet size EXACTLY match your data rate.  Your audio clock and the USB clock 
are not exactly in sync -- they will drift over time.  Because of that, you 
need to allow for a little extra padding to allow for an extra sample every now 
and then.



--

Tim Roberts, timr@xxxxxxxxx<mailto:timr@xxxxxxxxx>

Providenza & Boekelheide, Inc.

Legal Disclaimer: This e-mail communication (and any attachment/s) is 
confidential and contains proprietary information, some or all of which may be 
legally privileged. It is intended solely for the use of the individual or 
entity to which it is addressed. Access to this email by anyone else is 
unauthorized. If you are not the intended recipient, any disclosure, copying, 
distribution or any action taken or omitted to be taken in reliance on it, is 
prohibited and may be unlawful.

Please consider the environment before printing this e-mail


Other related posts: