开发者

Continuous Streaming PCM data in C++?

开发者 https://www.devze.com 2022-12-13 09:10 出处:网络
I have a stream of PCM audio captured from a cell phone, and I want to play it. I am trying to find a lightweight method of playing this audio in C++.

I have a stream of PCM audio captured from a cell phone, and I want to play it.

I am trying to find a lightweight method of playing this audio in C++.

I can already slap on a wave header and create a file that plays in any media player, but I want to play the file in real time as it streams in. I would like to avoid w开发者_开发百科riting the file to disc just to read it again, and I also don't want to have pauses in the audio as I stop one file and start another.

I realize that OpenAL provides audio streaming functionality, but I was hoping for something simpler. I only need to play a single channel PCM stream.

Does anyone know of a lightweight, free(for commercial use) library or windows API that can do this?


Use the waveOut API in Windows


It looks like the patent has expired, so there should be no legal complications. The beauty of a patent is that it makes the algorithm public.


Playing a single PCM stream is not THAT simple, alas. Its not that hard. I've not used OpenAL but under standard windows audio, XAudio2 or DirectSound its easy to use a double buffered. Play buffer 1 while filling buffer 2 from the stream. Then play buffer2 while filling buffer1 and so on.

0

精彩评论

暂无评论...
验证码 换一张
取 消