open2jamorg/open2jam — pull request #20 by dtinth (2012-10-23 15:00:18+00:00)
Title: Audio Latency and Autosyncing

This commits in audio latency branch tries to fix Issue #8.

Latency Class
-------------------
The autosyncing code in the Render class has been factored out into the Latency class.

This class can automatically adjust its latency based on the accuracy of note hits, so we can have one syncing code for both display lag and audio latency.

Changes to Autosound
--------------------------------
In the old version, the "Autosound" option makes a keysounded music behave like a non-keysounded music.

In this branch its behavior is changed:

* Keysounded music behaves like a keysounded music. If you press the keys when there are no notes, you will hear its keysound.
* When this option is turned on, the game plays the keysound for you if you hit the note late (because of audio latency, you'll hit most notes late, and this mode corrects it by playing the sound early).
* When you miss a note, the game stops playing keysounds automatically for you until you hit another note.
* __Audio latency__ takes place when this option is turned on.

Audio Latency
--------------------
Audio latency works by adjusting the display and judgment timing behind the audio time (which has latency).

How to use Autosync
-----------------------------

1. __Autosync the display lag first:__ Mute the sound, select an easy song that you know well, set the speed modifier to your comfortable speed. Check the "autosync" box next to the "display lag" box, then play that song. Try to play that song visually (because you muted the audio) and ignore the judgment the game gives. You may get a lot of GOOD or BAD judgments first but the game will adjust itself.
2. __Autosync the audio latency:__ Turn the sound on, select an easy song that you know well, set the speed modifier so that's it's a bit lower than your comfortable speed. Check the "auto-sync" box next to the "audio latency" box, then play that song. Try to make sure you hit the keyboard the moment the sound _actually goes out of your audio device into your ear_, not when you see the note falls down and hit the judgment bar. That is, try to make the sound of your finger hitting the keyboard match exactly with the sound coming out of your audio device.