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

Sound latency? #2

Closed
jan-kleks opened this issue Mar 7, 2023 · 8 comments
Closed

Sound latency? #2

jan-kleks opened this issue Mar 7, 2023 · 8 comments

Comments

@jan-kleks
Copy link

This is a really great project! Does it add sound latency due to the fact there is an additional emulation layer? If yes, how much?

@crazii
Copy link
Owner

crazii commented Mar 8, 2023

Yes, the emulated DMA transfer may not start immediately, but after about 0~5ms.

@jan-kleks
Copy link
Author

jan-kleks commented Mar 8, 2023

Hmm... I guess it is neglectable then in comparison to the latency you would get running an emulator on a modern OS?

@crazii
Copy link
Owner

crazii commented Mar 15, 2023

I overlooked the total buffering of the PCI sound card. with the total buffering size as 16384 bytes, and with format as 16bit PCM, stereo, 22050Hz, the delay will be 0~180ms, which is noticeable.

@crazii
Copy link
Owner

crazii commented Mar 24, 2023

the last update (beta2b) reduces the latency to an acceptable value, (10~20ms) you can try it at: https://www.vogons.org/viewtopic.php?f=62&t=93006

@jan-kleks
Copy link
Author

jan-kleks commented Mar 24, 2023

This is awesome! Thank you! I think it should be totally fine now... But if there is room for pushing the latency even further down without breaking SBEMU (at least on more powerful hardware) -- go for it! Of course, I mean, at some point in the future when other more important issues are ironed out...

@crazii crazii closed this as completed Mar 30, 2023
@jan-kleks
Copy link
Author

@crazii At this stage of the project can we theoretically reduce the buffering even further? -- For even lower latency. :)

@crazii
Copy link
Owner

crazii commented Feb 15, 2024

@crazii At this stage of the project can we theoretically reduce the buffering even further? -- For even lower latency. :)

Theoretically yes, but if smaller buffer are used, the sound might becomes stuttering - the sound card finishes playingback the buffer too fast that there's no more buffer for it.

It's a common dilemma in sound buffering that requires real-time reaction: large buffer may cause latency and yet too small buffer might cause stuttering.
If no real-time reaction is needed (i.e. playing a music), then the buffer could be as large as possible and it doesn't matter.

As you can read dosbox-x.conf, in [mixer] section's comments:

#       blocksize: Mixer block size, larger blocks might help sound stuttering but sound will also be more lagged.

@jan-kleks
Copy link
Author

@crazii I see, thank you for this detailed explanation! So how does SBEMU sound latency compare to real cards it emulates?

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

2 participants