用于Windows XP的USB麦克风描述符,7,8应用程序

时间:2014-07-08 14:37:18

标签: windows audio usb microphone usb-descriptor

我正在尝试使用STMicroelectronics的USB-FS库在STM32F103上实现USB麦克风。

在Windows XP,7和8上检测到我的麦克风。 当我尝试使用Audacity录制语音时,信号在Windows XP和Windows 8上是正确的,但对于Windows 7,它会被放大。

有没有人知道发生了什么?

这是描述符:

const uint8_t Mic_ConfigDescriptor[] =
{
/* Configuration 1 */
0x09,                                /* bLength */
USB_CONFIGURATION_DESCRIPTOR_TYPE,   /* bDescriptorType */
0x64,                               /* wTotalLength = 100  bytes */
0x00,
0x02,                                 /* bNumInterfaces */
0x01,                                 /* bConfigurationValue */
0x00,                                 /* iConfiguration */
0x80,                                 /* bmAttributes  BUS Powred*/
0x32,                                 /* bMaxPower = 100 mA*/
/* 09 byte*/
/* Interface 0, Alternate Setting 0, USB Microphone Standard AC Interface Descriptor */
9,  /* bLength */
USB_INTERFACE_DESCRIPTOR_TYPE,        /* bDescriptorType */
0x00,                                 /* bInterfaceNumber */
0x00,                                 /* bAlternateSetting */
0x00,                                 /* bNumEndpoints */
USB_DEVICE_CLASS_AUDIO,               /* bInterfaceClass */
AUDIO_SUBCLASS_AUDIOCONTROL,          /* bInterfaceSubClass */
AUDIO_PROTOCOL_UNDEFINED,             /* bInterfaceProtocol */
0x00,                                 /* iInterface */
/* 09 byte*/
/* USB Microphone Class-specific AC Interface Descriptor */
9,   /* bLength */
AUDIO_INTERFACE_DESCRIPTOR_TYPE,      /* bDescriptorType */
AUDIO_CONTROL_HEADER,                 /* bDescriptorSubtype */
0x01,          /* 1.00 */             /* bcdADC */
0x00,
0x1E,                                /* wTotalLength = 30*/
0x00,
0x01,                                 /* bInCollection */
0x01,                                 /* baInterfaceNr */
/* 09 byte*/
/* USB Microphone Input Terminal Descriptor */
AUDIO_INPUT_TERMINAL_DESC_SIZE,       /* bLength */
AUDIO_INTERFACE_DESCRIPTOR_TYPE,      /* bDescriptorType */
AUDIO_CONTROL_INPUT_TERMINAL,         /* bDescriptorSubtype */
0x01,                                 /* bTerminalID */
0x01,                                 /* wTerminalType: terminal is Micro = 0x0201 */
0x02,
0x00,                                 /* bAssocTerminal */
0x02,                                 /* bNrChannels */
0x00,                                 /* wChannelConfig 0x0000  Mono */
0x00,
0x00,                                 /* iChannelNames */
0x00,                                 /* iTerminal */
/* 12 byte*/
/* USB Microphone Output Terminal Descriptor*/
//AUDIO_OUTPUT_TERMINAL_DESC_SIZE,      /* bLength */

0x09,
AUDIO_INTERFACE_DESCRIPTOR_TYPE,      /* bDescriptorType */
AUDIO_CONTROL_OUTPUT_TERMINAL,        /* bDescriptorSubtype */
0x02,                                 /* bTerminalID */
0x01,                                 /* wTerminalType AUDIO_USB_STREAMING.  0x0101*/
0x01,
0x00,                                 /* bAssocTerminal */
0x01,                                 /* bSourceID */
0x00,                                 /* iTerminal */
/* 09 byte*/
/* Interface 1, Alternate Setting 0, Audio Streaming - Zero Bandwith */
9,    /* bLength */
USB_INTERFACE_DESCRIPTOR_TYPE,        /* bDescriptorType */
0x01,                                 /* bInterfaceNumber */
0x00,                                 /* bAlternateSetting */
0x00,                                 /* bNumEndpoints */
USB_DEVICE_CLASS_AUDIO,               /* bInterfaceClass */
AUDIO_SUBCLASS_AUDIOSTREAMING,        /* bInterfaceSubClass */
AUDIO_PROTOCOL_UNDEFINED,             /* bInterfaceProtocol */
0x00,                                 /* iInterface */
/* 09 byte*/
/* Interface 1, Alternate Setting 1, Audio Streaming - Operational */
9,    /* bLength */
USB_INTERFACE_DESCRIPTOR_TYPE,        /* bDescriptorType */
0x01,                                 /* bInterfaceNumber */
0x01,                                 /* bAlternateSetting */
0x01,                                 /* bNumEndpoints */
USB_DEVICE_CLASS_AUDIO,               /* bInterfaceClass */
AUDIO_SUBCLASS_AUDIOSTREAMING,        /* bInterfaceSubClass */
AUDIO_PROTOCOL_UNDEFINED,             /* bInterfaceProtocol */
0x00,                                 /* iInterface */
/* 09 byte*/
/* USB Microphone Class-specific AS General Interface Descriptor */
AUDIO_STREAMING_INTERFACE_DESC_SIZE,  /* bLength */
AUDIO_INTERFACE_DESCRIPTOR_TYPE,      /* bDescriptorType */
AUDIO_STREAMING_GENERAL,              /* bDescriptorSubtype */
0x02,                                 /* bTerminalLink */
0x00,                                 /* bDelay */
0x01,                                 /* wFormatTag AUDIO_FORMAT_PCM8  0x0002*/
0x00,
/* 07 byte*/
/* USB Microphone Type I Format Type Descriptor */
0x0B,                                 /* bLength */
AUDIO_INTERFACE_DESCRIPTOR_TYPE,      /* bDescriptorType */
AUDIO_STREAMING_FORMAT_TYPE,          /* bDescriptorSubtype */
AUDIO_FORMAT_TYPE_I,                  /* bFormatType */
0x01,                                 /* bNrChannels */
0x02,                                 /* bSubFrameSize */
16,                                    /* bBitResolution */
0x01,                                 /* bSamFreqType */
0x40,        /* tSamFreq 8KHz = 0x1F40 */
0x1F,
0x00,
/* 11 byte*/
/* USB Microphone Standard Endpoint Descriptor */
AUDIO_STANDARD_ENDPOINT_DESC_SIZE,    /* bLength */
USB_ENDPOINT_DESCRIPTOR_TYPE,         /* bDescriptorType */
//AUDIO_IN_EP,                                 /* bEndpointAddress 1 IN endpoint*/

0x81, /* bEndpointAddress 1 IN endpoint*/
0x01,//USB_ENDPOINT_TYPE_ISOCHRONOUS,        /* 01: Asynchronous, 10: Adaptive, 11: synchronous. bmAttributes */
16,                                 /* wMaxPacketSize 22 bytes*/
0x00,
0x01,                                 /* bInterval */
0x00,                                 /* bRefresh */
0x00,                                 /* bSynchAddress */
/* 09 byte*/
/* USB Microphone Class-specific Isoc. Audio Data Endpoint Descriptor */
AUDIO_STREAMING_ENDPOINT_DESC_SIZE,   /* bLength */
AUDIO_ENDPOINT_DESCRIPTOR_TYPE,       /* bDescriptorType */
AUDIO_ENDPOINT_GENERAL,               /* bDescriptor */
0x00,                                 /* bmAttributes */
0x00,                                 /* bLockDelayUnits */ 
0x00,                                 /* wLockDelay */
0x00,
/* 07 byte*/
} 

2 个答案:

答案 0 :(得分:2)

此问题已解决:必须在描述符+特定于音频类的请求的响应中实现功能单元。

答案 1 :(得分:0)

如果未为输入路径定义功能部件,则Windows 7和更高版本将添加数字增益控件。 (Windows XP和macOS只会显示无法调整的灰色滑块。)

但是,Windows 7 has a bug that sets this digital control to +30 dB gain by default for Microphones

Change Windows gain slider display from percentage to decibels

Windows gain slider is set to +30 dB

因此,或者在第一次插入麦克风后将增益降低到0 dB,将终端类型设置为除麦克风之外的其他值,或者定义功能部件。