Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Division by zero #49

reidrac opened this Issue · 14 comments

2 participants


Just trying to play a wav file.

This is Linux and I can't find a wav sample that it's OK for AVBin. Some of them crash with "division by zero" and others doesn't seem to play correctly.

I can provide wav samples.

Traceback (most recent call last):
  File "/home/reidrac/src/shooter/X/lib/python2.7/site-packages/pyglet/", line 610, in media
    return media.load(path, streaming=streaming)
  File "/home/reidrac/src/shooter/X/lib/python2.7/site-packages/pyglet/media/", line 1408, in load
    source = StaticSource(source)
  File "/home/reidrac/src/shooter/X/lib/python2.7/site-packages/pyglet/media/", line 612, in __init__
    audio_data = source.get_audio_data(buffer_size)
  File "/home/reidrac/src/shooter/X/lib/python2.7/site-packages/pyglet/media/", line 428, in get_audio_data
    packet_type, packet = self._process_packet()
  File "/home/reidrac/src/shooter/X/lib/python2.7/site-packages/pyglet/media/", line 399, in _process_packet
    audio_data = self._decode_audio_packet()
  File "/home/reidrac/src/shooter/X/lib/python2.7/site-packages/pyglet/media/", line 491, in _decode_audio_packet
    duration = float(len(buffer)) / self.audio_format.bytes_per_second
ZeroDivisionError: float division by zero

That's odd for several reasons, not the least of which I didn't think pyglet used AVbin for .wav files (it can play them without AVbin installed).

Could you send me a copy of the sound file, by chance? I haven't been able to reproduce this error on my own.


I've sent you a wav sample.


Some details:


 File Size: 2.91k     Bit Rate: 180k
  Encoding: Unsigned PCM  
  Channels: 1 @ 8-bit    
Samplerate: 22050Hz      
Replaygain: off         
  Duration: 00:00:00.13  

You're right, that should be played by pyglet because it is plain PCM.


Great, I'll see if I can figure out what's wrong. Just because pyglet has the ability to play wav files natively doesn't mean it shouldn't work through AVbin.

Don't hold your breath, though. I do this in my (increasingly rare) spare time!


Ah, the problem is in AudioFormat. sample_rate is zero. Oh, dear.

Edit: oh, sent the comment in draft state.


I can't tell, but looks like it. It's failing to read the info from the wav I think.

Anyway, feel free to close the bug.


I was working on a different issue and just put out version 11-alpha1. Would you mind trying it out and letting me know if it happens to make a difference on this issue as well?

It's on the Downloads page temporarily:


It makes no difference. Same "ZeroDivisionError: float division by zero" sample palce.

@ghost ghost was assigned
@ghost Unknown referenced this issue from a commit
@CleanCut CleanCut Issue #48, #49: Found and fixed bug where all 8-bit audio files repor…
…ted sample rates of 0.

It should be fixed! I found a line that was (erroneously) overwriting the sample rate information if the audio file was 8-bit. Try version 11-alpha4.

@ghost ghost closed this

Using 11-alpha 4 on Mac OS X (10.7.5) and (after fixing the file permissions on the libraries) pyglet starts to play this mp3 file: but after about 30 seconds, it just stops.

code snip:
import pyglet as p
music ='data/music/pamgaea.mp3')

Do you think this is an avbin problem?
Stable version 10 did not work at all - I got the ZeroDivisionError.


I think it's very likely an AVbin problem. I'm pretty much done trying to fix it, though. See!topic/pyglet-users/HxJVKUPcwgE

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.