Sound issues

I always had problems playing sound with Java, at the moment I use standard Java sound, with the following limitations :

  • Under Linux there is a crackling sound, with both OpenJDK or Oracle JVM, I can’t figure out why and how to remove it (tried it on two computers, same problems)
  • Under Windows, when changing volume, the sound becomes awful (crackling a lot), I just used the standard way to do it ‘line.getControl(FloatControl.Type.MASTER_GAIN)’, it does that on every computer I tried. Can’t figure out why…
  • Under Linux (I just tested OpenJDK), changing volume randomly crashes, maybe it’s crackling more when it works, not sure…
  • When trying to manually change gain (directly modifying source data), it seems the sound output is automatically adjusted. Meaning that even if I reduce volume on source data, the sound will be played full volume, losing bits of information… The result is awful…

So I tried to use lwjgl, and more specifically OpenAL, it’s very easy to use, even in an applet (took me around 1-2 hours to fully implement it, changing previous sound system, using lwjgl applet loader,…). I love it, but problems are :

  • Jar needs to be signed, lwjgl provides signed jars, but they still need the user to accept the security warning
  • It doesn’t work at all with OpenJDK, looking through the web, it seems everyone has problems when trying to use signed applets with OpenJDK (IcedTea plugin). And as Oracle JVM is not provided by default on Ubuntu now, there’s no “easy” way to solve it… So now I understand why the browser version of Minecraft doesn’t work on my Linux, I think he has same problems as I have…

So, as much of the problems currently concern Linux, and it is even worse when using lwjgl (because of OpenJDK), I have finally decided to :

  • Stick to the standard Java sound on the applet, with no volume control (except mute) and crackling sound under Linux
  • Use lwjgl for the offline version of Snorms (not currently developed)

So the offline version will provide spatialized sound support, volume control and nice sounds under Linux and Windows (MacOS also I think), but not the online version.

Comments are closed.