OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 5437|回复: 8

STM32F4做USB声卡,用AUDITION录音时,放出来的声音很小,录得时候显示的幅值也很小,但是放歌的时候声音就正常,怎么回事

[复制链接]

59

主题

196

帖子

0

精华

高级会员

Rank: 4

积分
770
金钱
770
注册时间
2018-5-3
在线时间
192 小时
发表于 2018-5-15 12:34:41 | 显示全部楼层 |阅读模式
正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165524
金钱
165524
注册时间
2010-12-1
在线时间
2116 小时
发表于 2018-5-15 12:34:42 | 显示全部楼层
回复

使用道具 举报

59

主题

196

帖子

0

精华

高级会员

Rank: 4

积分
770
金钱
770
注册时间
2018-5-3
在线时间
192 小时
 楼主| 发表于 2018-5-28 08:55:16 | 显示全部楼层
是修改WM8978的增益还是修改描述符
回复

使用道具 举报

59

主题

196

帖子

0

精华

高级会员

Rank: 4

积分
770
金钱
770
注册时间
2018-5-3
在线时间
192 小时
 楼主| 发表于 2018-5-28 08:56:32 | 显示全部楼层
麦克风的输入增益调大了也不行,还是太小
回复

使用道具 举报

59

主题

196

帖子

0

精华

高级会员

Rank: 4

积分
770
金钱
770
注册时间
2018-5-3
在线时间
192 小时
 楼主| 发表于 2018-5-28 08:58:18 | 显示全部楼层
