15

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.

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?

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

TJ1
  • 7,578
  • 19
  • 76
  • 119
  • A good start would be to state which platform you are aiming for. Since C++ has no native API for sound, you will have to rely on third-party libraries, and most of those are platform-specific. – DevSolar Jul 20 '12 at 12:25
  • thanks, I am intrested in Windows and also ASIO library. But more importantly a tutorial that explains how audio streaming is done, for example what is a server, or a socket etc. – TJ1 Jul 20 '12 at 12:29
  • 4
    What's with closing of questions like this? This is a seriously relevant issue. Good working sample code for realtime audio on PC platforms is a serious ongoing problem. – Robin Davies Apr 26 '13 at 16:55

2 Answers2

4

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

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

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

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

Aesthete
  • 18,622
  • 6
  • 36
  • 45
  • Thanks, I am wondering if there is a tutorial that explains how audio streaming is done in general and some sample C++ code that show how it is implemented? – TJ1 Jul 20 '12 at 12:36
  • 2
    Apparently this book is really good. And also low level enough that a lot could be learnt that is cross platform. http://www.amazon.com/Learning-Core-Audio-Hands-On-Programming/dp/0321636848 I may be wrong, if there is a windows specific book that is as good let me know! – Chris Barry Jul 20 '12 at 12:41
  • 1
    Your question is very broad TJ1. If you want to know more about sockets and servers it sounds like you should first start looking for some basic networking tutorials using `winsock`, maybe here? http://johnnie.jerrata.com/winsocktutorial/ – Aesthete Jul 20 '12 at 12:45
  • Otherwise `Live555` is open source, if you want to crawl through some source code. Learn networking basics and then start thinking about streaming. – Aesthete Jul 20 '12 at 12:47
  • @ChrisBarry thanks for the book suggestion, I will take a look at the book content and will let you know if there is a windows equivalent. – TJ1 Jul 20 '12 at 12:55
  • @Aesthete thank you very much for the information, I will take a look at your suggested links and Live555. – TJ1 Jul 20 '12 at 12:56
  • Glad to help, accept the answer and come back when you have more questions! :) – Aesthete Jul 20 '12 at 13:01
3

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

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

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

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

Alexandru C.
  • 3,337
  • 1
  • 25
  • 27
  • Thanks, that is useful I will take a look at your suggestions. – TJ1 Jul 20 '12 at 13:09
  • No. MMIO has terrible latency. Not even worth looking at, and no relevant improvements in recent operating systems. – Robin Davies Apr 26 '13 at 16:51
  • MMIO APIs on Windows are a disaster for realtime audio. Rarely gets much less than 100ms latency. Not worth pursuing. WASAPI is supposed to address realtime audio issues with windows, but is unable to provide anything much below 30ms latency on Windows 7 platforms. There's some evidence that WASAPI works much better on Windows 8; but I'm having serious problems getting it to work reliably. ASIO is probably still the way to go if you're after low-latency audio. Unfortunately. Microsoft has never provided reliable samples for realtime audio. A serious ongoing problem. – Robin Davies Apr 26 '13 at 16:56