gixie
Posts: 36
Joined: Sun Aug 26, 2012 5:56 pm

Re: RPi and real-time, low-latency audio

Sat Feb 27, 2016 3:04 am

A little update...
The guide that I found on youtube failed to work for me because of unmet dependencies:

Code: Select all

The following packages have unmet dependencies:
 jackd1 : Depends: libjack0 (= 1:0.124.1+20140122git5013bed0-3.1+fixed1~raspbian1) but it is not going to be installed
          Depends: libdb5.1 but it is not installable
E: Unable to correct problems, you have held broken packages.
disabling onboard sound card...
setting default sound card to usb...
sed: can't read /etc/modprobe.d/alsa-base.conf: No such file or directory
forcing usb 1.1 and turning off turbo mode on eth...
cp: cannot stat â./ampbrownie/config_ampbrownie.txtâ: No such file or directory
cp: cannot stat â./ampbrownie/gx_head_rcâ: No such file or directory
cp: cannot stat â./ampbrownie/ampbrownie.gxâ: No such file or directory
Setup has finished. You will want to:
         - reboot and remove your keyboard and mouse
         - have your guitar/soundcard/midi controller hooked up
         - play some sweet tunes
         use "sudo reboot" to reboot now.
I will try again, using this script as a guide...
The person in the video is explaining that the GUI can be "forwarded" through ssh to another computer... Does the other computer have to be running *nix?
Is there something like a mobile client for guitarix? So you can control it with an Android tablet?
Thanks in advance!

gixie
Posts: 36
Joined: Sun Aug 26, 2012 5:56 pm

Re: RPi and real-time, low-latency audio

Wed Mar 02, 2016 2:57 am

Hello Jeremy and the other readers of the thread,
I finally got my raspberry pi (not the pi 2) to work. I started off fresh with a raspbian installation. Overclocked and expanded file system and then did the update/upgrade.
I installed the software and tried my M-Audio card for both inputs and outputs. Worked flawlessly. CPU usage was a bit high. I also tried the webui from my tablet.
Next what I want to accomplish is to run everything headless: log in via ssh, start the webserver, launch the two pieces of software and control everything from my tablet. I have a portable router that will be used as hotspot when needed or I will hook up the pi to lan.
Any pointers on the command line for jack and guitarix?
Thanks in advance!

Synthberry
Posts: 3
Joined: Mon Mar 07, 2016 7:28 pm

Re: RPi and real-time, low-latency audio

Mon Mar 07, 2016 7:55 pm

Hi Jeremy,

Thanks for creating the Wiki page - very helpful stuff. Am well on the way to getting some nice synth code running on the Pi 3 as a result.

Cheers!

JovianPyx
Posts: 51
Joined: Fri Nov 20, 2015 9:34 pm

Re: RPi and real-time, low-latency audio

Sat Mar 12, 2016 3:42 pm

Hello all,
I have:
Raspberry Pi 2 B with Cirrus Logic/Element14 audio board.
Audio works fine using Arch Linux kernel 4.1.13 (has audio board driver compiled in)

I have developed a MIDI synthesizer that works and sounds great, but I'd like to reduce the latency (measured from receipt of MIDI note-on to start of sound) which is currently 24.5 milliseconds. The latency is quite consistent. My MIDI data comes in through the console UART (console functions are disabled).

The synth is written as 2 threads, the synth thread and the MIDI controller and voice assigner. I have set ALSA's period to 8 frames (but have tested with 64 frames with no difference in latency). The MIDI controller has a polling UART driver to avoid problems I had with UART's FIFO where the FIFO grouped messages and blurted them out in chunks. To make the polling driver work, I included code to disable the UART's interrupt (to prevent the kernel driver from waking up and stealing my data). The synth works by receiving a MIDI note-on and storing the new note's data in temporary locations and then setting a message available flag. The synth samples the message available flag once each period (I am using the direct write transfer method) and copying the temporary new note data to the synth's voice data array. This all works great, except for the 24.5 millisecond latency.

I have tried these things separately and in combination:
1) Prevent Xorg from starting
2) nicing the synth and MIDI controller processes to -20
3) using 2 isolated cores, one for the synth thread and one for the MIDI controller thread.
4) changed the period size from 8 frames to as large as 64 frames

None of the above made any difference in the latency.
Because the MIDI controller runs with 100% CPU, the system switches to 900 MHz and stays there.

I'm looking for ways to reduce the latency I measure, but I'm not finding much.

Any clues?

JaniF
Posts: 4
Joined: Mon Mar 07, 2016 5:31 am

Re: RPi and real-time, low-latency audio

Sat Mar 12, 2016 7:37 pm

