开发者

openAL - choppy sound when playing the buffers

I have a voice chat which receives rtp packets (each packet contains 20ms of voice afaik), adds them to a buffer and plays it out.

If I call alSourcePlay(开发者_运维问答) directly after buffering a packet(I have 5 buffers and each buffer gets one packet, which are then re-used once the packets are played), the sound will be 'choppy' since it will play out the buffer before another packet arrives.

My question is how do you deal with this so that audio isn't played as choppy?


If you are, on average, getting less than 50 20ms packets per minute then there has to be pauses somewhere. If you store the packets for a while before playing them, then you can look for natural pauses ( silence ) and combine the gaps with the natural pauses so things sound more natural. The more you store the better playback will sound, but do it too much and the delay will become unpleasant.

The amount of buffering you need is a matter of taste. Which is uglier, a choppy sound or a delayed response. I guess you will have to design it so it is a variable and and then experiment to find the 'happy medium'

If you are short, at a maximum, of 10 packets per second, then a simpler scheme suggests itself: Place a delay of 4ms between each packet, which should be undetectable. Run for 1 second. See how many packets have accumulated ( if you only go 40 packets, this would be zero ) Adjust the inter-packet delay to compensate. Continue.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