N7SD logo

HOME      INDEX

OpenAL_GtkAda_GUI_Doppler_Effect_10xSource_Linear


Project: gui_doppler_linear-m

Multi-Source (10 Sources) Train Doppler Simulator

Released 9/02/2025

Tested environment:
Ubuntu: 24.04.2 LTS, gcc:13.3.0, Gtkada:25.0.1
GNAT Studio 25.0w, Pulseaudio (pavucontrol)
OpenAL-Ada(Coreland) 1.1.1, Alire 2.0.2
PC: HP ENVY 17t-S100, i7-6700HQ, 16GB, Intel HD Graphics 530
Audio source file: Mono, 44.1kHz, 16bit, WAV file

To accurately reproduce the sound of a passing train, you can configure up to 10 sources along with the length of each source. Each source is positioned at equal intervals along the train according to the specified settings.

There is a known issue in OpenAL-Ada where the audio output level becomes abnormal when a source passes directly in front of the listener. Because of this, it is difficult to implement a proper workaround when using only a single source, especially for long objects such as trains.

As a solution, it is more effective to run the demo with multiple sources arranged in sequence.
This demo supports using up to ten sources simultaneously.

1. Tone Audio Doppler Effect Demo with 10 Sources

You can listen to the Doppler effect as a 1000 Hz tone Sources move from left to right or right to left relative to the listener.

As the Sources move, the audio frequency shifts according to the Doppler effect, and you can hear the sound transition from your left ear to your right ear.

Doppler Tone App and Audio output

10xSource Doppler App with Tone Audio

 

 

2. Passing Train Sound Doppler Effect Demo with 10 Sources

This demo reproduces the sound of a passing train as if you were standing near a railroad crossing.

Similar to the tone demo, you can hear both the change in audio frequency due to movement and the shift in volume from left to right as the train passes.

The duration of the sound is adjusted based on the train’s length.

Doppler Effect App and Audio output

10xSource Doppler App with Train Noise

 

The screen capture file with audio for the demo is 4 MB and too large to download here.
Please download it from GitHub.
GUI_Linear_M_10S_Train.webm

3. Additional Features

Select an audio WAV file

Choose direction of movement and enable looping

Adjust volume

Set source speed

Set listener distance from the track

Set source (train) length

Source files: https://github.com/moriyasum/OpenAL_GtkAda_GUI_Doppler_Effect_10xSource_Linear

4, Setup Environment

~$ cd ada/oal

~/ada/oal$ alr init gui_doppler_linear_m –bin (dash,dash)

Enter, Enter, Enter, Enter, Enter, Enter, Enter (all default)

Enter a short description of the crate: (default: '')
> 
Using default: ''

Alire needs some user information to prepare the crate for eventual submission 
to an index, which will be interactively requested now.

You can edit this information at any time with 'alr settings'

Please enter your full name: (default: 'Your Name')
> 
Using default: 'Your Name'
If you intend to publish this crate to the community index, you will need a 
GitHub account with which to submit a pull request, which can optionally be 
configured now (leave blank to skip).
Please enter your GitHub login: (default: '')
> 
Using default: ''
Please enter your email address: (default: 'example@example.com')
> 
Using default: 'example@example.com'

Alire needs some further crate-specific information to help other people who 
want to use your crate.

Select a software license for the crate?
  1. MIT OR Apache-2.0 WITH LLVM-exception
  2. MIT
  3. Apache-2.0 WITH LLVM-exception
  4. Apache-2.0
  5. BSD-3-Clause
  6. LGPL-3.0-or-later
  7. GPL-3.0-or-later WITH GCC-exception-3.1
  8. GPL-3.0-or-later
  9. Other...
Enter your choice index (first is default): 
> 
Enter a comma (',') separated list of tags to help people find your crate: (default: '')
> 
Using default: ''
Enter an optional Website URL for the crate: (default: '')
> 
Using default: ''
✓ gui_doppler_linear_m initialized successfully.

~/ada/oal$ cd gui_doppler_linear_m

~/ada/oal/gui_doppler_linear_m$ alr with gtkada

Updating index... remote: Enumerating objects: 12, done.
remote: Counting objects: 100% (2/2), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 12 (delta 1), reused 0 (delta 0), pack-reused 10 (from 1)
Unpacking objects: 100% (12/12), 8.66 KiB | 985.00 KiB/s, done.
From https://github.com/alire-project/alire-index
   ac45ff6..5414c7f  stable-1.4.0 -> origin/stable-1.4.0
 * [new branch]      aws-25.2.0   -> origin/aws-25.2.0
Updating ac45ff6..5414c7f
Fast-forward
 index/aw/aws/aws-25.0.0.toml | 60 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
 create mode 100644 index/aw/aws/aws-25.0.0.toml
