{"id":1296,"date":"2023-05-23T07:39:14","date_gmt":"2023-05-23T11:39:14","guid":{"rendered":"https:\/\/jausoft.com\/blog\/?p=1296"},"modified":"2023-05-23T08:40:29","modified_gmt":"2023-05-23T12:40:29","slug":"joal-openal-graphui-spatial-sound-in-your-ui-jogamp-v2-5-0-notes","status":"publish","type":"post","link":"https:\/\/jausoft.com\/blog\/2023\/05\/23\/joal-openal-graphui-spatial-sound-in-your-ui-jogamp-v2-5-0-notes\/","title":{"rendered":"JOAL\/OpenAL + GraphUI: Spatial Sound in your UI &#038; JogAmp v2.5.0 Notes"},"content":{"rendered":"<p>While working on <a href=\"https:\/\/forum.jogamp.org\/Release-2-5-0-tp4042507.html\">JogAmp v2.5.0 release<\/a> and updating <a href=\"https:\/\/jogamp.org\/cgit\/gluegen.git\/tree\/doc\/JogAmpMacOSVersions.md\">supported MacOS versions<\/a> as well as <a href=\"https:\/\/forum.jogamp.org\/DPI-scaling-not-working-td4042206.html\">fixing Hi-DPI for AWT and NEWT<\/a>, some love has been given to our <a href=\"https:\/\/forum.jogamp.org\/JOAL-Update-tp4042614.html\">OpenAL-Soft integration to JOAL and JOAL itself<\/a>. <a href=\"https:\/\/jogamp.org\/cgit\/joal.git\/about\/\">JOAL&#8217;s git-repo about face<\/a> as well as its <a href=\"https:\/\/jogamp.org\/joal\/www\/\">project websites<\/a> displays our bump to <a href=\"https:\/\/jogamp.org\/cgit\/openal-soft.git\/log\/\">OpenAL-Soft v1.23.1<\/a> with listed audio-backends per platform. <em>Synthesizers and utilizing spatial sound within <a href=\"https:\/\/jausoft.com\/blog\/tag\/type-rendering\/\">our GraphUI<\/a> were the next logical steps<\/em>.<!--more--><\/p>\n<h3>Some details about the last hacking sessions.<\/h3>\n<p><em>Skip to the bottom for the demo, if this is too boring \ud83d\ude09<\/em><\/p>\n<p>Bumping OpenAL-Soft happened by accident while working on our <a href=\"https:\/\/forum.jogamp.org\/Min-version-macOS-td4042193.html\">updated supported MacOS version<\/a> 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 <em>OpenAL-Soft<\/em> to v1.23.1 and resolve our build issues. Then make sure the build-in backends were up-to-date, i.e. adding <em>pipewire<\/em> for GNU\/Linux as default on Debian 12 while still building on Debian 11.<\/p>\n<p>After digging through this boring stuff, I thought, heck, let&#8217;s do some tiny sound programming and test OpenAL more tightly. Especially our <a href=\"https:\/\/jogamp.org\/deployment\/jogamp-next\/javadoc\/joal\/javadoc\/com\/jogamp\/openal\/util\/ALAudioSink.html\">ALAudioSink (now promoted to JOAL&#8217;s util package)<\/a> with an agnostic <a href=\"https:\/\/jogamp.org\/deployment\/jogamp-next\/javadoc\/gluegen\/javadoc\/com\/jogamp\/common\/av\/AudioSink.html\">AudioSink interface<\/a> and <a href=\"https:\/\/jogamp.org\/deployment\/jogamp-next\/javadoc\/gluegen\/javadoc\/com\/jogamp\/common\/av\/AudioFormat.html\">AudioFormat<\/a> were enhanced to please more use-cases than our dear <a href=\"https:\/\/jogamp.org\/deployment\/jogamp-next\/javadoc\/jogl\/javadoc\/com\/jogamp\/opengl\/util\/av\/GLMediaPlayer.html\">GLMediaPlayer<\/a>. After adding a <a href=\"https:\/\/jogamp.org\/cgit\/joal.git\/tree\/src\/java\/com\/jogamp\/openal\/util\/SimpleSineSynth.java\">simple sine wave synthesizer<\/a> which streams data into OpenAL, I added <a href=\"https:\/\/jogamp.org\/cgit\/jsyn.git\/log\/?h=joal\">JOAL\/OpenAL support for JSyn<\/a> as I really didn&#8217;t want to reinvent this wheel \ud83d\ude09<\/p>\n<p>Refinements in the <a href=\"https:\/\/jogamp.org\/deployment\/jogamp-next\/javadoc\/gluegen\/javadoc\/com\/jogamp\/common\/av\/AudioSink.html\">AudioSink interface<\/a> and its <a href=\"https:\/\/jogamp.org\/deployment\/jogamp-next\/javadoc\/joal\/javadoc\/com\/jogamp\/openal\/util\/ALAudioSink.html\">ALAudioSink<\/a> OpenAL implementation range from using <em>type float<\/em> 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 <a href=\"https:\/\/jogamp.org\/cgit\/joal.git\/tree\/src\/java\/com\/jogamp\/openal\/util\/ALAudioSink.java?id=44ed86045ee1fc8a91fa2902196e9ddaf53242ca#n768\">the queuing and dequeuing buffer code<\/a> utilizing all the above, allowing its low latency application.<\/p>\n<p>Then I naturally <a href=\"https:\/\/jogamp.org\/cgit\/joal.git\/commit\/?id=afb386e13fd00fde1401d4551ee4790b1f6d5e09\">moved most of my ALAudioSink OpenAL code<\/a> to <a href=\"https:\/\/jogamp.org\/deployment\/jogamp-next\/javadoc\/joal\/javadoc\/com\/jogamp\/openal\/sound3d\/package-summary.html\">JOAL&#8217;s sound3d OO wrapper<\/a>, so we can <a href=\"https:\/\/jogamp.org\/cgit\/joal.git\/commit\/?id=44ed86045ee1fc8a91fa2902196e9ddaf53242ca\">use these objects<\/a> in a more elegant manner. <a href=\"https:\/\/jogamp.org\/deployment\/jogamp-next\/javadoc\/joal\/javadoc\/com\/jogamp\/openal\/sound3d\/Context.html#makeCurrent(boolean)\">Context.makeCurrent(..)<\/a> and <a href=\"https:\/\/jogamp.org\/deployment\/jogamp-next\/javadoc\/joal\/javadoc\/com\/jogamp\/openal\/sound3d\/Context.html#makeCurrent(boolean)\">Context.recreate()<\/a> were just two examples, see <a href=\"https:\/\/jogamp.org\/cgit\/jogl.git\/tree\/src\/demos\/com\/jogamp\/opengl\/demos\/graph\/ui\/UISceneDemo20.java#n388\">UISceneDemo02<\/a>.<\/p>\n<p>Last step was to .. perhaps use OpenAL spatial 3D sound in <a href=\"https:\/\/jausoft.com\/blog\/tag\/type-rendering\/\">our GraphUI<\/a> for sound making Shapes like <a href=\"https:\/\/jogamp.org\/cgit\/jogl.git\/tree\/src\/graphui\/classes\/com\/jogamp\/graph\/ui\/shapes\/MediaButton.java\">MediaButton<\/a>? I had to (re)learn that OpenAL requires the source to be in mono only, 1 channel, to allow the spatial sound positioning \ud83d\ude09 Hence <a href=\"https:\/\/jogamp.org\/deployment\/jogamp-next\/javadoc\/gluegen\/javadoc\/com\/jogamp\/common\/av\/AudioSink.html#setChannelLimit(int)\">AudioSink.setChannelLimit()<\/a> was added, to be funneled <a href=\"https:\/\/jogamp.org\/deployment\/jogamp-next\/javadoc\/jogl\/javadoc\/com\/jogamp\/opengl\/util\/av\/GLMediaPlayer.html#setAudioChannelLimit(int)\">from and to FFMpeg via GLMediaPlayer<\/a>.<\/p>\n<h3>The Demo &#8230;<\/h3>\n<p>Then finally it all worked out as expected, after <a href=\"https:\/\/jogamp.org\/cgit\/jogl.git\/commit\/src\/demos\/com\/jogamp\/opengl\/demos\/graph\/ui?id=aea2254d1226b9471893113bde2bf1e54c24b14c\">adding a few lines<\/a> to <a href=\"https:\/\/jogamp.org\/cgit\/jogl.git\/tree\/src\/demos\/com\/jogamp\/opengl\/demos\/graph\/ui\/UISceneDemo20.java#n388\">UISceneDemo02<\/a>.<a href=\"https:\/\/jausoft.com\/blog\/wp-content\/uploads\/2023\/05\/UISceneDemo20-vbaa-s04-fsaa0-snap07-1280x0720-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1297\" src=\"https:\/\/jausoft.com\/blog\/wp-content\/uploads\/2023\/05\/UISceneDemo20-vbaa-s04-fsaa0-snap07-1280x0720-1.png\" alt=\"\" width=\"1280\" height=\"720\" srcset=\"https:\/\/jausoft.com\/blog\/wp-content\/uploads\/2023\/05\/UISceneDemo20-vbaa-s04-fsaa0-snap07-1280x0720-1.png 1280w, https:\/\/jausoft.com\/blog\/wp-content\/uploads\/2023\/05\/UISceneDemo20-vbaa-s04-fsaa0-snap07-1280x0720-1-300x169.png 300w, https:\/\/jausoft.com\/blog\/wp-content\/uploads\/2023\/05\/UISceneDemo20-vbaa-s04-fsaa0-snap07-1280x0720-1-1024x576.png 1024w, https:\/\/jausoft.com\/blog\/wp-content\/uploads\/2023\/05\/UISceneDemo20-vbaa-s04-fsaa0-snap07-1280x0720-1-768x432.png 768w, https:\/\/jausoft.com\/blog\/wp-content\/uploads\/2023\/05\/UISceneDemo20-vbaa-s04-fsaa0-snap07-1280x0720-1-1088x612.png 1088w\" sizes=\"auto, (max-width: 1280px) 100vw, 1280px\" \/><\/a><\/p>\n<p>Here is a short ~2:42 minute video of <a href=\"https:\/\/jogamp.org\/cgit\/jogl.git\/tree\/src\/demos\/com\/jogamp\/opengl\/demos\/graph\/ui\/UISceneDemo20.java#n388\">UISceneDemo02<\/a> &#8230;, how else to showcase graphics, video and sound otherwise.<\/p>\n<div style=\"width: 640px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-1296-1\" width=\"640\" height=\"360\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/jausoft.com\/Files\/media\/20230523-UISceneDemo20.mp4?_=1\" \/><a href=\"https:\/\/jausoft.com\/Files\/media\/20230523-UISceneDemo20.mp4\">https:\/\/jausoft.com\/Files\/media\/20230523-UISceneDemo20.mp4<\/a><\/video><\/div>\n<p style=\"text-align: center;\">(<a href=\"https:\/\/jausoft.com\/Files\/media\/20230523-UISceneDemo20.mp4\">Direct video URL<\/a>, download and share \u2013 or just view at original resolution)<\/p>\n<p>To download and test for yourself, do the following on your favorite GNU\/Linux machine ..<\/p>\n<blockquote><p>#!\/bin\/sh<\/p>\n<p>type=archive\/rc<br \/>\nversion=v2.5.0-rc-20230523<br \/>\nfolder=${type}\/${version}<\/p>\n<p>mkdir ${version}<br \/>\ncd ${version}<\/p>\n<p>wget <a href=\"https:\/\/jogamp.org\/deployment\/$\" target=\"_top\" rel=\"nofollow noopener\">https:\/\/jogamp.org\/deployment\/$<\/a>{folder}\/fat\/jogamp-fat.jar<br \/>\n# wget <a href=\"https:\/\/jogamp.org\/deployment\/$\" target=\"_top\" rel=\"nofollow noopener\">https:\/\/jogamp.org\/deployment\/$<\/a>{folder}\/fat\/jogamp-fat-test.jar<br \/>\nwget <a href=\"https:\/\/jogamp.org\/deployment\/$\" target=\"_top\" rel=\"nofollow noopener\">https:\/\/jogamp.org\/deployment\/$<\/a>{folder}\/fat\/jogl-demos.jar<br \/>\nwget <a href=\"https:\/\/jogamp.org\/deployment\/$\" target=\"_top\" rel=\"nofollow noopener\">https:\/\/jogamp.org\/deployment\/$<\/a>{folder}\/fat\/jogl-fonts-p0.jar<\/p>\n<p>echo &#8220;Fetched from ${folder} to ${version}&#8221;<\/p>\n<p>java -cp jogamp-fat.jar:jogl-demos.jar com.jogamp.opengl.demos.graph.ui.UISceneDemo20<\/p><\/blockquote>\n<p>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.<\/p>\n<p>That&#8217;s it for now ..<\/p>\n<p><strong>The JogAmp project needs funding and we offer <a href=\"https:\/\/jogamp.org\/wiki\/index.php?title=Maintainer_and_Contacts#Commercial_Support\">commercial support<\/a>!<\/strong><br \/>\nPlease contact <a href=\"https:\/\/jausoft.com\/\">G\u00f6thel Software (Jausoft)<\/a>.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;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.&hellip; <a class=\"more-link\" href=\"https:\/\/jausoft.com\/blog\/2023\/05\/23\/joal-openal-graphui-spatial-sound-in-your-ui-jogamp-v2-5-0-notes\/\">Continue reading <span class=\"screen-reader-text\">JOAL\/OpenAL + GraphUI: Spatial Sound in your UI &#038; JogAmp v2.5.0 Notes<\/span> <span class=\"meta-nav\" aria-hidden=\"true\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[7,3,8],"tags":[9,13,22,71,16,44,33,31,17,46,29,68,73],"class_list":["post-1296","post","type-post","status-publish","format-standard","hentry","category-3d-opengl","category-computer-stuff","category-jogamp","tag-3d","tag-embedded-device","tag-fonts","tag-graph_type_rendering","tag-java","tag-jogamp","tag-linux","tag-mobile","tag-opengl","tag-openjdk","tag-os-x","tag-type-rendering","tag-video"],"_links":{"self":[{"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/posts\/1296","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/comments?post=1296"}],"version-history":[{"count":6,"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/posts\/1296\/revisions"}],"predecessor-version":[{"id":1304,"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/posts\/1296\/revisions\/1304"}],"wp:attachment":[{"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/media?parent=1296"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/categories?post=1296"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/tags?post=1296"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}