Latency 30mSec
RezaYazdi604 opened this issue · 10 comments
Hi there,
I'm currently using sounddevice together with SamplerBox on a RPI device. I'm measuring about 30mSec latency from the time I hit a note until the note is played on the speaker. I was wondering if there's a way to reduce this latency. Reading PortAudio documentation, it's mentioned there is a way to reduce the latency to 10mSec but I don't know how to do that? The audiocallback() is called every 8mSec. Is there anyway to make this faster? The buffer size is 384 but I have tried lowering that and it didn't help.
I appreciate any help in this regards.
From PortAudio website
Unix
PortAudio under Unix currently uses a backgroud thread that reads and writes to OSS. This gives you decent but not great latency. But if you raise the priority of the background thread to a very priority then you can get under 10 milliseconds latency. In order to raise your priority you must run the PortAudio program as root! You must also set PA_MIN_LATENCY_MSEC using the appropriate command for your shell.
Which buffer sizes did you try? Did you try powers of 2?
There is a PortAudio test program called pa_minlat
, maybe that gives some insights?
Did you try setting blocksize=0
and varying latency
?
PortAudio under Unix currently uses a backgroud thread that reads and writes to OSS.
OSS is an audio backend that hasn't really been used for decades. I guess you are using ALSA?
You must also set PA_MIN_LATENCY_MSEC
That's something I have never heard before, and if you search for it in the PortAudio source code, it only appears in the file https://github.com/PortAudio/portaudio/blob/master/src/hostapi/dsound/pa_win_ds.c, which is irrelevant for Linux.
if you had a chance to see my feedback
Yeah, I've seen it, it's kinda hard to read. Can you try formatting it a bit nicer?
Please let me know if it's good or not.
Still not great.
Maybe you should use the web interface instead of replying by e-mail.
Did you try pa_minlat
?
Hi Mathias,
I have not tried the pa_minlat yet. Are you referring to this? --> https://portaudio.com/docs/v19-doxydocs-dev/pa__minlat_8c.html#details
yes.
Closing due to lack of response.