DEP OEM Example Applications
There are several example applications in dep_examples/apps directory:
- DepLoopback Loop received audio samples back out the transmit path, with a configurable latency.
- DepAlsaBridge Bridge DEP's audio buffers to an ALSA soundcard. Only for bridged clock domains.
- dsoundcard ALSA plugin for DEP to appear as a sound card.
- dinfo Print information about the DEP shared audio buffers configuration.
- dplay Play audio samples from a file out through DEP.
- drecord Record audio samples from DEP to a file.
- dtest Play test tones into DEP transmit buffers.
Application Details
The DEP Programmer's Guide contains a section describing how these example applications work, including diagrams. Consult that guide and the provided source code for more details.
DepLoopback
DepLoopback provides a minimal example for receiving and transmitting audio samples using DEP.
A callback handler receives a block of audio samples from DEP, and writes these back to the transmit channels at a configurable latency in the future.
The latency value is set by a command line parameter, and must be at least the scheduling frequency (set in dante.json).
This application can be used to determine the lowest possible round-trip glitch-free audio path within the local software system to/from DEP, given a system state (e.g. subscribed flows, scheduler parameters, system performance level, etc).
DepAlsaBridge
DepAlsaBridge acts as a user-space ALSA application, writing and reading samples to/from ALSA device(s).
Because the sound cards (ALSA devices) are clocked, they require the rate of samples to be precisely aligned with the application.
DEP's audio samples are aligned with the connected Dante network, which is distinctly different from the local clock domain of the ALSA device.
For this application to work, the local sound card and Dante network clock domains must be bridged.
DEP supports a "hardware clocking" feature, which controls a hardware clock generation circuit to be synchronised with the Dante network time.
If these clocks are then used by the local sound card(s), the two clock domains are bridged, and this application can be used.
DepAlsaBridge should only be used in conjunction with DEP's Hardware Clocking feature - ie when local audio clocks are synchronised to Dante network time.
A software Asynchronous Sample Rate Converter is required to be integrated into an ALSA bridge if the hardware clocking feature is not used.
dsoundcard
ALSA plugin dsoundcard.so which provides an ALSA device which bridges application audio to/from DEP.
Requires some installation: see below section.
This application does not require hardware clocking, and permits use of DEP similar to other (eg USB) sound cards.
dinfo
Print metadata from the DEP shared audio buffers to stdout and exist.
Use the -h flag for more config options.
dplay
This software application plays mp3, wav and flac files to the DEP transmit buffers.
Use the -h flag for more config options.
drecord
This software application records audio data from the DEP receive buffers into a wav file.
Use the -h flag for more config options.
dtest
This software application plays tones or pink noise to the DEP transmit buffers.
Use the -h flag for more config options.
Usage
System requirements for running the pre-compiled applications are:
- Target environment:
aarch64-linux-gnu - glibc version:
2.31 - GLIBCXX version:
3.4.28
To use AlsaBridge or dsoundcard, ALSA is also required:
- alsa-lib version:
1.2.1.2 - alsa-utils version:
1.2.1
After the DEP container is fully started you can start the application. It is recommended to run it as a background task, e.g.
./DepLoopback &
Installing and using dsoundcard
To install dsoundcard, run the script install.sh and copy the contents of asoundrc into ~/.asoundrc, then reboot.
Check that the soundcard has been added to the list of ALSA devices by running aplay -L and ensuring dsoundcard appears in the list.
DEP can be used as an ALSA output device by specifying dsoundcard as the ALSA device name.
For example, to play audio to dep, run aplay -D dsoundcard file.wav or similar.
Recording audio received by DEP is similar: arecord -D dsoundcard -c 2 -f S32_LE -r 48000 file.wav.
Note the specification of the audio format and configuration to use.
Pulse Audio
The plugin can be registered as a PulseAudio output by running pacmd load-module module-alsa-sink sink_name=dsoundcard device=dsoundcard format=s32le rate=48000 (adjust sample rate to match DEP sample rate).
Sometimes you need to run pacmd update-sink-proplist dsoundcard device.description=DEP_Example_Soundcard in order to get the output to display on pavucontrol.
Using pavucontrol you should be able to redirect the output of an audio-producing app to DEP.
Deregister from the plugin by running pactl unload-module module-alsa-sink.
Register the plugin as a PulseAudio input by running pacmd load-module module-alsa-source source_name=dsoundcard device=dsoundcard format=s32le rate=48000 (adjust sample rate to match DEP sample rate).
Sometimes you need to run pacmd update-source-proplist dsoundcard device.description=DEP_Example_Soundcard in order to get the output to display on pavucontrol.
An example command to record audio from PulseAudio would be ffmpeg -f pulse -i dsoundcard output.wav.
Deregister from the plugin by running pactl unload-module module-alsa-source.
NOTE: PulseAudio can get quite confused if you register the dsoundcard plugin before DEP is running, or if DEP stops before the plugin has been deregistered.
Try to keep DEP running while the plugin is loaded.
NOTE: Due to the way dsoundcard works, it cannot be opened by PulseAudio for both input and output simultaneously. Please refer to the dsoundcard section in the appendix of the DEP Programmer's Guide for details on how to create another ALSA plugin to achieve this task.
Source Code Compilation
Source code for the DEP example applications is in the dep_examples/source directory.
To compile, GNU make, CMake and an appropriate toolchain are required. The build steps below will by default download an appropriate toolchain.
The provided binaries were compiled with aarch64-buildroot-linux-gnu-gcc and alsa-lib 1.0.29.
Steps to compile:
-
Compile example applications.
Generate make files from cmake. The following step configures the build to download and build a default version of the alsalib package. To skip the alsalib build and use a pre built/installed alsalib add the parameter
-DALSA_INSTALL_PATH=<alsa install path>to the first cmake command below.cd dep_examples && rm -rf build && mkdir -p build && cd build && cmake -DCMAKE_TOOLCHAIN_FILE=../source/toolchain.cmake ..Navigate into the
dep_examples/builddirectory. To build all examples, callmakeTo build specific example, first list the available building targets by calling
make helpThen call make on the specific target, e.g. to build DepLoopback, call
make dep_example_loopback -
Binary output locations.
After successful compilation the applications are found in the following folders.
Application Location loopback source/DepLoopbackALSA Bridge source/DepAlsaBridgedinfo source/dinfodplay source/dplaydrecord source/drecorddtest source/dtestdsoundcard source/dsoundcard.so