Pygame midi ALSA call fails

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
Post Reply
JFitz
Level 1
Level 1
Posts: 6
Joined: Tue May 07, 2019 6:30 am

Pygame midi ALSA call fails

Post by JFitz » Sun Oct 20, 2019 10:43 am

Trying to use pygame midi in Python3 and the call to midi.init() fails (as below). The sound works fine in browsers and media players etc. Is there a problem with ALSA?

Code: Select all

Linux john-System 4.15.0-65-generic #74~16.04.1-Ubuntu SMP Wed Sep 18 09:51:44 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

john@john-System ~ $ python3
Python 3.5.2 (default, Oct  8 2019, 13:06:37) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pygame import midi
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
>>> midi.init()
ALSA lib conf.c:3558:(snd_config_hooks_call) Cannot open shared library libasound_module_conf_pulse.so (/usr/lib/alsa-lib/libasound_module_conf_pulse.so: libasound_module_conf_pulse.so: cannot open shared object file: No such file or directory)
ALSA lib seq.c:935:(snd_seq_open_noupdate) Unknown SEQ default
>>> 

JFitz
Level 1
Level 1
Posts: 6
Joined: Tue May 07, 2019 6:30 am

Re: Pygame midi ALSA call fails

Post by JFitz » Tue Oct 22, 2019 5:43 am

Well ... since enlightenment was not forthcoming I backtracked.
I had installed Pygame from pygame.org using,

Code: Select all

python3 -m pip install -U pygame --user
to install for python3. Since midi in this didn't work (although the test game aliens ran OK) I pip uninstalled pygame and went back to the Linux Mint Software Manager and installed "Idle-python2.7 (IDE for Python (v2.7) using Tkinter" and "Python-pygame (python 2)".

Then I was able to run a simple MIDI test,

Code: Select all

import pygame.midi

def print_devices():
    for n in range(pygame.midi.get_count()):
        print (n,pygame.midi.get_device_info(n))

if __name__ == '__main__':
    pygame.midi.init()
    print_devices()
which found my MIDI keyboard OK. So ... I will need to work in Python2 (unless Pygame using SDL2 installs for Python3?).

If you read my previous question, thanks for your interest and hope this follow-up proves useful to someone.

User avatar
MrEen
Level 14
Level 14
Posts: 5388
Joined: Mon Jun 12, 2017 8:39 pm

Re: Pygame midi ALSA call fails

Post by MrEen » Tue Oct 22, 2019 9:47 pm

Hi JFitz.

I'm not sure which thing is to blame, but that path to /usr/lib/alsa-lib/libasound_module_conf_pulse.so is wrong. It should be /usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_conf_pulse.so (assuming a 64 bit install.) I'm suspecting pygame was trying to access that incorrect location, but have no idea. It could be due to the way Ubuntu packages things, which is why your Software Manager version worked.

JFitz
Level 1
Level 1
Posts: 6
Joined: Tue May 07, 2019 6:30 am

Re: Pygame midi ALSA call fails

Post by JFitz » Wed Oct 30, 2019 4:23 pm

Thanks MrEen for your reply. I checked my system and you're correct of course that the alsa file path is wrong. Since I've found enough of a workaround to make some progress I'm going to persevere with the MINT installation of Pygame and Python 2.7. Currently getting my head around Threading and Events (for key press wait loop).

Thanks again for the response and sorry for my late reply. JF.

User avatar
MrEen
Level 14
Level 14
Posts: 5388
Joined: Mon Jun 12, 2017 8:39 pm

Re: Pygame midi ALSA call fails

Post by MrEen » Wed Oct 30, 2019 6:01 pm

You're welcome, JF.

Have fun! :D

Post Reply

Return to “Newbie Questions”