如何从 c++ 或 c 中的 USB 麦克风获取数据? [英] How to fetch data from a usb microphone in c++ or c?

查看:334
本文介绍了如何从 c++ 或 c 中的 USB 麦克风获取数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个项目,我需要对从 USB 麦克风获得的音频信号进行一些处理.最好从 USB 端口读取原始样本读数.但是,我找不到任何非常相关的东西.我打算用 C/C++ 来实现这个程序.谁能帮我开始?

I am working on a project that I need to do some processing with the audio signals obtained from a USB microphone. It would be best to read the original sample readings from the USB port. However, I couldn't find anything very relevant. I am planning to use C/C++ to implement this program. Can anyone help me to start?

我看到了一个名为 libusb 的库,但我不完全确定如何使用它作为从 USB 麦克风获取声音信号的方法.另外,当我说获取"时,我的意思是我需要查看原始采样数据.

I saw a library named libusb but I am not entirely sure how to use this as a way to fetch the sound signals from the USB mic. Also, when I say "fetch", I mean I need to see the originally sampled data.

推荐答案

Blue Snowflake Microphone 将在 Windows 和 Linux 上枚举为 USB 音频设备,这意味着您不需要驱动程序,也不应该将其作为通用 USB 设备进行通信.相反,您将希望使用本机音频 API 与设备进行交互.这意味着您可以打开设备,设置音频格式设置并直接从设备开始捕获样本.

The Blue Snowflake Microphone will enumerate as a USB Audio device on both Windows and Linux, which means you don't need a driver and you shouldn't have to talk to it as a generic USB device. Instead you will want to interface with the device using the native audio APIs. This means you can open the device, setup your audio format settings and start capturing samples directly from the device.

在 Windows 上查看 核心音频 API,打开设备后,您应该能够创建音频会话以使用 WASAPI.

On Windows have a look at the Core Audio APIs, once you have your devices opened you should be able to create an audio session to grab samples from the device using WASAPI.

对于 Linux,您应该查看 ALSA,虽然我还没有使用过它PulseAudio 似乎是现代 Linux 发行版的流行音频 API.

For Linux you should have a look at ALSA, and while I haven't used it PulseAudio seems to be a popular audio API for modern Linux distributions.

这篇关于如何从 c++ 或 c 中的 USB 麦克风获取数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