Closed gonzalocasas closed 5 years ago
There is indeed a way, and it is exactly what you thought: record(numframes=None)
will return whatever is currently buffered without waiting for a buffer to fill.
At least on Linux, we have a latency
attribute, which should be useful for syncing streams. This is entirely up to the backend system, though, and I have no idea how reliable these numbers are across sound cards.
@bastibe thanks for the reply! I'll give it a try and report here!
btw...there is no example on using numframes=None
, is there?
Only in the documentation.
But... pull requests are welcome!
In the end, I resorted to hardware support instead, using the loopback of the mic, so then it's not so relevant when the record starts (in a different thread/process), because the precise synchronization can be done based on the loopback channel. So, I think this issue could be closed.
Good to know. Thank you for following up on this!
Is it possible to playback audio and record it simultaneously? I didn't find a non-blocking way to call .
record()
(except perhaps passingNone
tonumframes
?) so that I can start playing back sound after the recording is active. For context, I want to playback a sweep signal and record it to later on calculate the impulse response and do some processing, I initially usedthreading
(and thenmultiprocessing
) with athreading.Event
to sync them, but identical playback/recording sessions have slight different, non-deterministic offsets in the range of +/-10ms.I am running this on Linux with Python 3.6.7, and
soundcard=0.2.2
.Is there a way to achieve this directly on
soundcard
without resorting to threading or other ways to parallelize?Thanks!!