Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latency 30mSec #524

Open
RezaYazdi604 opened this issue Mar 5, 2024 · 9 comments
Open

Latency 30mSec #524

RezaYazdi604 opened this issue Mar 5, 2024 · 9 comments

Comments

@RezaYazdi604
Copy link

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.

@mgeier
Copy link
Member

mgeier commented Mar 6, 2024

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.

@RezaYazdi604
Copy link
Author

RezaYazdi604 commented Mar 6, 2024 via email

@RezaYazdi604
Copy link
Author

RezaYazdi604 commented Mar 6, 2024 via email

@RezaYazdi604
Copy link
Author

RezaYazdi604 commented Mar 12, 2024 via email

@mgeier
Copy link
Member

mgeier commented Mar 13, 2024

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?

@RezaYazdi604
Copy link
Author

RezaYazdi604 commented Mar 14, 2024 via email

@mgeier
Copy link
Member

mgeier commented Mar 14, 2024

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?

@RezaYazdi604
Copy link
Author

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

@mgeier
Copy link
Member

mgeier commented Mar 20, 2024

yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants