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. > > staticconstUsbAudioEndpointDescriptorTypeUsbIfd2StdEndpoint= > > { > > 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 Providenza & Boekelheide, Inc.