Issue #236 wontfix

Bug in pygame.mixer.sound.fadeout : "stair effect" fadeout

Jos Bas
created an issue

I've noticed this with headphones, and now it is confirmed, as I recorded my stereo out.

pygame.mixer.sound.fadeout is not a normal linear fadefout, but a step function ("staircase" function) :

5.jpg

The "width" of the constant pieces is exactly the audio buffer size (1024 samples in my example).

In order to reproduce it :

1) Download http://gget.it/uk2oi63z/sine1.wav

2) Play it with pygame.mixer.sound.play() and do a fadeout(200) Ready to use test .py file : http://gget.it/0x6zxbvl/pygamefadeout.py

3) You'll notice stair effect. Here is the sound I get : http://gget.it/zjh61iz2/sine1_fadeout_with_pygame.wav

__

How to solve it ? I suspect it comes from /src/mixer.c, which calls Mix_FadeOutGroup().

Tested on both Pygame 1.9 Win7/PC and RaspberryPi.

Comments (5)

  1. Jason Marshall

    Thank-you for reporting this issue. I can hear the little clicky noises.

    Unfortunately, the fadeout math is in the SDL mixer code, not pygame. I cannot think of a feasible way to fix this fadeout noise issue in the pygame library because there is no way to determine precisely when the amplitude of the current sound is at zero and decrease the sound's volume at that precise moment.

  2. Log in to comment