gemidyne / microtf2

A custom gamemode for Team Fortress 2 - Players compete against each other to get the most points by playing a series of rapid fire microgames in order to win the round!
https://www.gemidyne.com/projects/microtf2
GNU General Public License v2.0
30 stars 16 forks source link

A possible solution to the old issue of Beatblock music becoming out of sync with the platforms changing #235

Open worMatty opened 2 years ago

worMatty commented 2 years ago

Hey, folks.

In the past, the platforms in the Beatblock boss were in sync with the music. Unfortunately they became out of sync over time, presumably because timers are not accurate, so they were changed to be on separate timers. I think this is unfortunate as the syncing was a great effect, and the lack of it makes it harder to play (at least for me because I'm still familiar with the old way).

I've thought of a few ways to try and fix this over the years, as it's something I think could happen in other stuff, too, but I think I found a simple fix that doesn't require altering the sound files.

There is a client command named sndplaydelay which lets you play a sound from a specified point in its length. For example, if you want to play a sound from ten seconds in, you use sndplaydelay -10 sound.wav. If you use the command again, it will override the sound and move to the point you specify. You can use it to jump around to different points in a music track.

My proposal is to use this command to play the music track, and to issue the command again whenever the platforms are toggled, supplying the correct point in the track as the argument so as to keep them in sync. For example, if the platforms toggle every five seconds, the process would look like this:

sndplaydelay -0 music/track.mp3 (I think this should work, if not then try -0.1) sndplaydelay -5 music/track.mp3 and toggle platforms sndplaydelay -10 music/track.mp3 and toggle platforms sndplaydelay -15 music/track.mp3 and toggle platforms and so on...

If the command is issued as frequently as the platforms are toggled, the variance between the toggling and the music beat landing should be minimal and hopefully unnoticeable.

There are some problems with this command. It only accepts direct sound file paths, and doesn't work with game sound name entries from a soundscript. But since the music and plugin are part of a bundle, this shouldn't be a problem. I haven't tested it with looping wavs, and I haven't determined the best way to stop it. It might be possible to supply a time that exceeds the track length to make it stop, but I have had some success with sending sndplaydelay 10 sound.wav and then sndplaydelay -10 sound.wav. If you monitored the channel the music track was played on, you could send common/null.wav on the same channel to silence it.

gdfsgdfg commented 2 years ago

Has never been out of sync in the newer versions for me.