I don't know if this is the right place since I'm quite new forum member but I'd like to share my partial success story with RPi2 and usb audio. I tried several solutions to get decent synth sound of the rpi. First the onboard audio wich was terrible. Never got jack and HDMI to work together either. Then I tried an old Soundblaster live external and got connecting errors. I even bought a cheap cmedia dongle which worked but sound quality was terrible, even though many have reported getting good quality audio out of them.

At this point I realized Zoom R16 (which I have) playback support had been finally implemented in 4.4 kernels. Updated and got it working quite well. But there is minor problem. With Zynaddsubfx I get occasional snaps and pop without jack reporting xruns. I haven't tried tweaking ethernet settings. That's what I'm going to try next. Can't force usb to 1.1 since this is a 2.0 device.

Yoshimi 1.2.4 which is the version that comes with raspbian refused to connect to jack so I couldn't try if it works better. But with alsa modular synth I got similar snaps and pops. The jack was run with parameters jackd -P70 -p16 -t2000 -d alsa -P -dhw:R16 -p 128 -n 3 -r 44100 &. I tried with and without softmod, no difference. Without -P it was worse. The R16 was powered directly from Pi's usb port without included power supply.

This probably was quite meaningless post but wanted to share my experience with you since AFAIK nobody has reported if R16 works with RPi.

JovianPyx
Posts: 51
Joined: Fri Nov 20, 2015 9:34 pm

Re: RPi and real-time, low-latency audio

Sat Mar 12, 2016 11:36 pm

I found the problem - ALSA's buffer size determines this latency. By reducing the size of the buffer, I was able to get latency down to an acceptable 7 milliseconds.

JovianPyx
Posts: 51
Joined: Fri Nov 20, 2015 9:34 pm

Re: RPi and real-time, low-latency audio

Wed Mar 16, 2016 4:35 pm

Further experimentation showed that a 6 period buffer with 8 frame period size yields MIDI note-on to sound start latency of 2 milliseconds.

User avatar
AutoStatic
Posts: 326
Joined: Tue Jan 01, 2013 10:27 pm
Contact: Website

Re: RPi and real-time, low-latency audio

Wed Mar 16, 2016 8:10 pm

JovianPyx wrote:Further experimentation showed that a 6 period buffer with 8 frame period size yields MIDI note-on to sound start latency of 2 milliseconds.
Those are a bit weird values but if it works it works ;) The consensus is to use a period buffer size of 3 for bus-driven devices (USB, FireWire) and a size of 2 for everything else. Frame period size is almost always a power of 2. You can calculate the system latency (so not the total latency) with this formula:
Frame buffer * period buffer / sample rate
So in your case 8*6 would translate to a more common 2*32.
RPi and real-time, low-latency audio: http://wiki.linuxaudio.org/wiki/raspberrypi
RPi audio repository: http://rpi.autostatic.com/
RPi and audio blog: https://autostatic.com/tag/raspberrypi/

User avatar
AutoStatic
Posts: 326
Joined: Tue Jan 01, 2013 10:27 pm
Contact: Website

Re: RPi and real-time, low-latency audio

Wed Mar 16, 2016 8:15 pm

JaniF wrote:At this point I realized Zoom R16 (which I have) playback support had been finally implemented in 4.4 kernels. Updated and got it working quite well. But there is minor problem. With Zynaddsubfx I get occasional snaps and pop without jack reporting xruns. I haven't tried tweaking ethernet settings. That's what I'm going to try next. Can't force usb to 1.1 since this is a 2.0 device.
That's good news for Zoom R16 owners! But do try to tweak or disable ethernet, USB2 audio interfaces probably need more bandwidth so you should try to free as much as possible.
JaniF wrote:The R16 was powered directly from Pi's usb port without included power supply.
You might want to try to power the R16 with an external power supply, I'm curious to hear if that would make any difference.
RPi and real-time, low-latency audio: http://wiki.linuxaudio.org/wiki/raspberrypi
RPi audio repository: http://rpi.autostatic.com/
RPi and audio blog: https://autostatic.com/tag/raspberrypi/

User avatar
AutoStatic
Posts: 326
Joined: Tue Jan 01, 2013 10:27 pm
Contact: Website

Re: RPi and real-time, low-latency audio

Wed Mar 16, 2016 8:16 pm

Synthberry wrote:Thanks for creating the Wiki page - very helpful stuff. Am well on the way to getting some nice synth code running on the Pi 3 as a result.
Awesome! Got my Pi3 in last week too :)
RPi and real-time, low-latency audio: http://wiki.linuxaudio.org/wiki/raspberrypi
RPi audio repository: http://rpi.autostatic.com/
RPi and audio blog: https://autostatic.com/tag/raspberrypi/

