Page 4 of 5

Re: Lowest possible latency

Posted: Fri Sep 01, 2017 11:43 pm
by flatmax
Interesting point, when I get time I will try to compare the two cards for latency.

Matt

Re: Lowest possible latency

Posted: Fri Dec 22, 2017 12:21 am
by guysoft
Hey,
If its relevant, I am building and maintaining a realtime Distro for the Pi which has a realtime kernel. Ordered an audio injector and planing to test it out.

You can try it out here:
https://github.com/guysoft/RealtimePi

Re: Lowest possible latency

Posted: Mon Dec 25, 2017 5:43 pm
by robiwan
It might indeed be relevant. Thanks for the info!

Re: Lowest possible latency

Posted: Tue Jan 30, 2018 11:44 pm
by robiwan
Thanks guysoft, I've setup a low latency streaming application with your RT image + jack2 + Octocard. It's magic :D

Re: Lowest possible latency

Posted: Wed Jan 31, 2018 8:54 am
by guysoft
robiwan wrote:
Tue Jan 30, 2018 11:44 pm
Thanks guysoft, I've setup a low latency streaming application with your RT image + jack2 + Octocard. It's magic :D
robiwan, awesome! Can you provide how you set up jack2? I am just trying to get it to work without a gui. I am working to get it to work as an guitar/electric violin FX pedal.
Saw jackd2 requires a GUI and trying to get a distro that will have jack2 running out of the box.

Re: Lowest possible latency

Posted: Wed Jan 31, 2018 3:48 pm
by robiwan
I had to...
1. Make sure there is large enough shared memory for jack2. Check with df -h:

Code: Select all

pi@realtimepi:~ $ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        29G  1.6G   26G   6% /
devtmpfs        459M     0  459M   0% /dev
tmpfs           464M   72K  464M   1% /dev/shm
...
If /dev/shm should have a Size of < 128 MB, add the following line last in /etc/fstab:

Code: Select all

none    /dev/shm        tmpfs   defaults,size=128M      0       0
2. Build jack2 on the Pi without dbus configured, pretty much following the instructions of https://github.com/jackaudio/jack2

Code: Select all

sudo apt-get install libasound2-dev
mkdir src
cd src
git clone https://github.com/jackaudio/jack2
cd jack2
./waf configure --clients=16 --ports-per-application=128
./waf build
sudo ./waf install
That should setup and install jack2 with ALSA and given parameters, check the reported config that it looks alright.

Also, the jack shared objects end up in /usr/local/lib, so that path must be in the search path, I'm looking at putting that in a file named jack.conf contained in the /etc/ld.so.conf.d/ folder.

3. Setup permissions for shared memory and realtime priority setting exactly acc. to http://jackaudio.org/faq/linux_rt_config.html , see "1. Editing the configuration file", creating the 99-realtime.conf file. And then add pi to the realtime group.

Code: Select all

sudo groupadd realtime
sudo usermod -a -G realtime pi
and then reboot the pi.

4. Startup jack in /etc/rc.local
I created a file start_jack in /home/pi with content:

Code: Select all

#!/bin/sh
jackd -P70 -d alsa -r 48000 -p 64 &
jack_wait --wait --timeout 10
jack_connect system:capture_1 system:playback_1
jack_connect system:capture_2 system:playback_2
and then made it executable with "chmod a+x /home/pi/start_jack". Note: -p 64 is the number of frames in each callback. CPU usage for simple stream through is ~10% with 64 frames, and gets higher with lower number of frames.

Then I added the following in /etc/rc.local (via "sudo nano /etc/rc.local"):

Code: Select all

sudo runuser -u pi -- /home/pi/start_jack
This way input to output streaming is setup (albeit with only L/R for now) each time the Pi reboots.

5. Disable removal of entries in /dev/shm on logout (https://superuser.com/a/1179962/222331)

Set RemoveIPC option to No in /etc/system.d/logind.conf (sudo nano /etc/system.d/logind.conf):

Code: Select all

...
#IdleActionSec=30min
#RuntimeDirectorySize=10%
RemoveIPC=No
#InhibitorsMax=8192
#SessionsMax=8192
...
6. To allow ALSA applications to play, albeit with a lot larger latency, the ALSA JACK PCM plugin can be utilized, see http://jackaudio.org/faq/routing_alsa.html . The plugin needs to be installed with:

Code: Select all

sudo apt-get install libasound2-plugins
From here you can add jack clients to do DSP processing etc. etc.

Re: Lowest possible latency

Posted: Wed Jan 31, 2018 10:26 pm
by guysoft
Wha!
Thanks for that!
It's really hard finding all those small tips.
I'm playing also with the zynthian installation script found here. When I have something decent i'll publish and update here.

Also feel free to tell me if something does not work in RealtimePi. It gets much less attention and therefore little maintenance compared to my other OSes and I'd like to change that. Making updated builds is not hard if there is call.

Re: Lowest possible latency

Posted: Thu Feb 01, 2018 6:24 am
by robiwan
Will do, so far, everything seems to work as expected. Mind you, I've updated my answer with point 5, about systemd thrashing /dev/shm upon logout. Really nasty.

Re: Lowest possible latency

Posted: Tue Feb 06, 2018 6:53 pm
by robiwan
guysoft, I could actually use some help. I'm sending a PM.

Re: Lowest possible latency

Posted: Tue Feb 06, 2018 7:19 pm
by guysoft
Hey,
Answering you, but also suggest you post it in the github issue tracker, that way the history is saved and public for other people:
https://github.com/guysoft/RealtimePi/issues