Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Voice Stutter #3

Open
ImNotTiara opened this issue Apr 9, 2023 · 8 comments
Open

Voice Stutter #3

ImNotTiara opened this issue Apr 9, 2023 · 8 comments

Comments

@ImNotTiara
Copy link

I'm having an issue where the voice output starts stuttering after some time or if the local player experiences a brief freeze (can be manually reproduced by pausing and unpausing the editor).

I assume it has to do something with the audio buffer falling behind without recovering?

In the "UniVoiceAudioSourceOutput.New" i have a minSegCount of 2 and a segCount of 4.
Maybe i've just configured it incorrectly?

@adrenak
Copy link
Owner

adrenak commented Apr 12, 2023

What's your segLen? I try to have a segCount * segLen of about 5 seconds and a minSegCount * segLen of 1 second. That reduces stutter but adds to the latency. It's a tradeoff

@ImNotTiara
Copy link
Author

My segDataLen is 1600.

I did some further debugging and it seems to happen in the Feed method where "locIdx" and "bufferIndex" will desync have the same values. They will have the same values until the local player experiences yet another brief freeze which causes them to bump into sync again.

One solution would be to reset the buffer to force it into sync again.
I currently do this by disabling and re-enabling the gameobject. There must be another proper way to do this.

@adrenak
Copy link
Owner

adrenak commented Apr 14, 2023

I see, that is a good catch, I'll introduce something to do it without disabling the gameobject. Has this solved your issue properly? If not, with a segDataLen of 1600, and I'm assuming you're on 16000Hz, your minSegCount of 2 means the audio starts playing when the buffer has just 200ms of audio. If you have fluctuating
network latency you can easily exhaust it. I'd recommend changing it to atleast 5 so you keep .5 seconds of playable audio before playback starts. That also means a .5 second delay in audio reception. And segCount to 25 so the buffer has 2.5 so that if you exhaust playable audiot, it'll take you 2.5 seconds to go around the buffer and end up with 2.5 seconds of playable audio.

I'll make some improvements to the buffer, your suggestion is helpful and I have other features in mind too.

@ImNotTiara
Copy link
Author

From my testing of basically playing music over the network for more than 2 hours it seems to have indeed "solved" it, even when trying my best to make it break which is really good. A single small stutter here and there which is totally fine (will probably be even less noticeable when a proper buffer reset compared to my method of doing it).

And yeah segDataLen of 1600 with 16000Hz indeed.
I guess i'm really pushing the limits of trying to have it as low-latency as possible which could/will cause issues with bad connections and i should definitely play around with the configuration.

Thank you!

@adrenak
Copy link
Owner

adrenak commented Apr 15, 2023

Glad to hear that! So the enable/disable method with largera values i suggested? Btw thanks for the heavy testing I really appreciate it!

@ImNotTiara
Copy link
Author

No, the test was conducted using my low-latency values.
And no problems! Thank you for maintaining and providing this awesome framework!

@Ahmed310
Copy link

My segDataLen is 1600.

I did some further debugging and it seems to happen in the Feed method where "locIdx" and "bufferIndex" will desync have the same values. They will have the same values until the local player experiences yet another brief freeze which causes them to bump into sync again.

One solution would be to reset the buffer to force it into sync again. I currently do this by disabling and re-enabling the gameobject. There must be another proper way to do this.

@ImNotTiara can you elaborate it more how enabling & disabling the gameobject has fixed it?

@Ahmed310
Copy link

Ahmed310 commented Oct 10, 2023

I see, that is a good catch, I'll introduce something to do it without disabling the gameobject. Has this solved your issue properly? If not, with a segDataLen of 1600, and I'm assuming you're on 16000Hz, your minSegCount of 2 means the audio starts playing when the buffer has just 200ms of audio. If you have fluctuating network latency you can easily exhaust it. I'd recommend changing it to atleast 5 so you keep .5 seconds of playable audio before playback starts. That also means a .5 second delay in audio reception. And segCount to 25 so the buffer has 2.5 so that if you exhaust playable audiot, it'll take you 2.5 seconds to go around the buffer and end up with 2.5 seconds of playable audio.

I'll make some improvements to the buffer, your suggestion is helpful and I have other features in mind too.

I'm also facing voice stutters, can you point me to the right direction which buffer to clear/rest to make it disappear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants