windows 如何从麦克风捕获音频以通过套接字发送?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7550197/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 18:09:21  来源:igfitidea点击:

How can I capture audio from a mic to send it over a socket?

c++windowsvisual-studio-2010winapiaudio

提问by Sefu

I am using Windows 7 and developing a chat-like application with Visual Studio 2010. I am looking for an EASY way of capturing audio from a microphone (or rather, from the default recording device), collect the buffer from said input, and send it over a socket. I've seen DirectX solutions recommended, but from my research that is quite the opposite of simple. 5000 lines of sample code for a simple capture/save file program? That simply doesn't work for me (and yes, that was an official sample provided with the SDK).

我正在使用 Windows 7 并使用 Visual Studio 2010 开发一个类似聊天的应用程序。我正在寻找一种从麦克风(或者更确切地说,从默认录音设备)捕获音频的简单方法,从所述输入收集缓冲区,然后发送它在一个插座上。我看过推荐的 DirectX 解决方案,但从我的研究来看,这与简单相反。一个简单的捕获/保存文件程序的 5000 行示例代码?这对我来说根本不起作用(是的,这是 SDK 提供的官方示例)。

Anyway, I don't need it to be cross-platform, and I would really prefer something that already comes with Windows, though I don't mind installing a library as long as it doesn't take longer than writing the hardware drivers from scratch to figure it out (exaggeration). I've heard of this waveInOpen function, but oddly enough I cannot find any demos on how to use it. If anyone has an idea or a link to some sample code, I would greatly appreciate it. Thanks everyone for your time!

无论如何,我不需要它是跨平台的,我真的更喜欢 Windows 已经附带的东西,尽管我不介意安装一个库,只要它不需要比编写硬件驱动程序更长的时间从头开始弄清楚(夸张)。我听说过这个 waveInOpen 函数,但奇怪的是我找不到任何关于如何使用它的演示。如果有人有想法或某些示例代码的链接,我将不胜感激。感谢大家的时间!

P.S. I can figure out the networking part myself. I just need access to the raw audio data buffer.

PS我可以自己弄清楚网络部分。我只需要访问原始音频数据缓冲区。

回答by Dave Holitish

If you're doing the sockets yourself try checking out:

如果您自己制作套接字,请尝试查看:

http://www.techmind.org/wave/

http://www.techmind.org/wave/

http://www.bcbjournal.com/articles/vol2/9810/Low-level_wave_audio__part_3.htm

http://www.bcbjournal.com/articles/vol2/9810/Low-level_wave_audio__part_3.htm

http://www.relisoft.com/freeware/recorder.html

http://www.relisoft.com/freeware/recorder.html

I enjoyed all of them but the last one, but then again, you might find it far more helpful.

我喜欢所有这些,但最后一个,但话说回来,你可能会发现它更有帮助。