Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

index out of range error (might be related to #47) #53

Closed
gaijinsr opened this issue Nov 22, 2018 · 8 comments
Closed

index out of range error (might be related to #47) #53

gaijinsr opened this issue Nov 22, 2018 · 8 comments

Comments

@gaijinsr
Copy link

Hi,
running on Ubuntu 18.04, without jackd running (audio-reactive-led-strip works great like this, btw), I get

Systematic-LEDs/python$ python3 main.py 
Could not find settings.ini
No user colours found
No user gradients found
QApplication: invalid style override passed, ignoring it.
ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Traceback (most recent call last):
  File "main.py", line 2046, in <module>
    microphone = Microphone(microphone_update)
  File "main.py", line 847, in __init__
    self.setDevice(self.default_device_id)
  File "main.py", line 858, in setDevice
    self.device_id = self.devices[device_id]["index"]
IndexError: list index out of range

With jackd running, I get

Systematic-LEDs/python$ python3 main.py 
Could not find settings.ini
No user colours found
No user gradients found
QApplication: invalid style override passed, ignoring it.
ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
Cannot lock down 82280346 byte memory area (Cannot allocate memory)
Traceback (most recent call last):
  File "main.py", line 2046, in <module>
    microphone = Microphone(microphone_update)
  File "main.py", line 842, in __init__
    device_info = py_audio.get_device_info_by_host_api_device_index(0,i)
  File "/usr/lib/python3/dist-packages/pyaudio.py", line 852, in get_device_info_by_host_api_device_index
    host_api_device_index)
OSError: [Errno -9996] Invalid device

and the window freezes and uses 100% CPU. Any idea what is happening here?

By the way, I patched audio-reactive-led-strip to send output in the format of Systematic-LEDs
because I have a WS2811 strip and some WS2801 strips that are not supported by the libraries
used in the ESP8266 code in audio-reactive-led-strip. Tell me if you are interested in the code
(I did not post it because I thought you consider audio-reactive-led-strip dead.)

@kennerblick
Copy link

i have the same error, with clean ubuntu 16.04, install all dependencies, clean git clone, same error

@lpearl
Copy link

lpearl commented Jan 27, 2019

@gaijinsr I got it working on my pi3, I was getting the same error as you and I made a few changes to make it work for me (My setup does differ as I'm using rasparian and shairport-sync as an input).
add after line 257 in main.py

for i in range(len(self.devices)):
    if self.devices[i]['index'] == device_id:
        device_id = i
        break

let me know if that works.

@gaijinsr
Copy link
Author

@lpearl: Great, I'd like to try this, but are you sure about the line number? In my main.py, c.f.
https://github.com/not-matt/Systematic-LEDs/blob/master/python/main.py
the code around line 257 is about updating the LED strip... Can you post the context of your patch?

@lpearl
Copy link

lpearl commented Jan 28, 2019

@gaijinsr My bad I meant after 857. From what I could tell when looking at the code it's trying to pick a device on the list of devices with an index of x (x being whatever index the device chosen is). x is in a list and instead of picking the position the device is in (in the list), it asks for the index at a position of the index which makes no sense. so adding that code should fix it. There is definitely a more efficient way of fixing it but I don't want to delete any of the code that's already there.

@andrealbers
Copy link

andrealbers commented Jan 29, 2019

@lpearl Didn't work for me. Any advice?

 def setDevice(self, device_id):
        # set device to stream from by the id of the device
        if not device_id in range(0,self.numdevices):
            raise ValueError("No device with id {}".format(device_id))
        for i in range(len(self.devices)):
            if self.devices[i]['index'] == device_id:
                device_id = i
                break
        self.device_id = self.devices[device_id]["index"]

@lpearl
Copy link

lpearl commented Jan 30, 2019

@gaijinsr What error did you get? How are you giving the devices an audio input? What system are you running Ubuntu on?

@gaijinsr
Copy link
Author

@lpearl Great, this worked for me!!
I am running Bionic on several different x86 machines, the result was always the same.
BTW: When I copy the directory with the patched file from one machine to another, the program crashes due to the different audio device structure. Deleting settings.ini helps.

@richyxi
Copy link

richyxi commented Feb 3, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants