After spending quite a bit of time trying to design my way around the existing javax.sound.sampled library for simple (but relatively time-accurate) capture/rendering of audio, I'm concluding that I really need to get to the native audio API. The problem I've found is that I need to be able to get frame position of sound (that I'm rendering by writing to a SourceDataLine) in increments of 20 or 50 milliseconds, accurate to 1 or 2 milliseconds. In other words, I want to synchronize some graphical events to audio that is playing, with a video frame rate of 20 to 50 fps, with jitter no greater than 1 or 2 millseconds. It seems that the JavaSound implementation is too far from the hardware (a price to pay for platform independence?) for this. After much "tinkering" with SDL/TDL buffer sizes, audio formats, size of SDL.write() and TDL.read() buffers, frequency of writing, etc, I can't find a way to avoid the variation in the frame position reported compared to the system clock (at 1 millisecond resolution, not microseconds).
[Further clarification: I could just let the graphical rendering run at a fixed rate based on the system clock, which would be accurate enough for my needs. However, if this is to be synchronized with an audio track, by the time a typical audio track (5 minutes long, for instance) neared the end even small time differences will acccumulate to a noticeable time difference between audio and graphics. I thought to just check for synchronization every second (or 2 or 5), but the "jitter" from the reported audio frame position would result in corrections that would then be noticeable.]
I've been researching what libraries might already be available. It seems many of the existing packages are targeted to support the game development community. However, I don't need 3D audio, hardware acceleration of effects, synthesis, processing - just a way to read the frame position of what is being heard with a consistent latency. If the latency was as much as 100 milliseconds, but consistent, I could design around that.
I would appreciate recommendations for Java libraries providing this type of capability. I presume it will be JNI wrappers of a native audio API. I only need to support Windows7 at this point. I've seen OpenAL (seems to be Creative's "open" way of supporting hardware acceleration of audio since now no longer supported in Vista - game-oriented and more than I need), JSyn (focusing on synthesis, MIDI, not a simple sampled interface) and JAsioHost (most promising so far).
If there are ways around the limitations I've noted with the JavaSound API, that would also be fine, but I've just about given up after a week of effort.
Thanks.