OpenAL-aoal6oct23-with Gnat2021 on Ubuntu Installation
Updated 1/06/2024
Confirmed Ubuntu versions:
22.04.3 LTS
Full Description
This is a sound-playing utility for Ada that can play WAV files on Windows, OSX, and Linux, using
Ada tasking and OpenAL libraries. It includes a partial Ada binding to OpenAL.
It provides sound-playing capabilities for Ada apps to:
- asynchronously start and stop music/sound loops,
- initiate transient sounds,
- allow unlimited sound concurrency.
Description in READMEao.md:
Here is another OpenAL set with some test programs in GitHub. The test program plays two audio sounds.
It has a test programs “two”.
Install OpenAL ver 1.1.4 (06oct2023)
Install libopenal-dev package
$ sudo apt install libopenal-dev
Download Test Program from GitHub
Source Files: https://sourceforge.net/projects/portable-openal-sound/files/6oct2023/
Extract the file and copy “aoal6oct23” directory files as following diagram.
The test environment is extracted to home/ada
Check file permissions.
adaExample directory files:
Build “two” with Terminal
“two” plays 2 wave files simultaneously
Build with the original batch file
~/ada/aoal6oct23/adaOpenAL/adaExample$ ./lcmp.sh two
~/ada/aoal6oct23/adaOpenAL/adaExample$ ./lcmp.sh two
rm: cannot remove '*.o': No such file or directory
gcc -c -O3 -gnat12 -I.. -I../OalBinding -o /home/mm/ada/aoal6oct23/adaOpenAL/adaExample/obj/two.o two.adb
gcc -c -I./ -O3 -gnat12 -I.. -I../OalBinding -I- -o /home/mm/ada/aoal6oct23/adaOpenAL/adaExample/obj/snd4ada.o /home/mm/ada/aoal6oct23/adaOpenAL/snd4ada.adb
gcc -c -I./ -O3 -gnat12 -I.. -I../OalBinding -I- -o /home/mm/ada/aoal6oct23/adaOpenAL/adaExample/obj/al_h.o /home/mm/ada/aoal6oct23/adaOpenAL/OalBinding/al_h.ads
gcc -c -I./ -O3 -gnat12 -I.. -I../OalBinding -I- -o /home/mm/ada/aoal6oct23/adaOpenAL/adaExample/obj/alc_h.o /home/mm/ada/aoal6oct23/adaOpenAL/OalBinding/alc_h.ads
gcc -c -I./ -O3 -gnat12 -I.. -I../OalBinding -I- -o /home/mm/ada/aoal6oct23/adaOpenAL/adaExample/obj/oal_hpp.o /home/mm/ada/aoal6oct23/adaOpenAL/OalBinding/oal_hpp.ads
gcc -c -I./ -O3 -gnat12 -I.. -I../OalBinding -I- -o /home/mm/ada/aoal6oct23/adaOpenAL/adaExample/obj/snd.o /home/mm/ada/aoal6oct23/adaOpenAL/snd.adb
gcc -c -I./ -O3 -gnat12 -I.. -I../OalBinding -I- -o /home/mm/ada/aoal6oct23/adaOpenAL/adaExample/obj/sndloop.o /home/mm/ada/aoal6oct23/adaOpenAL/sndloop.adb
gnatbind -aO/home/mm/ada/aoal6oct23/adaOpenAL/adaExample/obj -I.. -I../OalBinding -x /home/mm/ada/aoal6oct23/adaOpenAL/adaExample/obj/two.ali
gnatlink /home/mm/ada/aoal6oct23/adaOpenAL/adaExample/obj/two.ali -o two_gnu -O3 oal.o -lstdc++ -lopenal -lpthread
rm: cannot remove '*.ali': No such file or directory
~/ada/aoal6oct23/adaOpenAL/adaExample$ ls -al
-rw-r–r– 1 mm mm 3824888 Dec 9 2021 choirCC3.wav
drwxr-xr-x 2 mm mm 4096 Jan 2 2023 hide
-rwxr-xr-x 1 mm mm 859 Oct 4 17:56 lcmp.sh
-rw-r–r– 1 mm mm 149548 Dec 11 2021 mKickCC0.wav
drwxr-xr-x 2 mm mm 4096 Jan 7 15:49 obj (The files in this directory were all updated)
-rw-r–r– 1 mm mm 789 Jan 2 2023 two.adb
-rwxrwxr-x 1 mm mm 1104064 Jan 7 15:49 two_gnu (This file is the new executable)
lcmp.sh creates executable on directory adaExample/.
Execute
~/ada/aoa12nov20/adaOpenAL/adaExample$./two_gnu
Hit to begin
Enter and output both sound channels simultaneously (mixed monaural)
hit to end kick
Enter and output only “choir” sound (monaural)
hit to end choir
Enter and stop audio
This program outputs both sounds as monaural.
Build with GnatStudio
Startup GnatStudio and Setting
~/ada/aoal6oct23/adaOpenAL/adaExample$ gnatstudio
Choose “Create New Project” and “Simple Ada Project”
Press Apply and the new project was created.
Choose “Edit” and ” Project-Properties”
Create source files list. File: ~ada/aoal6oct23/adaOpenAL/adaExample/Two-SourceFiles.txt
two.adb
snd.adb
snd.ads
snd4ada.adb
snd4ada.ads
sndloop.adb
sndloop.ads
alc_h.ads
al_h.ads
oal.cpp
oal.hpp
oal_hpp.ads
al.h
alc.h
alext.h
efx.h
efx-creative.h
Setup to use Source file names list Two-SourceFiles.txt
Setup Main program name
Setup C++ special header file name
There is “oal.hpp” file in OalBindig directory.
Setup Ada Linker option
Press “Save” to update Project-Properties settings
Auto generated file: two.gpr
project Two is
project Two is
for Source_Dirs use (".", "../../adaOpenAL", "../OalBinding", "../OalBinding/incoal");
for Object_Dir use "obj";
for Main use ("two.adb");
for Languages use ("Ada", "C", "C++");
for Source_List_File use "Two-SourceFiles.txt";
package Naming is
for Spec_Suffix ("C++") use ".hpp";
end Naming;
package Linker is
for Switches ("ada") use ("-lopenal");
end Linker;
end Two;
Build Project
Execute
Copy 2 audio files to ./obj/ directory before run:
choir.wav, kick.wav
Run with command line or gnatstudio “Run” button.
~/ada/aoal6oct23/adaOpenAL/adaExample/obj$ ./two
Hit to begin Enter
Mixed “choir” and “kick” monaural audio outputs.
hit to end kick Enter
Single “choir” monaural audio outputs.
hit to end choir Enter
Finish.
This program outputs both audios as monaural, it doesn’t output each Left and Right individual audio channel.