Lowering buffer on rpi4

Dear All,

I´ve just installed Ardour 6.3 on a raspberry pi 4 2GB running Raspbian Buster 64-bit (Debian), and managed to get sound from it with my midi keyboard connected via USB and the rpi4 onboard sound.
However, the latency is not as low as I want it, and when trying to change from 512 samples to the lowest possible, being 256, I get this message:

As you can see, I´m simply using ALSA, and I understand that using JACK will not improve anything on the latency parameter. I did try though, but Ardour crashes as soon as I select JACK.

So does anybody have any ideas about how I can make Ardour accept 256 samples, and perhaps even make 128 samples available?

Thanks in advance!

But why? You have a playback only device. Latency does not matter at all. You only need a low buffersize to minimize input -> output delay (e.g. when mixing or recording live with effects).

HDMI doesn’t usually work well at all below 1024 fpp and often also only at 48KHz. I suggest to run at 1024 or 2048 fpp, which also requires less CPU power, which is good for an under-powered system such as the RPi.

Other than that you need a proper soundcard.

A hifiberry.com is pretty good quality that can run at 64fpp, many USB soundcards can also go that low, but you’ll need to optimize the system (realtime kernel, various system tweaks) in order to get it running reliably. – Then again, don’t expect wonders.

I´m not sure if I put my words in a not so clear way, but the reason why I want to have low latency is because I want to hear the sound that I play on my midi keyboard as instantly as possible, and that´s when using softsynths e.g. Ardours builtin GM-synths (perhaps this is what I should have mentioned). My needs are nothing heavy, just to have an option in the living room to play some keyboard and record whenever good ideas pop up. I do have some workhorse DAWs elsewhere in the house.
As far as I can see, others have success achieving low latency with their RPI4 without additional hardware, but there´s not a lot of info on how they got there. 512 samples worked fine with the HDMI-cable wired to my stereo, but still I´d like to know how to get Ardour to accept 256 and see how that goes.

The thing is, it isn’t a matter of Ardour ‘accepting’ lower buffer sizes, the message you are seeing is that Ardour tried to open your audio device with those settings, but your audio device did not open. This is an issue between your audio device and ALSA actually. As @x42 indicated, a HDMI port may not work with a lower buffer size, which would be a limitation of the hardware, and as a result ALSA simply won’t ever open the device with the lwoer buffer size, there is no way to do it.

Ardour itself will use whatever the lower level audio stack provides, be it ALSA, Jack, whatever. In the Audio Setup dialog all you are doing is requesting that low level stack try to access the hardware, and if the low level stack can’t access the hardware with the requested parameters you will see a message like that.

 Seablade

Thanks Seablade, gotcha!
In fact the same message appears when I just try to send to the 3,5 mm jack, so it´s not about the HDMI.
Anyway, perhaps I should do as suggested earlier, go for a hifiberry. I guess this would do with a coax-cable, right?

https://www.hifiberry.com/shop/boards/hifiberry-digiplus-standard-version/

I’ve used the hifiberry boards on RPi3, and had very good results (in fact I have one connected to my network running RuneAudio as a general networked audio player). On the early RPi boards the onboard 3.5mm DAC output was just some 11 or 12Bit thing IIRC - I’m not even sure if it was intended for proper audio other than squeaks and bleeps (it just about works for some 8bit game emulators but I could never get it working well enough for audio). I haven’t had much time to experiment with the Pi4 so that might be a lot better, but I would think the hifiberry board is the way to go. If you do go with the hifiberry, be aware that the one you linked to is the digital version - you would need an external S/PDIF compatible DAC to turn its output into analogue audio. There is an alternative -

https://www.hifiberry.com/shop/boards/hifiberry-dac-pro/
or
https://www.hifiberry.com/shop/boards/hifiberry-dacplus-rca-version/

Which provide analogue audio out on standard RCA / Phono connectors that you could connect to a mixer or amp + speakers

Thanks mike,

