spatialaudio / python-sounddevice

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

Asking for a feature of the callback #358

Open rako233 opened 2 years ago

rako233 commented 2 years ago

To write the code in an OOP style, I had a problem to inject a queue into the callback. I did this with a closure with success.

But the success ended when using sounddevice with multiprocessing.process. I could use the callback when the callback was a static method without the wrapper of the closure. This lacks of course a reference to a queue.

So my proposal is to add a parameter for the callback, providing a python reference for a queue or another object instance, which can be provided by instancing a Stream.

mgeier commented 2 years ago

Can you please give a minimal example where a closure cannot be used?

This can either be a broken example with the current API or a fictitious example with the suggested new API.