Pirate Radio ASLA error


#1

Hello,
I picked up a pirate radio from the PiParty and i’m trying to make a pygame mixer music player, however i’m currently not getting a sound output.

When running the following code:

from pygame import mixer
import phatbeat
volume = 0.5
state = 'pause'
mixer.init()
mixer.music.load('test.mp3')
@phatbeat.on(phatbeat.BTN_PLAYPAUSE)
def play_pause(pin):
    global state
    print "play"
    if state == 'pause':
        mixer.music.play()
        state = 'play'
    if state == 'play':
        mixer.music.pause()
        state = 'pause'
while True:
  pass

I get the following output:

When just opening python, if i type in the following commands, the music plays, and i receive no ALSA messages.

from pygame import mixer
mixer.init()
mixer.music.load('test.mp3')
mixer.music.play()

I’m not going to lie, I am not too good at coding, so it could very well be an issue with the code, however the “ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred” error is really confusing me!

Many Thanks

Alex


#2

Welcome to the fortnight of alsa errors!


#3

oh! That doesn’t sound good!


#4

You’re going to head-desk when you see your error.

Look at the content of your play_pause function for a few minutes, and let me know if you don’t spot it :D

(I hope I know what I’m talking about)

Edit: ALSA coughs up errors like it’s going out of fashion anyway, in this case they do allude to the problem very slightly (if you know what a buffer underrun is and why it occurs) but are mostly just misleading.


#5

Oh Dear! I’m going to blame it on the weather :P Thank you!


#6

LOL… sorry took me a second or two to see it too, and I don’t mean to mock you by laughing out loud (I’ve done my share of painting myself in a corner that way before), but I literally spilt my tea on my desk.


#7

I am completely fine with the laughing however wasting a perfectly good cuppa is unacceptable :P Spent ages last night trying to find the problem :D