spatialaudio / python-sounddevice

:sound: Play and Record Sound with Python :snake:
https://python-sounddevice.readthedocs.io/
MIT License
1.06k stars 149 forks source link

Setting latency returns unexpected result #280

Open wilsco opened 4 years ago

wilsco commented 4 years ago

Hi,

The following code produces an unexpected result.

import sounddevice as sd
sd.Stream(channels=1,latency=(0.1,0.1)).latency

returns :

(0.014512471655328799, 0.10158730158730159)

I would not have been as surprised if it returned a latency longer than the desired input latency, but why would the first value be so much smaller than 0.1?

The devices being used are:

   0 Microsoft Sound Mapper - Input, MME (2 in, 0 out)
>  1 Microphone Array (Realtek High , MME (2 in, 0 out)
   2 Microsoft Sound Mapper - Output, MME (0 in, 2 out)
<  3 Speaker/HP (Realtek High Defini, MME (0 in, 2 out)
mgeier commented 4 years ago

Can you try some more extreme values to check if the returned values change at all? Can you try different values for input and output?

There might be a bug in the sounddevice module mixing up inputs and outputs (or something like that), but it might also simply be the behavior of the PortAudio library.