ws-audio-api
ws-audio-api copied to clipboard
Audio drift over time?
Hi there, 1st of all, thanks for this great project! its pretty darn good! I am testing with various browsers and I noticed that the longer I broadcast on 1 machine, the more the audio on the client drifts behind.. I have the settings as codec: { sampleRate: 24000, channels: 1, app: 2051, frameDuration: 40, bufferSize: 4096 } but have experimenting with lots of combinations. no matter what, the delay starts at 0 or 1 sec, and progressively gets more and more, sometimes 10 or 15 seconds behind. I assume there is a buffer somewhere that keeps growing in the player but not sure where to look. Any help appreciated
also, on if a person is on Mac OS X and another on Windows, the voice from the Mac sounds "speed up" on the PC, and the voice of the PC is "slowed down" on the Mac...
Hi. Please try default settings:
codec: {
sampleRate: 24000,
channels: 1,
app: 2048,
frameDuration: 20,
bufferSize: 4096
}
I have the same issue. Two browsers broadcasting and playing at the same time: One of them plays with the frequencies shifted up, and in the other one they are shifted down. In the first one the time lag is almost unnoticeable, but in the second one the lag keeps growing (which seems logical)
I'm using the default codec config.
Any luck with the frequencies shifted up issue @yomboprime i am having the same issue
@Wilko0707 Yes, it dissappeared suddenly. It must have been a failure in The Matrix. Jokes aside, the frequency shift dissappeared, but the increase in lag in one of the sides did not. I solved it by erasing the receiving queue if its size exceeds 50000 (around one second) when receiving a new packet. There a a few audio clicks initially but otherwise my HTML5 phone application works well. I'll publish it soon.
@Ivan-Feofanov @BellesoftConsulting . I did a pull request for the audio playback issue. The problem derives from the fact that different machines sample at different rates. My Windows machine samples and plays at 48kHz and my friends Mac at 44kHz. If you sample at high rate and play at a lower sampling rate the audio will seem to slow down and vice versa.
As for the buffering problemn I've tried with the default settings but with those I experience stuttering on mobile phones. My theory is that the phones can't keep up with audio decoding versus playback. I increased the buffer size to 8192 and the stuttering stopped, but I'm experiencing increased buffer as mentioned by others previsously. I wonder if the issue could be solved by using webworkers to share the processing load to external threads?
pull request #3 fixes it for me