Solving dependencies: 0.00% solved (0/0 deps, 0/1 solutions left)... Looking f
◶ Solving dependencies: 0.00% solved (0/0 deps, 0/1 solutions left)... Looking f
◶ Solving dependencies: 0.00% solved (0/0 deps, 0/1 solutions left)... Looking f
◶ Solving dependencies: 25.00% solved (1/4 deps, 5/11 solutions left)... Looking
◶ Solving dependencies: 25.00% solved (1/4 deps, 5/11 solutions left)... Looking
◶ Solving dependencies: 25.00% solved (1/4 deps, 5/11 solutions left)... Looking
◶ Solving dependencies: 25.00% solved (1/4 deps, 5/14 solutions left)... Looking
◶ Solving dependencies: 25.00% solved (1/4 deps, 5/14 solutions left)... Looking
◶ Solving dependencies: 25.00% solved (1/4 deps, 5/14 solutions left)... Looking
Requested changes:
   ✓ gtkada ^25.0.1 (add)

Changes to dependency solution:

   +   gtkada     25.0.1  (new)
   +📦 libgtk3    3.24.41 (new,indirect,system package)
   +📦 make       4.3.0   (new,indirect,system package)
   +📦 pkg_config 1.8.1   (new,indirect,system package)

Do you want to proceed?
[Y] Yes  [N] No  (default is Yes) Yes

~/ada/oal/gui_doppler_linear_m$ ls -al

total 36
drwxrwxr-x  6 mm mm 4096 Nov  9 15:52 .
drwxrwxr-x 17 mm mm 4096 Nov  9 15:52 ..
drwxrwxr-x  2 mm mm 4096 Nov  9 15:53 alire
-rw-rw-r--  1 mm mm  293 Nov  9 15:53 alire.toml
drwxrwxr-x  2 mm mm 4096 Nov  9 15:52 config
-rw-rw-r--  1 mm mm   29 Nov  9 15:52 .gitignore
-rw-rw-r--  1 mm mm  648 Nov  9 15:52 gui_doppler_linear_m.gpr
drwxrwxr-x  3 mm mm 4096 Nov  9 15:52 share
drwxrwxr-x  2 mm mm 4096 Nov  9 15:52 src

5, Download files from GitHub

Copy the extracted files to the directory below.

Copy the extracted files to the directory below.

$ cp *.adb ~/ada/oal/gui_doppler_linear_m/src

$ cp *.ads ~/ada/oal/gui_doppler_linear_m/src

$ cp *.gpr ~/ada/oal/gui_doppler_linear_m/

$ cp *.txt ~/ada/oal/gui_doppler_linear_m/

$ mkdir ~/ada/oal/gui_doppler_linear_m/bin

$ cp *.wav ~/ada/oal/gui_doppler_linear_m/bin

6, Build

~/ada/oal/gui_doppler_linear_m$ alr build

alr –non-interactive –no-color –no-tty -q build — -XLIBRARY_TYPE=static -XBUILD=Production -XGTK_PREFIX=/home/mm/.local/share/alire/builds/gtkada_25.0.1_d3787772/5b0a6c228d630e36e6dc7a2e55ab79e0ec87b01c42118c60761c64f4c6d5669c/ -XOBJCFLAGS= -XLDFLAGS= -XCPPFLAGS= -XCFLAGS= -XADAFLAGS=

[2025-11-16 15:56:57] process terminated successfully,

 elapsed time: 00.91s

At this point, a large number of “bad indentation”, “this line is too long”, “in should be omitted” and the other (style) warnings will be displayed, but you can ignore them all. 

Finally, if the link is completed and “Build finished successfully” is displayed, the build was successful.

check ./bin directory

/ada/oal/gui_doppler_linear_m$ cd bin

~/ada/oal/gui_doppler_linear_m/bin$ ls -al

total 9464
drwxrwxr-x 2 mm mm 4096 Nov 16 11:59 .
drwxrwxr-x 14 mm mm 4096 Nov 15 23:50 ..
-rwxrwxr-x 1 mm mm 8295352 Nov 16 11:59 gui_doppler_linear_m
-rw-rw-r– 1 mm mm 441044 Nov 9 16:06 testsound.wav
-rw-rw-r– 1 mm mm 939886 Nov 9 16:06 train-testsound-44100-Mono-Original.wav

 

 

7, Execution

~/ada/oal/gui_doppler_linear_m/bin$ ./gui_doppler_linear_m

Application Window

8, NOTE

  1. Avoid pressing “Pause” while the source is passing directly in front of the listener. If you press “Pause–Start” at that moment, the audio between the sources will become misaligned because the playback speeds of the left and right channels differ.
  2. If you change the “Source Count” setting after pressing “Start”, be sure to restart the demo by using “Stop–Start.” This prevents complications in synchronization between sources.