Systematic-LEDs
Systematic-LEDs copied to clipboard
Fix Method Usage
tl;dr
There might have been a mix up with the following available API calls
get_device_info_by_index(device_index)
get_device_count()
get_host_api_count()
get_host_api_info_by_index(host_api_index)
get_device_info_by_host_api_device_index(host_api_index, host_api_device_index)
The incorrect method was being used for finding the device which led to an IndexError. Since we're attempting to add all of the devices, we should be using the method 'get_device_info_by_index` which will properly fetch the amount of devices we have.
This issue was also raised in #47 and #53
Issue
Run PyAudio().get_default_host_api_info()
Windows 10
{'index': 0, 'structVersion': 1, 'type': 2, 'name': 'MME', 'deviceCount': 5, 'defaultInputDevice': 1, 'defaultOutputDevice': 3}
>>> for i in range(py_audio.get_device_count()):
... device_info = py_audio.get_device_info_by_host_api_device_index(0, i)
... print(device_info)
...
{'index': 0, 'structVersion': 2, 'name': 'Microsoft Sound Mapper - Input', 'hostApi': 0, 'maxInputChannels': 2, 'maxOutputChannels': 0, 'defaultLowInputLatency': 0.09, 'defaultLowOutputLatency': 0.09, 'defaultHighInputLatency': 0.18, 'defaultHighOutputLatency': 0.18, 'defaultSampleRate': 44100.0}
{'index': 1, 'structVersion': 2, 'name': 'VoiceMeeter Output (VB-Audio Vo', 'hostApi': 0, 'maxInputChannels': 8, 'maxOutputChannels': 0, 'defaultLowInputLatency': 0.09, 'defaultLowOutputLatency': 0.09, 'defaultHighInputLatency': 0.18, 'defaultHighOutputLatency': 0.18, 'defaultSampleRate': 44100.0}
{'index': 2, 'structVersion': 2, 'name': 'Microsoft Sound Mapper - Output', 'hostApi': 0, 'maxInputChannels': 0, 'maxOutputChannels': 2, 'defaultLowInputLatency': 0.09, 'defaultLowOutputLatency': 0.09, 'defaultHighInputLatency': 0.18, 'defaultHighOutputLatency': 0.18, 'defaultSampleRate': 44100.0}
{'index': 3, 'structVersion': 2, 'name': 'VoiceMeeter Input (VB-Audio Voi', 'hostApi': 0, 'maxInputChannels': 0, 'maxOutputChannels': 8, 'defaultLowInputLatency': 0.09, 'defaultLowOutputLatency': 0.09, 'defaultHighInputLatency': 0.18, 'defaultHighOutputLatency': 0.18, 'defaultSampleRate': 44100.0}
{'index': 4, 'structVersion': 2, 'name': 'Speakers (Realtek High Definiti', 'hostApi': 0, 'maxInputChannels': 0, 'maxOutputChannels': 8, 'defaultLowInputLatency': 0.09, 'defaultLowOutputLatency': 0.09, 'defaultHighInputLatency': 0.18, 'defaultHighOutputLatency': 0.18, 'defaultSampleRate': 44100.0}
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "D:\Programs\Anaconda\envs\esp\lib\site-packages\pyaudio.py", line 852, in get_device_info_by_host_api_device_index
host_api_device_index)
OSError: [Errno -9996] Invalid device
Looking into the docs further, we see that the Invalid device
error is described as
A paInvalidDevice error code indicates that the hostApiDeviceIndex parameter is out of range.
source: portaudio docs
If I do PyAudio().get_device_count()
, it lists 13 devices! That's way more than I have when I checked it using PyAudio().get_default_host_api_info()
and PyAudio().get_host_api_count()
which lists 2.
So what this means is if I try PyAudio().get_device_info_by_host_api_device_index(0,index)
, I will always have an index error because the host only has 2 while I have 13 devices in total on my setup. Sometimes this will work seamlessly for people because their rig has the same amount of devices as their PortAudio Host APIs count.
The fix is to simply swap out the method call to get_device_info_by_index(device_index)
Thank you! But now I get this error..:(
(RGB) bash-3.2$ python main.py No user colours found No user gradients found Traceback (most recent call last): File "main.py", line 1263, in set_mic microphone.setDevice(mic_button_group.checkedId()) File "main.py", line 858, in setDevice self.device_id = self.devices[device_id]["index"] IndexError: list index out of range Abort trap: 6 (RGB) bash-3.2$
Try adding this line of code in #53
I will try when Im at home. By the way do I need to edit just main.py file or also .gitignore file? Its shown here: https://github.com/not-matt/Systematic-LEDs/pull/71/commits/29d3dc9a29620fed0ca750d592e178aa1e6fee61
I just modify main.py, does it work for you?
On Tue, Feb 5, 2019, 7:58 AM Andriejus <[email protected] wrote:
I will try when Im at home. By the way do I need to edit just main.py file or also .gitignore file? Its shown here: 29d3dc9 https://github.com/not-matt/Systematic-LEDs/commit/29d3dc9a29620fed0ca750d592e178aa1e6fee61
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/not-matt/Systematic-LEDs/pull/71#issuecomment-460646914, or mute the thread https://github.com/notifications/unsubscribe-auth/As6sG-zrXk6uWc2tgv7IliIaFxH3roOfks5vKY4bgaJpZM4agS_L .
It worked for me. Now Im able to choose not only microphone or built-in input. But if I make some changes in sound settings on my computer (like disabling microphone), so it crashes. I think you should set your sound settings right before you launch main.py. I played with sound settings and if microphone was disabled, so I couldnt run main.py (it crashes with syntax error). Im trying to find out how to set audio settings right in order to play music from my computer. Now Im able to use it only with microphone. Tried to use program "soundflower", but Im not sure how to use it:) I need to watch some tutorials.
Let me know your right audio configuration men, we can do the same to see if that's the problem
On Wed, Feb 6, 2019, 2:57 AM Andriejus <[email protected] wrote:
It worked for me. Now Im able to choose not only microphone or built-in input. But if I make some changes in sound settings on my computer (like disabling microphone), so it crashes. I think you should set your sound settings right before you launch main.py. I played with sound settings and if microphone was disabled, so I couldnt run main.py (it crashes with syntax error). Im trying to find out how to set audio settings right in order to play music from my computer. Now Im able to use it only with microphone. Tried to use program "soundflower", but Im not sure how to use it:) I need to watch some tutorials.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/not-matt/Systematic-LEDs/pull/71#issuecomment-460946526, or mute the thread https://github.com/notifications/unsubscribe-auth/As6sG66fz8csfVBMgwccpMwsw3jBj8fIks5vKpj_gaJpZM4agS_L .
Its working now for me. Here are screenshots of my audio configuration:
Thank you sir, I'll check that out!
On Wed, Feb 6, 2019, 2:46 PM Andriejus <[email protected] wrote:
Its working now for me. Here are screenshots of my audio configuration: [image: screen shot 2019-02-06 at 9 40 10 pm] https://user-images.githubusercontent.com/38490002/52372432-75999980-2a58-11e9-8d46-7e62b83e830a.png [image: screen shot 2019-02-06 at 9 39 12 pm] https://user-images.githubusercontent.com/38490002/52372433-75999980-2a58-11e9-9eb8-b8b309625c79.png [image: screen shot 2019-02-06 at 9 41 18 pm] https://user-images.githubusercontent.com/38490002/52372482-9366fe80-2a58-11e9-92cf-490da6845caf.png [image: screen shot 2019-02-06 at 9 39 33 pm] https://user-images.githubusercontent.com/38490002/52372483-9366fe80-2a58-11e9-9577-a795838224dd.png [image: screen shot 2019-02-06 at 9 40 10 pm] https://user-images.githubusercontent.com/38490002/52372485-9366fe80-2a58-11e9-989a-852688dfe71e.png
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/not-matt/Systematic-LEDs/pull/71#issuecomment-461180832, or mute the thread https://github.com/notifications/unsubscribe-auth/As6sG8eqxxfEPO_vN7CN-yhvXD4sGma1ks5vKz8QgaJpZM4agS_L .