bastibe / SoundCard

A Pure-Python Real-Time Audio Library
https://soundcard.readthedocs.io
BSD 3-Clause "New" or "Revised" License
680 stars 69 forks source link

Added index search for get_microphone() #125

Open yuannan opened 3 years ago

yuannan commented 3 years ago

as stated by the docs:

Parameters: | id (int or str) – can be an int index, a backend id, a substring of the speaker name, or a fuzzy-matched pattern for the speaker name.

This is not true and caused me to bash my face on my computer for all of last night before I thought it could be an upstream issue. Please merge this. Thanks.

yuannan commented 3 years ago

There is a minor bug with this implementation, sound card IDs change and are not static. This could lead to issues if cards are changed around such as unplugging and plugging a device.

This could be fixed by redefining source_list() as a properly indexed list with the index matching up with the sink number. This could lead to more memory usage but this is at most a few array elements. I'm happy to make this patch as well if you don't want to. I'm just worried that changing this around would mess up your other code.