I'm in the process of bringing G-Audio to Raspberry Pi / LINX, and am pleased to report audio playback is working with a Raspberry Pi 3B+.
This means it's now possible to decode and playback MP3, FLAC, WAV, and Ogg Vorbis files directly from LabVIEW running on a LINX target. No chroot ssh trick, system exec calls, or Python code necessary 🎉
Those tact switches make for terrible sample trigger buttons - here's a more musical demo video of the same example VI running on Windows, demonstrating the multi-channel mixer.
If you're unfamiliar with G-Audio, it's an open source LabVIEW library designed as a replacement for LabVIEW's sound library (lvsound2), while bringing a number of new features and improvements.
Now a humble request to fellow hobbyists - I only have access to RPi 3B+ hardware, so would greatly appreciate if anyone could help test the library with other Raspberry Pi variants, BeagleBone Black, or other LINX capable boards (RockPi etc). If you have an audio hat / cape for your board or USB soundcard, I'd be interested to know if the library works with those too.
If you're interested in testing, or just want to try out the library, installation and (optional) build instructions are below.
Before beginning, ensure your board has the LINX toolkit installed and SSH is enabled.
1. Install G-Audio
Download and install the VIPM package from the github project dev branch:
2. Install ALSA to chroot
SSH into the LINX target (using PuTTy or similar) and run the commands:
sudo schroot -r -c lv opkg update opkg install alsa-lib exit
3. Copy g_audio_32.so to the target
(Note: This library has been compiled for armv7a processors. Other architectures may need to build the library using the build instructions below.)
SCP / SFTP to the LINX target (using WinSCP or similar) and copy the library file located in <vi.lib>\Dataflow_G\G-Audio\lib\LINX\g_audio_32.so to the /srv/chroot/labview/usr/lib folder.
Alternatively, SSH to the LINX target and download the library direct from github:
cd /srv/chroot/labview/usr/lib wget https://github.com/dataflowg/g-audio/raw/dev/src/LabVIEW/G-Audio/lib/LINX/g_audio_32.so
4. Make some noise!
Copy some audio files to your device using SCP or SFTP and place them in /home/pi or your preferred location. Create a LabVIEW project, add your LINX target, then try running the playback example VI from the Add-ons >> G-Audio >> Examples >> LINX palette.
If you need to adjust the volume output, SSH into the LINX target and run alsamixer. Press F6, then select the physical audio device (not Default). Use the up and down arrow keys to adjust the volume, or use numbers 1-9 to set the volume in 10% increments. Press Esc to save and exit the mixer.
If you don't trust random libraries from the internet (and why would you?) or the pre-built library doesn't work on your hardware, the library can also be built from source. The following commands will install the build environment to chroot, clone the git repo, build the library, and copy the built library to chroot's /usr/lib.
sudo schroot -r -c lv opkg update opkg install packagegroup-core-buildessential opkg install --force-depends libc6-dev opkg install --force-depends libgcc-s-dev opkg install libstdc++-staticdev opkg install git opkg install alsa-lib-dev git clone https://github.com/dataflowg/g-audio cd g-audio/src/C++ git checkout dev g++ -shared -fPIC -o g_audio_32.so *.cpp -lm -lpthread -ldl -std=c++11 cp g_audio_32.so /usr/lib exit
If you do get a chance to test the library, please mention the hardware board, OS version, and the audio device you tested with. There are a few known issues (see above), but playback should work with the default headphone audio device. Thank you!
Some updates on the library progress. The latest VIPM dev build can be found here:
Installation instructions remain the same, though the build command has been updated (see below) if you're building from source.
CPU usage has been significantly reduced. Decoding and playing an mp3 previously used ~30% CPU on the RPi 3B+, but is now down to around 7% CPU. FLAC playback has dropped from ~20% to ~7%, and WAV playback is down from ~15% to ~6%. The updated build command is:
g++ -shared -fPIC -o g_audio_32.so *.cpp -lm -lpthread -ldl -std=c++11 -mfpu=neon -mfloat-abi=softfp
The ALSA backend now performs a verbose query on all available devices and their subdevices. Previously all of the hardware devices were abstracted into a single high level device. In reality a single device (like the headphone jack) can have many subdevices with different capabilities, of which only a subset are available in the chroot environment.
Unless there's any serious issues that appear during testing in the next week or two, I'll include Raspberry Pi / LINX support in the next library release.