An ARMv7 Bela / Beaglebone black Lab Streaming Layer implementation
The Bela platform is a low-latency audio and sensor processing platform based on the BeagleBone Black. It is designed for real-time audio and other low-latency applications. Lab Streaming Layer (LSL) is a protocol for streaming data between applications, and is commonly used in neuroscience and other fields.
This repo contains the code and library needed to demonstrate real-time stream consumption from liblsl within the Bela context. It will discover available streams and will consume and print them to the console. Of course, you could create outlets, send data from the Bela, or process the data that's recieved. This just demonstrates the basic functionality of the library. It's also to help you get started with LSL on the Bela platform, including how to build it yourself if you want (or if the library is not compatible with some combination of OS and LSL version).
You can see it in action here:
bf16acec-b2c2-4947-8621-e83a3ec9e555.mp4
Included is also a simple example of streaming from pylsl to the bela. See render_lsl_audio.cpp for an example of how to stream audio from a wav file to the Bela board.
This example is not well tested, it works, but it needs optimization and checking for use in a project as right now it uses a lot of CPU (~90%) on the Bela.
- Clone the repo
- Upload the contents of the
srcfolder to your Bela project - Set the following in the "Make Parameters" section of the Bela IDE Settings:
CPPFLAGS=-std=c++14 -I/root/Bela/projects/<your_project_name>/include;LDLIBS=/root/Bela/projects/<your_project_name>/lib/liblsl.soDon't forget to replace<your_project_name>with the name of your project folder. - Click "Build" and then "Run"
- You should see the output of the LSL stream discovery and consumption in the console. If you have a stream available, it will print the data to the console.
The liblsl.so library is included in the lib folder, you can reuse this in other projects if you have the same Bela version. If not, or if you just want to build it yourself, you can do so by following these steps.
- Ensure your Bela has an internet connection
- SSH into your Bela board
ssh [email protected]orssh root@<your_bela_ip_address> - Run the following commands to install the dependencies (for Debian 9 / Stretch - Bela v0.3.8h):
This will install and set up llvm and clang version 7 which is the latest version supported on that version of Debian.
sudo apt-get update sudo apt-get install -y build-essential cmake llvm-7 clang-7 distcc update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-7 10 update-alternatives --install /usr/bin/clang clang /usr/bin/clang-7 10 update-alternatives --set clang++ /usr/bin/clang++-7 update-alternatives --set clang /usr/bin/clang-7
- Download and extract the dart-sdk, probably the latest dev version, until the stable version has native-assets support. The following demonstrates this for dart-sdk version 3.8.0-246.0.dev:
# download the archive wget https://storage.googleapis.com/dart-archive/channels/dev/release/3.8.0-246.0.dev/sdk/dartsdk-linux-x64-release.zip # extract the archive unzip dart-sdk-linux-x64-release.zip # delete the zip file rm -f dart-sdk-linux-x64-release.zip # add the dart-sdk to your PATH $PATH=$(pwd)/dart-sdk/bin:$PATH # make it available for the current session export PATH
- Download a liblsl.dart release, e.g.
v0.5.0, you can also use the main branch, but just remember clone withgit clone --recurse-submodules https://github.com/zeyus/liblsl.dart.gitto do agit submodule update --init --recursiveafter:# downlaod the release wget https://github.com/zeyus/liblsl.dart/archive/refs/tags/v0.5.0.zip # extract the archive unzip liblsl.dart-v0.5.0.zip # delete the zip file rm -f liblsl.dart-v0.5.0.zip
- Build the library, and test that it works:
cd liblsl.dart-0.5.0/packages/liblsl # build the library (this takes a while) dart --enable-excperiment=native-assets test # if all the tests pass, then you have a working library # you can see the shared library dependencies with the following command ldd .dart_tool/native_assets/lib/liblsl.so
- Copy the library to the
libfolder of your project:cp .dart_tool/native_assets/lib/liblsl.so /root/Bela/projects/<your_project_name>/lib/
- Clean up:
cd # delete the liblsl.dart folder rm -rf liblsl.dart-0.5.0 # delete the dart-sdk folder rm -rf dart-sdk
- Congrats! You've now build the
liblsl.solibrary and can use it in your Bela project. Take a look at an example of how to use it in this project'srender.cppcode.
This project is licensed under the MIT License. See the LICENSE file for details.
liblsl is licensed under the MIT License. See the liblsl/LICENSE file for details.