最近做了一个USB的audio设备,接到电脑上可以当外接声卡用,但在使用它录音的时候会有时候声音正常,有时候录的音走调了,比如录的是“喂喂喂”,放出来编程了“我我我”,大家有没有碰到过类似问题啊?
我的ISO_IN(录音)通道是单声道 8khz/16bit PCM
ISO_OUT(PLAY)通道是立体声 8khz/16bit PCM
下面是我的设备描述和配置描述(其中还集成了一个mass stroage 设备),大家帮忙看看有什么问题吗?
const uint8_t gau8DeviceDescriptor[] =
{
LEN_DEVICE, /* bLength */
DESC_DEVICE, /* bDescriptorType */
0x10, 0x01, /* bcdUSB */
0x00, /* bDeviceClass */
0x00, /* bDeviceSubClass */
0x00, /* bDeviceProtocol */
MAX_PACKET_SIZE0, /* bMaxPacketSize0 */
USB_VID_LO,
USB_VID_HI, /* idVendor */
USB_PID_LO,
USB_PID_HI, /* idProduct */
0x00, 0x01, /* bcdDevice */
0x01, /* iManufacture */
0x02, /* iProduct */
0x00, /* iSerialNumber */
0x01 /* bNumConfigurations */
};
const uint8_t gau8ConfigDescriptor[] =
{
LEN_CONFIG, /* bLength */
DESC_CONFIG, /* bDescriptorType */
0xd7,0x00, /* wTotalLength */
0x04, /* bNumInterfaces */
0x01, /* bConfigurationValue */
0x00, /* iConfiguration */
0x80, /* bmAttributes */
0x20, /* Max power */
/* Standard AC inteface */
0x09, /* bLength */
0x04, /* bDescriptorType */
0x00, /* bInterfaceNumber */
0x00, /* bAlternateSetting */
0x00, /* bNumEndpoints */
0x01, /* bInterfaceClass:AUDIO */
0x01, /* bInterfaceSubClass:AUDIOCONTROL */
0x00, /* bInterfaceProtocol */
0x00, /* iInterface */
/* Class-spec AC interface descriptor */
0x0A, /* bLength */
0x24, /* bDescriptorType:CS_INTERFACE */
0x01, /* bDescriptorSubType:HEADER */
0x00,0x01, /* bcdADC:1.0 */
0x3C,0x00, /* wTotalLength */
0x02, /* bInCollection */
0x01, /* baInterfaceNr(1) */
0x02, /* baInterfaceNr(n) */
/* TID 1: Input for usb streaming */
0x0C, /* bLength */
0x24, /* bDescriptorType:CS_INTERFACE */
0x02, /* bDescriptorSubType:INPUT_TERMINAL */
0x01, /* bTerminalID */
0x01,0x01, /* wTerminalType: 0x0101 usb streaming */
0x00, /* bAssocTerminal */
PLAY_CHANNELS, /* bNrChannels */
PLAY_CH_CFG,0x00, /* wChannelConfig */
0x00, /* iChannelNames */
0x00, /* iTerminal */
/* UNIT ID 5: Feature Unit */
0x08, /* bLength */
0x24, /* bDescriptorType */
0x06, /* bDescriptorSubType */
REC_FEATURE_UNITID, /* bUnitID */
0x04, /* bSourceID */
0x01, /* bControlSize */
0x03, /* bmaControls(0) */
0x00, /* iFeature */
/* TID 2: Output Terminal for usb streaming */
0x09, /* bLength */
0x24, /* bDescriptorType:CS_INTERFACE */
0x03, /* bDescriptorSubType:OUTPUT_TERMINAL */
0x02, /* bTerminalID */
0x01,0x01, /* wTerminalType: 0x0101 usb streaming */
0x00, /* bAssocTerminal */
REC_FEATURE_UNITID, /* bSourceID */
0x00, /* iTerminal */
/* UNIT ID 6: Feature Unit */
0x0A, /* bLength */
0x24, /* bDescriptorType */
0x06, /* bDescriptorSubType */
PLAY_FEATURE_UNITID, /* bUnitID */
0x01, /* bSourceID */
0x01, /* bControlSize */
0x01, /* bmaControls(0) */
0x02, /* bmaControls(0) */
0x02, /* bmaControls(0) */
0x00, /* iFeature */
/* TID 3: Output for speaker */
0x09, /* bLength*/
0x24, /* bDescriptorType:CS_INTERFACE*/
0x03, /* bDescriptorSubType:OUTPUT_TERMINAL*/
0x03, /* bTerminalID*/
0x01,0x03, /* wTerminalType: 0x0301 speaker*/
0x00, /* bAssocTerminal*/
0x06, /* bSourceID*/
0x00, /* iTerminal*/
/* TID 4: Input Terminal for microphone */
0x0C, /* bLength */
0x24, /* bDescriptorType:CS_INTERFACE */
0x02, /* bDescriptorSubType:INPUT_TERMINAL*/
0x04, /* bTerminalID*/
0x01,0x02, /* wTerminalType: 0x0201 microphone*/
0x00, /* bAssocTerminal*/
REC_CHANNELS, /* bNrChannels*/
REC_CH_CFG, 0x00, /* wChannelConfig*/
0x00, /* iChannelNames*/
0x00, /* iTerminal*/
/* Standard AS interface 1, alternate 0 */
0x09, /* bLength */
0x04, /* bDescriptorType */
0x01, /* bInterfaceNumber */
0x00, /* bAlternateSetting */
0x00, /* bNumEndpoints */
0x01, /* bInterfaceClass:AUDIO */
0x02, /* bInterfaceSubClass:AUDIOSTREAMING */
0x00, /* bInterfaceProtocol */
0x00, /* iInterface */
/* Standard AS interface 1, alternate 1 */
0x09, /* bLength */
0x04, /* bDescriptorType */
0x01, /* bInterfaceNumber */
0x01, /* bAlternateSetting */
0x01, /* bNumEndpoints */
0x01, /* bInterfaceClass:AUDIO */
0x02, /* bInterfaceSubClass:AUDIOSTREAMING */
0x00, /* bInterfaceProtocol */
0x00, /* iInterface */
/* Class-spec AS interface, this interface's endpoint connect to TID 0x02 */
0x07, /* bLength */
0x24, /* bDescriptorType:CS_INTERFACE */
0x01, /* bDescriptorSubType:AS_GENERAL */
0x02, /* bTernimalLink */
0x01, /* bDelay */
0x01,0x00, /* wFormatTag:0x0001 PCM */
/* Type I format type Descriptor */
0x0B, /* bLength */
0x24, /* bDescriptorType:CS_INTERFACE */
0x02, /* bDescriptorSubType:FORMAT_TYPE */
0x01, /* bFormatType:FORMAT_TYPE_I */
REC_CHANNELS, /* bNrChannels */
0x02, /* bSubFrameSize */
REC_BIT_RATE, /* bBitResolution */
0x01, /* bSamFreqType : 0 continuous; 1 discrete */
REC_RATE_LO,
REC_RATE_MD,
REC_RATE_HI, /* Sample Frequency */
/* Standard AS ISO Audio Data Endpoint */
0x09, /* bLength */
0x05, /* bDescriptorType */
ISO_IN_EP_NUM | EP_INPUT, /* bEndpointAddress */
0x05, /* bmAttributes */
MAX_PACKET_SIZE_ISO_IN,0x00, /* wMaxPacketSize*/
0x01, /* bInterval*/
0x00, /* bRefresh*/
0x00, /* bSynchAddress*/
/* Class-spec AS ISO Audio Data endpoint Descriptor */
0x07, /* bLength */
0x25, /* bDescriptorType:CS_ENDPOINT */
0x01, /* bDescriptorSubType:EP_GENERAL */
0x00, /* bmAttributes */
0x00, /* bLockDelayUnits */
0x00, 0x00, /* wLockDelay */
/* Standard AS interface 2, alternate 0 */
0x09, /* bLength */
0x04, /* bDescriptorType */
0x02, /* bInterfaceNumber */
0x00, /* bAlternateSetting */
0x00, /* bNumEndpoints */
0x01, /* bInterfaceClass:AUDIO */
0x02, /* bInterfaceSubClass:AUDIOSTREAMING */
0x00, /* bInterfaceProtocol */
0x00, /* iInterface */
/* Standard AS interface 2, alternate 1 */
0x09, /* bLength */
0x04, /* bDescriptorType */
0x02, /* bInterfaceNumber */
0x01, /* bAlternateSetting */
0x01, /* bNumEndpoints */
0x01, /* bInterfaceClass:AUDIO */
0x02, /* bInterfaceSubClass:AUDIOSTREAMING */
0x00, /* bInterfaceProtocol */
0x00, /* iInterface */
/* Class-spec AS inf this interface's endpoint connect to TID 0x01 */
0x07, /* bLength */
0x24, /* bDescriptorType:CS_INTERFACE */
0x01, /* bDescriptorSubType:AS_GENERAL */
0x01, /* bTernimalLink */
0x01, /* bDelay */
0x01,0x00, /* wFormatTag:0x0001 PCM */
/* Type I format type Descriptor */
0x0B, /* bLength */
0x24, /* bDescriptorType:CS_INTERFACE */
0x02, /* bDescriptorSubType:FORMAT_TYPE */
0x01, /* bFormatType:FORMAT_TYPE_I */
PLAY_CHANNELS, /* bNrChannels */
0x02, /* bSubFrameSize */
PLAY_BIT_RATE, /* bBitResolution */
0x01, /* bSamFreqType : 0 continuous; 1 discrete */
PLAY_RATE_LO,
PLAY_RATE_MD,
PLAY_RATE_HI, /* Sample Frequency */
/* Standard AS ISO Audio Data Endpoint, output, addtess 2, Max 0x40 */
0x09, /* bLength */
0x05, /* bDescriptorType */
ISO_OUT_EP_NUM | EP_OUTPUT, /* bEndpointAddress */
0x0d, /* bmAttributes */
MAX_PACKET_SIZE_ISO_OUT, 0x00, /* wMaxPacketSize */
0x01, /* bInterval */
0x00, /* bRefresh */
0x00, /* bSynchAddress */
/* Class-spec AS ISO Audio Data endpoint Descriptor */
0x07, /* bLength */
0x25, /* bDescriptorType:CS_ENDPOINT */
0x01, /* bDescriptorSubType:EP_GENERAL */
0x80, /* bmAttributes */
0x00, /* bLockDelayUnits */
0x00, 0x00, /* wLockDelay */
//////////////////////////////////////////////////////////////////////////以下是mass stroage interface
LEN_INTERFACE, // bLength
DESC_INTERFACE, // bDescriptorType
0x03, // bInterfaceNumber
0x00, // bAlternateSetting
0x02, // bNumEndpoints
0x08, // bInterfaceClass
0x05, // bInterfaceSubClass
0x50, // bInterfaceProtocol
0x00, // iInterface
LEN_ENDPOINT, // bLength
DESC_ENDPOINT, // bDescriptorType
BULK_IN_EP_NUM | EP_INPUT, // bEndpointAddress
EP_BULK, // bmAttributes
MAX_PACKET_SIZE_BULK_IN, 0x00, // wMaxPacketSize
0x00, // bInterval
LEN_ENDPOINT, // bLength
DESC_ENDPOINT, // bDescriptorType
BULK_OUT_EP_NUM | EP_OUTPUT, // bEndpointAddress
EP_BULK, // bmAttributes
MAX_PACKET_SIZE_BULK_OUT, 0x00, // wMaxPacketSize
0x00 // bInterval
}; |