When I started
Penn TotalRecall last year I was a newcomer to the audio programming world, blissfully ignorant of all the problems I would run into trying to achieve cross-platform high-precision playback.
I have the dubious honor of have having written TotalRecall's audio backend not once, not twice, but four times.
- Java Sound. Kept the program "pure Java," but JS has fallen behind since its initial release. Sun's implementation's performance is problematic on Windows, and a deal breaker on Linux. Worse yet, OpenJDK's PulseAudio implementation improves audio performance on Linux but introduces restrictions on how you can use streams. The result is to render essentially all existing JS code (JavaZOOM, jsresources, etc.) incompatible and to make it difficult to program with both Sun JS and OpenJDK in mind. JFugue is the only major audio application I know of that uses JS. Do yourself a favor and don't touch it unless you absolutely must achieve pure Java, or are only doing trivial playback.
- OpenAL via LWJGL bindings. Despite hype from the Mac community, OpenAL is not really actively developed, even on Windows. On Linux the Standard Implementation is broken, and OpenAL Soft has consistent problems on some of my testing machines. Add to that LWJGL's stability problems and I knew it was time to move on.
- RtAudio. Refreshingly high level, but no community or support to speak of. The ALSA backend has consistent problems on one of my machines where RtAudio's stream status falls out of sync with the underlying ALSA stream status. RtAudio is the only cross-platform API I tried that does not come with file i/o abilities, so it must be used in conjunction with libsndfile. The author does not plan to add a WASAPI backend either, leaving things with DirectSound from the XP era. He only tests on XP and uses the term "windoze" in the code. Not a good sign for a cross-platform library. Additionally, the build process on Windows is essentially undocumented.
- FMOD. Moving to closed source was a huge concession. All our code is licensed GPLv3, but including FMOD prevents us from using anyone else's copyleft code. Also, it makes the resulting Penn TotalRecall binaries non-FOSS. Licensing aside, FMOD has been by far the best Audio API I have tried. Its performance across platforms is excellent. Even with the default settings. Even on Linux. Their forums are monitored regularly by FMOD employees, and you can email them in "emergency" situations and get a response within a business day. Unfortunately they don't offer paid support, but with free support that good it's hard to complain. The API is pretty darn well documented, and comes with loads of examples, although I did find it tricky to figure out how to accurately play sub-intervals of sounds.
Right now the playback code for TotalRecall is working perfectly on all platforms. The only "kludge" has been using the Java layer to stop the native playback. My last attempt to make FMOD self-stopping resulted in instability on Windows. Next time my work returns to TotalRecall audio I'll try to figure it out, and release the final audio library separately as HIMOD - a high-level interface for FMOD playback.