JaniF
Posts: 4
Joined: Mon Mar 07, 2016 5:31 am

Re: RPi and real-time, low-latency audio

Thu Mar 17, 2016 9:23 am

AutoStatic wrote:That's good news for Zoom R16 owners! But do try to tweak or disable ethernet, USB2 audio interfaces probably need more bandwidth so you should try to free as much as possible.
I disabled ethernet but it really made not much difference. I noticed that those clicks and pops might be just running out of cpu power. They occur when activating a window etc.
AutoStatic wrote:You might want to try to power the R16 with an external power supply, I'm curious to hear if that would make any difference.
This is my second time I'm using my R16 as an audio interface and didn't realize that it really requires to plug in the PSU. Last time I removed it after boot and it worked but the R16 wont power up if it get's no external power. So you might just leave it in.

OT, I've included a 16x4 non-backlit LCD in the same case I've put the RPI2 together with midi-in circuitry. It could be fun to get some information out of zynaddsubfx or other synth to the LCD but I've run out of ideas. What information would be usefull and is this even possible?

EDIT: Just figured out that to get yoshimi working with R16 and alsa you must use command

yoshimi -a --alsa-audio=plughw:R16

to get sample format conversion.

User avatar
AutoStatic
Posts: 326
Joined: Tue Jan 01, 2013 10:27 pm
Contact: Website

Re: RPi and real-time, low-latency audio

Thu Mar 17, 2016 12:49 pm

JaniF wrote:I disabled ethernet but it really made not much difference. I noticed that those clicks and pops might be just running out of cpu power. They occur when activating a window etc.
:( Then you might benefit from using a real-time kernel.
JaniF wrote:This is my second time I'm using my R16 as an audio interface and didn't realize that it really requires to plug in the PSU. Last time I removed it after boot and it worked but the R16 wont power up if it get's no external power. So you might just leave it in.
So that doesn't make a difference either :(
JaniF wrote:OT, I've included a 16x4 non-backlit LCD in the same case I've put the RPI2 together with midi-in circuitry. It could be fun to get some information out of zynaddsubfx or other synth to the LCD but I've run out of ideas. What information would be usefull and is this even possible?
That should be possible, check out the [url=htttp://zynthian.org/]Zynthian[/url] project and I also blogged a bit about it at https://autostatic.com/tag/zynaddsubfx/
RPi and real-time, low-latency audio: http://wiki.linuxaudio.org/wiki/raspberrypi
RPi audio repository: http://rpi.autostatic.com/
RPi and audio blog: https://autostatic.com/tag/raspberrypi/

hngjms
Posts: 1
Joined: Tue Mar 29, 2016 9:33 pm

Re: RPi and real-time, low-latency audio

Tue Mar 29, 2016 9:37 pm

I'm trying to get audio streaming working on the raspberry pi and so far ffmpeg and gstreamer have been disapointing.
Jack Audio seems very promising for me: rerouting an input mic to output speaker on the sound card level seems to be almost instantaneous for me on a single raspberry pi.

I've been trying to get NetJack to work though, to stream audio from one raspberry pi to another. However, I've been having trouble getting audio. I've posted a question on stackoverflow to but I figured I would try this thread too.

http://stackoverflow.com/questions/3627 ... g-over-lan

Any advice would be appreciated.

RpiName
Posts: 713
Joined: Sat Jul 06, 2013 3:14 am

Re: RPi and real-time, low-latency audio

Sun Apr 03, 2016 10:33 pm

hngjms wrote:Any advice would be appreciated.
Try UV4L for low-latency audio, optionally 2-way audio, optionally with (optionally 2-way) video between any rpi's and/or browsers,smartphones,etc.. (p2p, 1->many, many<->many)

http://linux-projects.org

trondis23
Posts: 42
Joined: Mon May 21, 2012 11:55 am

Re: RPi and real-time, low-latency audio

Wed Apr 20, 2016 10:46 am

I was wondering if this page http://wiki.linuxaudio.org/wiki/raspberrypi is still up to date. I have tried to follow the instructions line by line, but get some errors. On the latest Jessie Qjackctl is installed by default, so I guess that it is not necessary to install it again. But whether it works or not seems to be a hit and miss. I have one SD card where it works perfectly, but when I tried setting up another card from a clean Jessie install, I get no audio. Alsa works, but not Jack with the same settings as on the working card. And any changes I try in Qjackctl has no effect.

I am having great fun testing different soft synths. I am following step by step instructions found on different sites. Some works and some not. When Jack works there are lots of options. Carla works, but I think it is very slow. Ghostess with dssi plugins is a lot faster.

Return to “Graphics, sound and multimedia”