使用 C++ 教程和示例代码的音频流

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11579217/
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-08-27 15:18:19  来源:igfitidea点击:

Audio streaming using C++ tutorial and sample code

c++audio-streaming

提问by TJ1

I would like to learn basics of audio streaming. In particular, I would like to learn how to capture audio from a computer mic, and in real time stream it so that another user can listen to it live. I would like to do it on Windows.

我想学习音频流的基础知识。特别是,我想学习如何从计算机麦克风捕获音频,并实时流式传输,以便其他用户可以现场收听。我想在 Windows 上执行此操作。

Is there any good tutorial that explains how it is done and some sample C++ code that I can take a look for more details?

有没有很好的教程来解释它是如何完成的,以及一些我可以查看更多详细信息的示例 C++ 代码?

Also I heard ASIO provides a low latency library, so I am interested in that.

我也听说 ASIO 提供了一个低延迟的库,所以我对此很感兴趣。

采纳答案by Aesthete

Maybe herewould be a good place to start, if you're using Windows?

如果您使用的是 Windows,也许这里是一个很好的起点?

Have a read of that page and look at the WASAPIas well.

阅读该页面并查看WASAPI

You can capture raw audio directly from the device using the IAudioCaptureClient

您可以使用 IAudioCaptureClient

I have been involved in projects involving real time streaming of audio and have used aacas the audio format and Live555for a streaming library. These might be a good place to start.

我参与了涉及实时音频流的项目,并使用aac作为音频格式和Live555作为流媒体库。这些可能是一个很好的起点。

回答by Alexandru C.

For recording and playing audio on Windows I would recommend the waveform audio API. You have an example herefor recording data from the mic.

对于在 Windows 上录制和播放音频,我建议使用波形音频 API。您在此处有一个用于从麦克风录制数据的示例。

For the streaming part, if you want to use an already available multimedia streaming server, i would recommend icecast, with its API lib.

对于流媒体部分,如果您想使用已经可用的多媒体流媒体服务器,我会推荐icecast及其API lib

If you want to implement the network streaming by yourself, then you can use the asio lib. You have some examples here.

如果你想自己实现网络流媒体,那么你可以使用asio lib。你在这里有一些例子。

For audio playback on the client side, there is a tutorial using waveform API here.

有关客户端音频播放,有使用波形API的教程在这里