I actually chose that one because my amp´s got digital inputs, and I need to run 8 m of cable over to it from the raspberry. That won´t sound pretty with analog cables, so I´d say it´s alot better going digital in my case.

Btw, such a board as the one I mentioned will fit into a standard rpi4 case right, and with no PSU of its own?

The DAC board takes its power from the RPi so you don’t need to provide it with a separate power connection - you would need to check if the case you intend using is compatible since it has to accommodate the extra RCA connectors etc. I used the RPi3 version of this one:

https://www.hifiberry.com/shop/cases/steel-case-for-hifiberry-dac-pi-4/

Thanks Mike, so will it not work with this one?

https://www.raspberrypi.org/products/raspberry-pi-4-case/

And, do you think 8 m of coaxial or toslink is the better option?

I’ve only used the DAC, with the case I mentioned, so with the two RCA connectors for analogue out, but looking at the picture of the digi+ board I would assume the same mechanical issues arise with the single RCA S/PDIF connector, specifically that it doesn’t appear the official Pi case would be compatible without modification (and the internal dimensions likely don’t allow enough room for the body of the RCA connector(s) mounted on the board).

Either coax or optical should be fine with a good quality interconnect - though at 8m you are getting close to the normally quoted maximum (IIRC, S/PDIF is usually quoted as being good for 10m with a decent cable, similar for TOSLink), but as the board seems to support either, assuming your amp is compatible, you can try either option

Thanks, I guess I better be on the safe side and get a case to fit my pi and the hifiberry together then. I read a bit about cable lengths, and it seems that optical is more critical on the length, so I´ll go for RCA S/PDIF. Thanks again for all your help!

Edit: Nope, looking across shops, I see only up to 5 meters of RCA for this purpose, where as 10 meter of optical seems easy to get so that oughtta be for a reason…

Hi again, got myself a hifiberry and things are up and running!
I do however get crackles on 64 samples buffer size, with just one GM-piano sound, an EQ and a reverb.
So I´m wondering if you´re using a particular low latency OS? I googled and found a couple of them promising that, but would rather not have to go through all. I also understand that there are some tweaks which can be made to the system, that I´ll be playing around with.
I´m on 64-bit buster beta.

For live performances, perhaps check out http://zynthian.org/ – they provide an ISO image with realtime-kernel.

As for tweaking debian/buster, a first step would be to install the rtirq-init package (to prioritize the soundcard driver/IRQ).

…and unless you have already done so grant your user permissions to run processes with rt-priority. The easiest way to do that on debian is to install jack and/or re-configure an already installed jack: sudo dpkg-reconfigure -p high jackd2, enable rt, and then re-login (or reboot).

Thank you Robin,

Gotta look into Zynthian then - if that´s a distro for RPI4 that I can add stuff into (XRDP and of course Ardour are musts at my end) then that´s probably the way to go.
I´m still struggling to get anything going with jack, so I´ll look for other ways to realtime priority…

Does not 128 frames settings work? That may depend on your feeling but up to 256 it must be playable without noticing that much delay , or maybe am i auto offsetting without noticing it?

Hi Sahaathyva,

I was thinking that 128 would be fine, but I do feel the latency at that setting. It´s a bit weird, cause I think I work with a higher buffer on my Hammerfall card on Windows, where I don´t have any problems. Could it be that it´s the DA-converter in my 10 year old Onkyo amp that´s actually adding latency?

Possible, i dont know if ardour arm can do latency measure.

Would be nice to compare this setting systemic latency to another system with the same buffersize and frequency settings :wink:

@128 i feel 0 problem about latency beetween my midi kb and the output of the synths

According to Ardour I get 2,9 ms - usually that´d be very sufficient for me…

Ardour displays the process-block size.

input to output is at least twice that. Hard to say how large the systemic latency of the hifiberry + S/PDIF is. Since it’s playback only there is also no way to measure round-trip latency to establish that.

RME devices play in different league.

Allright, I guess that I´ll see if I can go 64 samples with Zynthian then on just a gm-sound and reverb without crackles… or I´ll need to get an analogue hifiberry and some long cable of a good quality for it…