Crackling noises after long time. Bug?

44 views
Skip to first unread message

ESPark Tests

unread,
Jun 10, 2019, 12:20:56 PM6/10/19
to pyglet-users
Hi, I am using pyglet only to play wav files on user events. At first it works fine but if I let it alone for a few hours the files will play but with horrible crakling noises. I cant say if it still happens if I keep playing stuff. If I play the same file outside of the python program with aplay it sounds fine. I am using openal. I only have alsa installed, no pulseaudio.I am basically doing this every time I need to play a file:

if self.player:
   
self.player.pause()
   
self.player.delete()
self.player.queue(pyglet.media.load(file_path, streaming=False))
self.player.play()
Timer(self.player.source.duration + 0.01, self.pause_audio).start()

I am not doing anything on_eos or on_player_eos because I could make them work. Thats why I set a Timer and then call pause and delete. The pause and delete part at the top is to stop playing the previous clip if it was still playing. I have tried re-instantiating the player after delete() but it doesnt make any difference.

On another note, the volume in pyglet is much lower than with aplay even if its at the maximum. Its not such a big issue because it is the only app playing sounds and I added a preamp with alsa. 

Python ver: 2.7.13
Pyglet ver: 1.3.2
Computer: Beaglebone

Thanks for your help.



Benjamin Moran

unread,
Jun 11, 2019, 9:03:44 AM6/11/19
to pyglet-users
This sounds like some resources are not getting cleaned up properly. Could you give it a try with the latest code on Bitbucket? There are some changes to how Players are destroyed, which might fix the issue.

If you try that, and it still doesn't solve the issue, let's mock up a simple test to try to simulate the bug.

ESPark Tests

unread,
Jun 12, 2019, 10:51:11 AM6/12/19
to pyglet-users

Thanks. I left it overnight with the latest code on bitbucket but the problem persists. Today I'll make some tests outside of my application and post the results and code.

Benjamin Moran

unread,
Jun 13, 2019, 1:09:40 AM6/13/19
to pyglet-users
If you can put that reproduction together, I can see if I can sort out the cause.
I guess this goes without saying, but did you test this on another machine by any chance?

Marcin Skibiński

unread,
Jun 13, 2019, 6:56:12 AM6/13/19
to pyglet...@googlegroups.com
Hi all,
As I work almost daily with audio edeiting software such noises usually are because some issues of audio buffer of audio driver (leak or load)

From some audio software manual:

If the CPU load is too high and audio can't be buffered within the chosen buffer rate, then this may result in crackles, dropouts (gaps in playback) or glitches during playback

-Marcin

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users...@googlegroups.com.
To post to this group, send email to pyglet...@googlegroups.com.
Visit this group at https://groups.google.com/group/pyglet-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyglet-users/afb73f44-b768-43ab-9ac8-41a05a6f5690%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ESPark Tests

unread,
Jun 19, 2019, 10:30:31 AM6/19/19
to pyglet-users

I have finally been able to do some tests and I believe it is an issue with the preamp I added on alsa. In my tests, without the preamp the problem didn't occur. I guess this is more of a problem with alsa than with pyglet, but do you have any idea what could be happening or how to fix it? Also, I added this preamp because for some reason when playing the wav files with pyglet the volume is much lower than with aplay. Is there a way to fix this without using the preamp?

My /etc/asound.conf file has this configuration:

pcm.!default {
      type plug;
      slave.pcm softvol;
}

pcm.softvol {
      type softvol
      slave {
          pcm "dmix:1,0"
      }
      control {
          name PreAmp
          card 1
      }
      min_dB -5.0
      max_dB 20.0
      resolution 6
}




Reply all
Reply to author
Forward
0 new messages