belangeo / pyo

Python DSP module
GNU Lesser General Public License v3.0
1.28k stars 130 forks source link

Improving Input latency #198

Closed giorgioguttilla closed 3 years ago

giorgioguttilla commented 3 years ago

I'm working on a script that needs responsive input from the microphone (on windows), and am encountering about a half second of delay using the pyo.Input class. This happens both with my default computer soundcard and a Samson C-01 USB microphone. The processing I am attempting to do after receiving input is extremely fast, so it is likely not a problem with CPU speed. Here is a simple example of what I'm trying to do:

`from pyo import *

s = Server(duplex=1, buffersize=512, audio='pa') s.amp = 0.1 s.boot().start()

a = Input(chnl=1).play().out()

s.gui(locals())`

I tried adjusting buffer size, but nothing seems to affect it. Is this just a problem with my soundcard? Thanks!

belangeo commented 3 years ago

By default, pyo uses DIRECTSOUND driver to talk with soundcards, only because it is the most "configuration friendly"! If you are willing to tweak your system, I suggest to take a look at this page in the doc which explain how to use more performant driver like WASAPI or wdm-ks:

http://ajaxsoundstudio.com/pyodoc/winaudioinspect.html

After that, try to reduce the buffer size until you get drop outs, the lower the buffer size, the lower the latency!

ghost commented 3 years ago

Thank you! After doing some research and testing on another computer I realized it’s mostly my poor sound card. Buffer size does help to a degree as well. Appreciate it!

stripwax commented 3 years ago

Out of interest, is ASIO supported (e.g. in conjunction with ASIO4ALL)?

On Thu, 5 Nov 2020, 17:32 Olivier Bélanger, notifications@github.com wrote:

By default, pyo uses DIRECTSOUND driver to talk with soundcards, only because it is the most "configuration friendly"! If you are willing to tweak your system, I suggest to take a look at this page in the doc which explain how to use more performant driver like WASAPI or wdm-ks:

http://ajaxsoundstudio.com/pyodoc/winaudioinspect.html

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/belangeo/pyo/issues/198#issuecomment-722525670, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABF47HDCLORYHKPGW66MXYTSOLOTTANCNFSM4TLR6JRA .

giorgioguttilla commented 3 years ago

I tried to install ASIO4ALL and set audio='asio' but pyo wasn't able to detect it. I might have done somethin wrong in the installation though, I've never used ASIO before.

belangeo commented 3 years ago

Run

from pyo import *
pa_list_host_apis()
pa_list_devices()

to discover what you need to give to the server in order to use ASIO4ALL.

Audio setup functions are documented here:

http://ajaxsoundstudio.com/pyodoc/api/functions/audio.html

belangeo commented 3 years ago

ASIO support is now back in version 1.0.4.