JOAL/OpenAL + GraphUI: Spatial Sound in your UI & JogAmp v2.5.0 Notes

While working on JogAmp v2.5.0 release and updating supported MacOS versions as well as fixing Hi-DPI for AWT and NEWT, some love has been given to our OpenAL-Soft integration to JOAL and JOAL itself. JOAL’s git-repo about face as well as its project websites displays our bump to OpenAL-Soft v1.23.1 with listed audio-backends per platform. Synthesizers and utilizing spatial sound within our GraphUI were the next logical steps.

Some details about the last hacking sessions.

Skip to the bottom for the demo, if this is too boring 😉

Bumping OpenAL-Soft happened by accident while working on our updated supported MacOS version range. I became aware that neither our Windows nor MacOS builds were working properly, the latter lacked the fat lipo for x86_64 and aarch64. Hence, biz as usual, update the awesome underling OpenAL-Soft to v1.23.1 and resolve our build issues. Then make sure the build-in backends were up-to-date, i.e. adding pipewire for GNU/Linux as default on Debian 12 while still building on Debian 11.

After digging through this boring stuff, I thought, heck, let’s do some tiny sound programming and test OpenAL more tightly. Especially our ALAudioSink (now promoted to JOAL’s util package) with an agnostic AudioSink interface and AudioFormat were enhanced to please more use-cases than our dear GLMediaPlayer. After adding a simple sine wave synthesizer which streams data into OpenAL, I added JOAL/OpenAL support for JSyn as I really didn’t want to reinvent this wheel 😉

Refinements in the AudioSink interface and its ALAudioSink OpenAL implementation range from using type float in seconds for statistical values, avoiding losing precision on averages etc. Then retrieving OpenAL defaults as readable when using OpenAL-Soft, like default sample-rate and the latency (refresh-rate of mixing source buffers) to the proposed maximum number of sources. Finally I enhanced the queuing and dequeuing buffer code utilizing all the above, allowing its low latency application.

Then I naturally moved most of my ALAudioSink OpenAL code to JOAL’s sound3d OO wrapper, so we can use these objects in a more elegant manner. Context.makeCurrent(..) and Context.recreate() were just two examples, see UISceneDemo02.

Last step was to .. perhaps use OpenAL spatial 3D sound in our GraphUI for sound making Shapes like MediaButton? I had to (re)learn that OpenAL requires the source to be in mono only, 1 channel, to allow the spatial sound positioning 😉 Hence AudioSink.setChannelLimit() was added, to be funneled from and to FFMpeg via GLMediaPlayer.

The Demo …

Then finally it all worked out as expected, after adding a few lines to UISceneDemo02.

Here is a short ~2:42 minute video of UISceneDemo02 …, how else to showcase graphics, video and sound otherwise.

(Direct video URL, download and share – or just view at original resolution)

To download and test for yourself, do the following on your favorite GNU/Linux machine ..

#!/bin/sh

type=archive/rc
version=v2.5.0-rc-20230523
folder=${type}/${version}

mkdir ${version}
cd ${version}

wget https://jogamp.org/deployment/${folder}/fat/jogamp-fat.jar
# wget https://jogamp.org/deployment/${folder}/fat/jogamp-fat-test.jar
wget https://jogamp.org/deployment/${folder}/fat/jogl-demos.jar
wget https://jogamp.org/deployment/${folder}/fat/jogl-fonts-p0.jar

echo “Fetched from ${folder} to ${version}”

java -cp jogamp-fat.jar:jogl-demos.jar com.jogamp.opengl.demos.graph.ui.UISceneDemo20

On Windows you need to adjust the script to your command.com if not using cygwin, and for both, Windows and MacOS you need to add the FFMpeg dynamic libraries to your search path.

That’s it for now ..

The JogAmp project needs funding and we offer commercial support!
Please contact Göthel Software (Jausoft).

 

1 thought on “JOAL/OpenAL + GraphUI: Spatial Sound in your UI & JogAmp v2.5.0 Notes”

Comments are closed.