__ALIGN_BEGIN static uint8_t usbd_audio_CfgDesc[AUDIO_CONFIG_DESC_SIZE] __ALIGN_END =
{
/* Configuration 1 */
  0x09,                                 /* bLength */
  0x02,                                 /* bDescriptorType */
  LOBYTE(AUDIO_CONFIG_DESC_SIZE),       /* wTotalLength  109 bytes*/
  HIBYTE(AUDIO_CONFIG_DESC_SIZE),
  0x03,                                 /* bNumInterfaces */
  0x01,                                 /* bConfigurationValue */
  0x00,                                 /* iConfiguration */
  0xC0,                                 /* bmAttributes  BUS Powred*/
  0x32,                                 /* bMaxPower = 100 mA*/
  /* 09 byte*/
  
  /* USB Speaker Standard interface descriptor */
  0x09,                                     /* bLength */
  0x04,                                     /* bDescriptorType */
  0x00,                                 /* bInterfaceNumber */
  0x00,                                 /* bAlternateSetting */
  0x00,                                 /* bNumEndpoints */
  0x01,                                /* bInterfaceClass */
  0x01,                                   /* bInterfaceSubClass */
  0x00,                               /* bInterfaceProtocol */
  0x00,                                 /* iInterface */
  /* 09 byte*/
//  
  /* USB Speaker Class-specific AC Interface Descriptor */
  0x0a,                                 /* bLength */
  0x24,                              /* bDescriptorType */
  0x01,                                  /* bDescriptorSubtype */
  0x00,          /* 1.00 */             /* bcdADC */
  0x01,
  0x46,                                 /* wTotalLength = 0x27*/
  0x00,
  0x02, //0x02                                /* bInCollection */
  0x02,  //0x02                               /* baInterfaceNr */
        0x01,  //0x01
  /* 0x0a byte*/
  
  /* USB Speaker Input Terminal Descriptor */
  0x0c,                                 /* bLength */
  0x24,                                    /* bDescriptorType */
  0x02,                                 /* bDescriptorSubtype */
  0x01,                                 /* bTerminalID */
  0x01,                                 /* wTerminalType AUDIO_TERMINAL_USB_STREAMING   0x0101 */
  0x01,
  0x00,                                 /* bAssocTerminal */
  0x01,                                 /* bNrChannels */
  0x00,                                 /* wChannelConfig 0x0000  Mono */
  0x00,
  0x00,                                 /* iChannelNames */
  0x00,                                 /* iTerminal */
  /* 12 byte*/
  
  /* USB Speaker Audio Feature Unit Descriptor */
  0x09,                                 /* bLength */
  0x24,                              /* bDescriptorType */
  0x06,                                  /* bDescriptorSubtype */
  0x02,                                  /* bUnitID */
  0x01,                                 /* bSourceID */
  0x01,                                 /* bControlSize */
  AUDIO_CONTROL_MUTE,                   /* bmaControls(0) */
  0x00,                                 /* bmaControls(1) */
  0x00,                                 /* iTerminal */
  /* 09 byte*/
  
  /*USB Speaker Output Terminal Descriptor */
  0x09,                                 /* bLength */
  0x24,                                 /* bDescriptorType */
  0x03,                                 /* bDescriptorSubtype */
  0x03,                                 /* bTerminalID */
  0x01,                                 /* wTerminalType  0x0301*/
  0x03,
  0x00,                                 /* bAssocTerminal */
  0x02,                                 /* bSourceID */
  0x00,                                 /* iTerminal */
  /* 09 byte*/
       
        /* USB Microphone Input Terminal Descriptor */
        0x0c,                                 /* bLength */
        0x24,                             /* bDescriptorType */
        0x02,                              /* bDescriptorSubtype */
        0x05,                                  /* bTerminalID */
        0x01,                                 /* wTerminalType : Microphone 0x0201 */
        0x02,
        0x00,                                 /* bAssocTerminal */
        0x02,                                 /* bNrChannels */
        0x03,                                 /* wChannelConfig : Mono sets no position bits */
        0x00,
        0x00,                                 /* iChannelNames */
        0x00,                                 /* iTerminal */
        /* 12 byte*/
       
        /* USB Microphone Audio Feature Unit Descriptor */
        0x0a,                                 /* bLength */
        0x24,                               /* bDescriptorType */
        0x06,                                /* bDescriptorSubtype */
        0x06,                                 /* bUnitID */
        0x05,                                 /* bSourceID */
        0x01,                                 /* bControlSize */
        0x01,                                 /* bmaControls(0) Mute & Volume */
        0x02,
        0x02,                                 /* ?? bmaControls(1) / iTerminal */
        0x00,
        /* 9 byte*/
       
        /*USB Microphone Output Terminal Descriptor */
        0x09,                                 /* bLength */
        0x24,                              /* bDescriptorType */
        0x03,                                /* bDescriptorSubtype */
        0x07,                            /* bTerminalID */
        0x01,                                 /* wTerminalType : USB Streaming */
        0x01,
        0x00,                                 /* bAssocTerminal */
        0x06,                            /* bSourceID */
        0x00,                                 /* iTerminal */
        /* 09 byte*/
  
       
  /* USB Speaker Standard AS Interface Descriptor - Audio Streaming Zero Bandwith */
  /* Interface 1, Alternate Setting 0                                             */
  AUDIO_INTERFACE_DESC_SIZE,             /* bLength */
  0x04,                               /* bDescriptorType */
  0x01,                                 /* bInterfaceNumber */
  0x00,                                 /* bAlternateSetting */
  0x00,                                 /* bNumEndpoints */
  0x01,                               /* bInterfaceClass */
  0x02,                               /* bInterfaceSubClass */
  0x00,                                /* bInterfaceProtocol */
  0x00,                                 /* iInterface */
  /* 09 byte*/
  
  /* USB Speaker Standard AS Interface Descriptor - Audio Streaming Operational */
  /* Interface 1, Alternate Setting 1                                           */
  AUDIO_INTERFACE_DESC_SIZE,            /* bLength */
  0x04,                               /* bDescriptorType */
  0x01,                                 /* bInterfaceNumber */
  0x01,                                 /* bAlternateSetting */
  0x01,                                 /* bNumEndpoints CCCCCCCCCCC*/
  0x01,                                 /* bInterfaceClass */
  0x02,                                 /* bInterfaceSubClass */
  0x00,                                /* bInterfaceProtocol */
  0x00,                                 /* iInterface */
  /* 09 byte*/
  
  /* USB Speaker Audio Streaming Interface Descriptor */
  AUDIO_STREAMING_INTERFACE_DESC_SIZE,  /* bLength */
  0x24,                                 /* bDescriptorType */
  0x01,                                 /* bDescriptorSubtype */
  0x01,                                 /* bTerminalLink */
  0x01,                                 /* bDelay */
  0x01,                                 /* wFormatTag AUDIO_FORMAT_PCM  0x0001*/
  0x00,
  /* 07 byte*/
  
  /* USB Speaker Audio Type III Format Interface Descriptor */
  0x0B,                                 /* bLength */
  0x24,                                 /* bDescriptorType */
  0x02,                                   /* bDescriptorSubtype */
  0x01,                                /* bFormatType */
  0x02,                                 /* bNrChannels */
  0x02,                                 /* bSubFrameSize :  2 Bytes per frame (16bits) */
  16,                                   /* bBitResolution (16-bits per sample) */
  0x01,                                 /* bSamFreqType only one frequency supported */
  SAMPLE_FREQ(USBD_AUDIO_FREQ),         /* Audio sampling frequency coded on 3 bytes */
  /* 11 byte*/
  
  /* Endpoint 1 - Standard Descriptor */
  AUDIO_STANDARD_ENDPOINT_DESC_SIZE,    /* bLength */
  0x05,                                 /* bDescriptorType */
  0x01,                                  /* bEndpointAddress 1 out endpoint*/
  //USB_ENDPOINT_TYPE_ISOCHRONOUS,        /* bmAttributes CCCCCCC*/
        0x01,
  LOBYTE(192),    /* wMaxPacketSize in Bytes (Freq(Samples)*2(Stereo)*2(HalfWord)) */
  HIBYTE(192),
        0x01,                                 /* bInterval */
  0x00,                                 /* bRefresh */
  0x00,                                 /* bSynchAddress */
  /* 09 byte*/
  
  /* Endpoint - Audio Streaming Descriptor*/
  AUDIO_STREAMING_ENDPOINT_DESC_SIZE,   /* bLength */
  0x25,                               /* bDescriptorType */
  0x01,                               /* bDescriptor */
  0x00,                                 /* bmAttributes */
  0x00,                                 /* bLockDelayUnits */
  0x00,                                 /* wLockDelay */
  0x00,
  /* 07 byte*/
//       
        /* USB Microphone Standard AS Interface Descriptor - Audio Streaming Zero Bandwith */
  /* Interface 2, Alternate Setting 0                                             */
        0x09,                                /* bLength */
        0x04,                                /* bDescriptorType */
        0x01,                                 /* bInterfaceNumber */
        0x00,                                 /* bAlternateSetting */
        0x00,                                 /* bNumEndpoints */
        0x01,                                /* bInterfaceClass */
        0x02,                                /* bInterfaceSubClass */
        0x00,                                /* bInterfaceProtocol */
        0x00,                                 /* iInterface */
        /* 09 byte*/
  
  /* USB Microphone Standard AS Interface Descriptor - Audio Streaming Operational */
  /* Interface 2, Alternate Setting 1                                           */
        0x09,                                  /* bLength */
        0x04,                               /* bDescriptorType */
        0x01,                                 /* bInterfaceNumber */
        0x01,                                 /* bAlternateSetting */
        0x01,                                 /* bNumEndpoints */
        0x01,                                       /* bInterfaceClass */
        0x02,                                  /* bInterfaceSubClass */
        0x00,                                   /* bInterfaceProtocol */
        0x00,                                 /* iInterface */
        /* 09 byte*/
  
  /* USB Microphone Audio Streaming Class-Specific Interface Descriptor */
        0x07,                                    /* bLength */
        0x24,                                /* bDescriptorType */
        0x01,                                   /* bDescriptorSubtype */
        0x07,                            /* bTerminalLink : Unit ID of the Output Terminal*/
        0x01,                                 /* bDelay */
        0x01,                                 /* wFormatTag : AUDIO_FORMAT_PCM */
        0x00,
        /* 07 byte*/
  
  /* USB Microphone Audio Type I Format Interface Descriptor */
        0x0B,                               /* bLength */
        0x24,                                 /* bDescriptorType */
        0x02,                                     /* bDescriptorSubtype */
        0x01,                                      /* bFormatType */
        0x02,                                 /* bNrChannels */
        0x02,                                 /* bSubFrameSize : 2 Bytes per audio subframe */
        0x10,                                 /* bBitResolution : 16 bits per sample */
        0x01,                                 /* bSamFreqType */
  SAMPLE_FREQ(USBD_AUDIO_FREQ),   /* Audio sampling frequency coded on 3 bytes */
  /* 8 + 3*N byte*/
  
  /* USB Microphone Streaming Standard Endpoint Descriptor */
        0x07,                                    /* bLength */
        0x05,                                   /* bDescriptorType */
        0x81,                                /* bEndpointAddress : IN endpoint 1 */
        0x05,                                 /* bmAttributes ?????? */
        LOBYTE(AUDIO_IN_PACKET),              /* wMaxPacketSize */
        HIBYTE(AUDIO_IN_PACKET),
        0x01,                                 /* bInterval : one packet per frame */
//        0x00,                                 /* bRefresh */
//        0x00,                                 /* bSynchAddress */
        /* 09 byte*/
  
        /* USB Microphone Class-specific Isoc. Audio Data Endpoint Descriptor */
        0x07,                                  /* bLength */
        0x25,                                  /* bDescriptorType */
        0x01,                                 /* bDescriptor */
        0x00,                                 /* bmAttributes */
        0x00,                                 /* bLockDelayUnits */
        0x00,                                 /* wLockDelay */
        0x00,
        /* 07 byte*/
} ;
哪个大神帮忙看下是不是描述符错了
回复

