- Edited
I'm trying to use the https://github.com/SkAT-VG/SDT toolkit on the Bela.
This is how I compile it, via ssh root@192.168.7.2
, on the Bela:
mkdir /root/src
cd /root/src/
git clone https://github.com/SkAT-VG/SDT.git SDT_git
After cloning has completed, the Makefile should be changed according to the following patch:
diff --git a/build/linux/Makefile b/build/linux/Makefile
index 6eb30e0..16332e5 100644
--- a/build/linux/Makefile
+++ b/build/linux/Makefile
@@ -1,7 +1,10 @@
SHELL=/bin/bash
CC=gcc
-CFLAGS=-fPIC -Wall -Wno-unknown-pragmas -Werror -O3
+# added PD_INCLUDE
+PD_INCLUDE = /usr/local/include/libpd
+# added -march=armv7-a -mtune=cortex-a8 -mfloat-abi=hard -mfpu=neon -ftree-vectorize --fast-math
+CFLAGS=-fPIC -Wall -Wno-unknown-pragmas -Werror -O3 -I"$(PD_INCLUDE)" -march=armv7-a -mtune=cortex-a8 -mfloat-abi=hard -mfpu=neon -ftree-vectorize --fast-math
LDFLAGS=-shared
SRCDIR=../../src
PREFIX=/usr
.... and then compilation can proceed:
cd SDT_git/build/linux
make
# and this to install:
cp -av ../../src/SDT/libSDT.so /usr/lib/
cp -av ../../src/Pd/*.pd_linux /root/Bela/projects/pd-externals/
cp -av ../../Pd/* /root/Bela/projects/pd-externals/
Compilation completes without a problem.
For testing, I create a new PD project on the Bela, and as the _main.pd
, I use https://github.com/SkAT-VG/SDT/blob/master/Pd/breaking%7E-help.pd - except I have to explicitly add [SDT]
so the other SDT objects can be found/instantiated; and I add some loadbang delays, and a [metro]
to keep retriggering sound production, as in:
... and copying the output to the dac 3 and 4, in addition to 1 and 2:
When I run this patch on laptop (Ubuntu 18.04), it runs without any messages about problems.
I have compiled and ran this on "Bela image, v0.3.1, 8 November 2017" Bela.io, and if I remember correctly, there were some underruns detected, but not very often.
Recently I performed a full update to "Bela image, v0.3.6b, 23 October 2018" - including both flashing the SD card, and flashing the eMMC (using the Beaglebone eMMC procedure). When I run this patch on the Bela, with Project Settings of Block size (audio frames): 16 (which was the default for me, I guess), then I get a ton of messages like:
Building project...
Build finished
Running project...
Running Pd 0.48-2
Audio channels in use: 2
Analog channels in use: 4
Digital channels in use: 16
No MIDI device enabled
bonk version 1.5
fiddle version 1.1 TEST4
pique 0.1 for PD version 23
sigmund~ version 0.07
=== SDT - Sound Design Toolkit ===
Version 078, (C) 2001 - 2018
Project SOb - http://soundobject.org
Project CLOSED - http://closed.ircam.fr
Project NIW - http://soundobject.org/niw
Project SkAT-VG - http://skatvg.eu
Included externals:
bouncing~ breaking~ bubble~ crumpling~ dcmotor~ demix~ envelope~
explosion~ fluidflow~ friction~ impact~ inertial modal
motor~ myo~ pitch~ pitchshift~ reverb~ rolling~
scraping~ spectralfeats~ windcavity~ windflow~ windkarman~ zerox~
Underrun detected: 1 blocks dropped
Underrun detected: 2 blocks dropped
Underrun detected: 1 blocks dropped
Underrun detected: 1 blocks dropped
Underrun detected: 1 blocks dropped
Underrun detected: 3 blocks dropped
Underrun detected: 2 blocks dropped
Underrun detected: 2 blocks dropped
Underrun detected: 1 blocks dropped
Underrun detected: 1 blocks dropped
...
... and the underrun messages are plenty and go very fast, occasionally I even get a console message about incoming messages being too fast - and CPU use is around 60%...
While I'm a bit uncertain about block size ( https://forum.bela.io/d/715-block-size-with-puredata-on-the-bela ), if I change Project Settings of Block size (audio frames): 64, and run again (which does not trigger a rebuild of the executable) then I get strictly "Underrun detected: 1 blocks dropped" (maybe with 2 blocks every once in a while), and CPU use is towards 53-55% - so block size apparently makes a difference, but is still there even with the max block size of 128. When I listen to the block size 64 output, however, it doesn't sound worse from the one on from the desktop PD.
Maybe the problem is partially due to the external objects not being self-contained, but instead, depending on some generic code in an .so
library; for instance, https://github.com/SkAT-VG/SDT/blob/master/src/Pd/breaking%7E.c uses:
t_int *breaking_perform(t_int *w) {
t_breaking *x = (t_breaking *)(w[1]);
t_float *out0 = (t_float *)(w[2]);
t_float *out1 = (t_float *)(w[3]);
int n = (int)w[4];
double tmpOuts[2];
while (n--) {
SDTBreaking_dsp(x->breaking, tmpOuts);
*out0++ = (t_float)tmpOuts[0];
*out1++ = (t_float)tmpOuts[1];
}
return w + 5;
}
... where SDTBreaking_dsp
is defined in https://github.com/SkAT-VG/SDT/blob/master/src/SDT/SDTControl.c (which ends up in the .so
, I guess).
As you can see from the Makefile patch, I've tried using Cortex-specific optimizations ( https://forum.bela.io/d/101-compiling-puredata-externals/30 ), but that didn't help much.
Would anyone have an idea why these underruns happen, and what - if anything - can be done to prevent them?