"Name" Is Cut In sounddevice.query_devices(device=None, kind='output')
I have a question on stackoverflow https://stackoverflow.com/q/65877612
When I run:
import sounddevice as sd
speaker = sd.query_devices(device=None, kind='output')
speaker = speaker["name"]
print(speaker)
it cuts off the end of it.
For example:
My speaker is:
Altavoces(High Definition Audio Device)
but
print(speaker)
returns:
Altavoces(High Definition Audi
When you cross-post questions, please include links in both directions.
Here's the link to SO: https://stackoverflow.com/q/65877612/ (I assume this is from you, right?)
Regarding your question:
The sounddevice module gets the device name from the underlying PortAudio library like this:
https://github.com/spatialaudio/python-sounddevice/blob/f063cd1b427b90907a671a7be4427f6c2290914c/sounddevice.py#L562-L580
I might be mistaken, but I don't see a possibility here that the name would be cut. I also don't think that CFFI cuts the name.
I assume the shortened name is all we get from PortAudio, so we would have to continue investigating there.
The latest PortAudio release if quite a few years old, so it is possible that this has been fixed in the meantime in the development version.
Either way, would you like to ask your question at https://github.com/PortAudio/portaudio?
Here's the link to SO: https://stackoverflow.com/q/65877612/ (I assume this is from you, right?)
Yes, I will edit the question here and on stackoverflow.
Either way, would you like to ask your question at https://github.com/PortAudio/portaudio?
Yes, Please.
The latest PortAudio release if quite a few years old, so it is possible that this has been fixed in the meantime in the development version.
I will try to get the development version working, and will keep you posted.
Either way, would you like to ask your question at https://github.com/PortAudio/portaudio?
Yes, Please.
Feel free to open an issue over there!
Not exactly certain about the answer. When I get the sound devices by using 'python -m sounddevice' it looks like the names are proper:
$ python -m sounddevice
0 HDA Intel PCH: ALC892 Digital (hw:0,1), ALSA (0 in, 2 out)
1 HDA Intel PCH: HDMI 0 (hw:0,3), ALSA (0 in, 8 out)
2 HDA Intel PCH: HDMI 1 (hw:0,7), ALSA (0 in, 2 out)
3 HDA Intel PCH: HDMI 2 (hw:0,8), ALSA (0 in, 8 out)
4 HDA Intel PCH: HDMI 3 (hw:0,9), ALSA (0 in, 8 out)
5 HDA Intel PCH: HDMI 4 (hw:0,10), ALSA (0 in, 8 out)
6 iec958, ALSA (0 in, 2 out)
7 spdif, ALSA (0 in, 2 out)
8 hdmi, ALSA (0 in, 8 out)
9 pulse, ALSA (32 in, 32 out)
* 10 default, ALSA (32 in, 32 out)
When you look at the names returned by sounddevice.query_devices:
HDA Intel PCH: ALC892 Digital (hw:0,1)
HDA Intel PCH: HDMI 0 (hw:0,3)
HDA Intel PCH: HDMI 1 (hw:0,7)
HDA Intel PCH: HDMI 2 (hw:0,8)
HDA Intel PCH: HDMI 3 (hw:0,9)
HDA Intel PCH: HDMI 4 (hw:0,10)
...
Notice that ALSA.. at the end is cutoff. But the SoundDevice is getting the longer name along with the index. (Another inconvenient issue is that the index is not returned by query_devices. I could not find a good way to get the index, other than constructing the index from the order of the devices returned by query_devices()) Thank you for your comments..
Each line of the string representation of the result of query_devices() (which is also shown with python -m sounddevice) contains the device name and the corresponding host API (and even more stuff).
See the "Examples" section in https://python-sounddevice.readthedocs.io/en/0.4.4/api/checking-hardware.html#sounddevice.query_devices: "After the device ID and the device name, the corresponding host API name is displayed. In the end of each line, the maximum number of input and output channels is shown."
The , ALSA part is not part of the device name, just as (0 in, 2 out) isn't.
Another inconvenient issue is that the index is not returned by query_devices.
See #403.