使用道具 举报

59

主题

196

帖子

0

精华

高级会员

Rank: 4

积分
770
金钱
770
注册时间
2018-5-3
在线时间
192 小时
 楼主| 发表于 2018-6-11 15:35:18 | 显示全部楼层
描述符是对的,固定频率已经实现了,现在再弄频率间的转换
回复

使用道具 举报

59

主题

196

帖子

0

精华

高级会员

Rank: 4

积分
770
金钱
770
注册时间
2018-5-3
在线时间
192 小时
 楼主| 发表于 2018-6-11 15:36:12 | 显示全部楼层
就是在描述符中增加其他频率,数据包的大小怎么处理?有大神知道吗?
回复

使用道具 举报

59

主题

196

帖子

0

精华

高级会员

Rank: 4

积分
770
金钱
770
注册时间
2018-5-3
在线时间
192 小时
 楼主| 发表于 2018-6-11 15:38:38 | 显示全部楼层
#define AUDIO_OUT_PACKET                              (uint32_t)((USBD_AUDIO_FREQ * 2 * 2) /1000)
/* modMono:1) */
#define AUDIO_IN_PACKET                               (uint32_t)((USBD_AUDIO_FREQ * 2 * 1) /1000)
这些数据包都是根据频率来设定的,修改了频率,包的大小怎么修改?
回复

使用道具 举报

59

主题

196

帖子

0

精华

高级会员

Rank: 4

积分
770
金钱
770
注册时间
2018-5-3
在线时间
192 小时
 楼主| 发表于 2018-6-12 14:37:38 | 显示全部楼层
电脑显示多个采样频率,切换频率传送的数据包怎么变换?如果还是按照以前默认的数据包,不就是出错了吗?有人知道吗?
QQ截图20180612135101.png
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-5-28 02:07

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表