Graf Zahl wrote:I noticed that OpenAL has sufficient lag here when trying to implement streaming audio for some of the video formats in Raze. I had to fudge quite a bit to make them match up.
Worse, different systems will have a different amount of lag. OpenAL Soft has extensions to measure the active latency of a sound source (or more generally, the device), though proper A/V sync for video playback can get somewhat involved.
For a form of this feature, however, OpenAL and streaming lag doesn't really factor into it. It's in the decoder's domain; when the decoder would read sample 'X' from the file (the end loop point or some other predefined point), jump to time point 'Y' (or bitstream 'Z') to read samples instead. From OpenAL's perspective, it's just playing a continuous stream of samples, it doesn't really care about what the decoder or zmusic is doing to get them. The trick, as it were, is largely in defining how scripts can control the flow of a music stream. What would be needed is a way for songs to define break points and seek points (as defined by the music creator; where it can stop reading the current samples and start reading other samples, without causing an obvious click or pop when played), and a way for scripts to set a seek point the decoder should start reading from the next time it reaches a break point.