Lowest possible latency

Moderator: flatmax

flatmax
Posts: 609
Joined: Sat Jul 23, 2016 11:39 pm

Re: Lowest possible latency

Post by flatmax » Fri Sep 01, 2017 11:43 pm

Interesting point, when I get time I will try to compare the two cards for latency.

Matt
Checkout the next kickstarter campaign - the Ultra 2 : https://kck.st/2xwM3DL
Please review the Zero sound card on Amazon USA : https://www.amazon.com/dp/B075V1VNDD
---
Check out our new forum on github : https://github.com/Audio-Injector

guysoft
Posts: 10
Joined: Thu Dec 21, 2017 9:55 pm

Re: Lowest possible latency

Post by guysoft » Fri Dec 22, 2017 12:21 am

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

robiwan
Posts: 59
Joined: Wed Jul 05, 2017 1:18 am

Re: Lowest possible latency

Post by robiwan » Mon Dec 25, 2017 5:43 pm

It might indeed be relevant. Thanks for the info!

robiwan
Posts: 59
Joined: Wed Jul 05, 2017 1:18 am

Re: Lowest possible latency

Post by robiwan » 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

guysoft
Posts: 10
Joined: Thu Dec 21, 2017 9:55 pm

Re: Lowest possible latency

Post by guysoft » Wed Jan 31, 2018 8:54 am

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.

robiwan
Posts: 59
Joined: Wed Jul 05, 2017 1:18 am

Re: Lowest possible latency

Post by robiwan » Wed Jan 31, 2018 3:48 pm

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.
Last edited by robiwan on Thu Feb 01, 2018 4:53 pm, edited 6 times in total.

guysoft
Posts: 10
Joined: Thu Dec 21, 2017 9:55 pm

Re: Lowest possible latency

Post by guysoft » Wed Jan 31, 2018 10:26 pm

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.

robiwan
Posts: 59
Joined: Wed Jul 05, 2017 1:18 am

Re: Lowest possible latency

Post by robiwan » Thu Feb 01, 2018 6:24 am

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.

robiwan
Posts: 59
Joined: Wed Jul 05, 2017 1:18 am

Re: Lowest possible latency

Post by robiwan » Tue Feb 06, 2018 6:53 pm

guysoft, I could actually use some help. I'm sending a PM.

guysoft
Posts: 10
Joined: Thu Dec 21, 2017 9:55 pm

Re: Lowest possible latency

Post by guysoft » Tue Feb 06, 2018 7:19 pm

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

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest