App Development

An LSL app is typically a (small) program that acquires data from a device (EEG amplifier, mouse, eye tracker, Wiimote) then sends it over a LSL stream, or that receives data from a LSL stream to do something meaningful with it (e.g. LabRecorder, visualization).

The optimal application structure will depend on the data source, the data source API, and the technology/language used to develop the application. We have several example applications, outlined below, that may serve as a guide. In general, we have found the following structure to be effective for most cases:

  • Optionally present options to the user and wait for the user to click “Start” or “Link”
  • Upon start:
  • In a loop (in a thread), or via a callback:
    • Retrive data from the device
    • Push data to the outlet

See LSL Coding Examples for links to small examples of code, and see the (in progress) API documentation.

Or see below for full applications.

C++ apps

The recommended way to get liblsl is to simply download the latest release from the release page. You may need to click on the black arrow to expand the list of assets.

If you are using CMake, pass the LSL_INSTALL_ROOT argument set to the location where your liblsl file installed / unpacked to. And your application should use something like the following line to find liblsl:

find_package(LSL 1.13.0 REQUIRED

Then you can link your target to liblsl with target_link_libraries(${PROJECT_NAME} PRIVATE LSL::lsl).

For a more complete example to help you get started with a C++ acquisition app, take a look at the AppTemplate_cpp_qt, a small example that provides a solid groundwork for at least the following parts:

  • license information
  • setting up a build with CMake
  • setting up a data stream in a separate thread
  • showing a graphical user interface to change the configuration and start / stop streaming data
  • save / load the configuration
  • CI configuration so binaries are almost automatically built on the three major OSes

On the AppTemplate_cpp_qt repository website click on “Use this template” to generate your own repository.

Read the annotated CMakeLists.txt file and the annotated source files for an overview of the app design and pointers about what you should change.

And of course many of the applications in the labstreaminglayer submodules are good examples of C++ applications, most of which use Qt.

You will also need to build your C++ application. Most LabStreamingLayer applications will follow similar Building LSL Apps instructions. Please be sure to read the application’s README (and optionally BUILD) before building.

Python apps

Python is another great language for app development, as long as your target audience has Python and the required libraries installed. You (and other app users) will need to have pylsl installed. The recommended way to get it is with pip install pylsl.

While there are no full application templates, look at the example code to begin.

A couple good pylsl example apps are the one from PupilLabs, which has both a plugin and a simple application, and SigVisualizer.

Windows Users

If users of applications linked to liblsl are encountering errors related to not being able to load the DLL, in particular missing a VCRUNTIME140_1.dll (or similar), then they probably need to install the latest Microsoft Visual C++ Redistributable for the application architecture