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 Synchronization #14431
Comments
Duplicate of: #10306 But good description of the issue! |
#10306 doesn't cover the synchronization aspect of this issue, which is actually the most important part. It's mentioned only briefly in passing in #10306 (comment) but never made it into the issue proper. |
How I understood #10306, it's about precise delays between sound playbacks. If you use a delay of 0, so to speak, both sounds play at the same time, aka are synchronized. Idk what else that issue would be requesting. Did I misunderstand something? |
If I play a sound with delay 0, and then 5 seconds later, I play another sound with delay 0, I want them to play 5 seconds apart on the client side regardless of the amount of time each packet took to traverse the network. I don't just want each sound to play when they arrive at the destination. A key thing that the old issue misses is that it's possible to receive a sound packet AFTER the sound is supposed to start playing, in which case the sound needs to be started past the beginning of the sound file to avoid the rest of the sound being delayed (you can't make up for the portion you missed). I also proposed keeping compatibility, so that if a delay is nil, we keep the old behavior of playing sounds at the earliest possible opportunity rather than forcing them to sync by timestamp. |
That's what the other issue is about.
That's an important detail. Still, I think it's essentially the same issue, so merging them makes sense.
Keeping compatibility is required for all new features. The other issue speaks more about relative time offsets than global timestamps, and keeps the solution more open, maybe that caused some confusion. |
I was actually thinking about this just yesterday and the issue is way bigger then just sounds. Minetest needs a general synchronized time between the server and clients. This affects:
These packets should be timestamped so the other party can take network latency into account when handling these events.
The name I propose for this is "global timestamp" or "gts" for short. There's no need for it to be per-player either. As for synchronization we probably have to implement whatever algorithm NTP uses, because if it's off too much the whole approach goes bad.
Honestly I think calling this "backwards compatibility" is wrong. The old behavior is very broken. If general lag compensation is implemented you would also not need the complexity of If we want to facilitate bulk-playing of sounds (aka sheet music), it would still be more efficient to add a command that can transfer and entire list of sounds + delays to the client at once. |
@sfan5 [1] or tick counter, for fixed interval ticks EDIT: To clarify, you'll need two timestamps from the server when there's an event scheduled in the future rather than immediately. One for when the packet was sent, and one for when the event is scheduled. |
We don't need to account for clock drift over time, we should be able to assume that clocks on both ends of the connection tick at a rate that is close enough for our purposes, and manage their own time synchronization. Reimplementing any portion of NTP is probably out of scope for a game engine. For music, echoes, and other timed effects, it's less important than the time between sounds is exact as that it's consistent, and if I ask for an N second delay, it's never perceptibly different than any other N second delay between any other sounds. Just a zero-order model, where the client and server start their timers based on a single server to client packet, should be sufficient for an MVP of this. We should try to solve other problems only if there's evidence they exist, or else this will get scope creeped into infeasibility before we even have an implementation and we'll be stuck with sound-rich games being SP-only. |
So you wouldn't try to latency compensate the movement the client sends to the server? why not?
To be clear I was suggesting implementing exactly as many parts of (e.g.) NTP needed so the client and server can establish a common time that's not off by 1-300ms. Ignoring clock drift is okay.
I bet that would work well enough for sounds but I'm not convinced that this is the proper way to do it if you wanted to also use it for the other points on my list. |
Problem
When playing sounds in Minetest, the timing of sounds is entirely dependent on when the network packet requesting those sounds arrives at the client side. This means that:
Solutions
Alternatives
None.
Additional context
Use-cases:
The text was updated successfully, but these errors were encountered: