When trying to use the Speaker pHat on Raspbian 2017-01-11 with Pygame to play an audio file I get a Memory Error related to the sound meter plugin - see error message here.
ALSA lib pcm_meter.c:678:(snd_pcm_meter_add_scope_conf) Cannot open shared library /usr/local/lib/libphatmeter.so
Traceback (most recent call last):
File "pyaudio.py", line 4, in <module>
song = pygame.mixer.Sound('WALLE1.ogg')
If I comment out all the sound meter sections in /etc/asound.conf it works. Is there a bug in the library? I have tried recompiling it and that doesn’t seem to make any difference.
The code used to play the audio is based off an example:
song = pygame.mixer.Sound('thesong.ogg')
clock = pygame.time.Clock()
I ran into this today trying to set up a combined Drum HAT/Piano HAT/Speaker pHAT. I’ve not the foggiest clue what’s going on, but “aplay -Dameter filename.wav” plays sounds perfectly fine, whereas anything else trying to open the device fails with the shared library error.
My Google-fu has failed me on this one- finding only issues with Pulse Audio. I just can’t figure out why neither PyGame or PulseAudio can open the shared library, even though it works in all other cases.
Granted, I haven’t spent more than an hour or so looking into it yet, but you’re not alone!
I’ve got to the bottom of this finally, and will be spinning out a new version of the lib to fix the problem. Watch this space!
@gadgetoid fix seems to work with pygame for him and I, so give it a go - it’s live now… to install, just re-run the O-L-I:
curl https://get.pimoroni.com/speakerphat | bash