Question about the timePosition resolution in AlphaSynth
See original GitHub issueYour environment
- Version used: master branch
- Platform used: JavaScript
- Rendering engine used: SVG
- Browser Name and Version: Chrome Version 59.0.3071.115
- Operating System and version (desktop or mobile): Windows 10
Expected Results
Is there a way to get a more precise result than as.get_TimePosition()
?
I donāt know much about how the sequencer works, so tell be if there is no easy way to do this. However I imagine the timing must be very precise in the sequencer, so the get_TimePosition API call may not be the most precise.
Observed Results
The precision is currently approximately 0.09 second. i.e if we call 100 times the get_timePosition
method in a second, weāll have only 11 or 12 different values.
What Iām trying to do
Iāme building a metronome sound. What Iāve done is retrieving the _tempoChanges
from the sequencer. I use that to construct an array with all the precise times where a click sound has to be played.
(By the way, here is what Iāve done to get the tempo changes: https://github.com/j4kim/alphaTab/commit/6f4eaffff0a0b0533eb9f3df38e9ca9c0e75bf6d, please tell me if there is a simpler way)
Then, I need to know where I am in the score to properly progam the next metronome sound (using setTimeout
or requestAnimationFrame
).
For the moment it works but the precision of the AlphaSynth time creates accumulative delay.
(āretardā means delay)
Possible Solution
If there is no way, I will consider a solution using javascriptās timestamp (performaces.now()
).
Of course Iām also listening to your advices if you have other ideas.
Thankās again for this amazing work !
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
My bad. I forgot to handle the new metronome events at the silent processing needed for seeking. š The problem should be solved nowā¦
Itās still in an experimental state but outputLatency is maybe the solution in the future https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/outputLatency
I also wanted to share this very good article about latency https://www.html5rocks.com/en/tutorials/audio/scheduling/