Ogg playback bug in SDL_mixer - crackling noise when looping

Hello to all in SDL community ! There is bug in SDL_mixer library that has to
be solved - Gabriel Gambetta <mystml adinet.com.uy> talked about it "In
one of our recent games, we play ogg loops as background music. For
some reason, some songs work fine, but other songs start making
strange noises (slight but noticeable white noise over the music) when
it loops.

I traced the error to music_mixer() inside music.c:

#ifdef OGG_MUSIC
case MUS_OGG:
len = OGG_playAudio(music_playing->data.ogg, stream, len);
if (len > 0 && music_halt_or_loop())
OGG_playAudio(music_playing->data.ogg, stream, len);
break;
#endif

Commenting the two last lines before the break statement fixes the
problem. What is really weird is that these two lines are part of a
patch I submitted myself a long time ago (2006 maybe) to fix
something. I believe the idea was to make looping smoother by filling
the buffer with the start of the new loop instead of leaving it empty,
but obviously I was wrong.

So, the purpose of this message is twofold :

  1. These two lines should be taken out of SDL_Mixer!

  2. Does anyone understand why do these two lines generate static?
    Music sounds better without these two lines, but there’s a barely
    perceptible “gap” when the track should loop.

Thanks,
–Gabriel "
We’re having the same problem in pur game…
This hasn’t been done yet in SVN also. phime studio …

Just from a quick glance of the code in the post, it seems that the
culprit may be the returned “len” value since it is reused as input
parameter on the next OGG_playAudio call. Also, is the state of the
stream and ogg decoding engine defined after checking checking
music_halt_or_loop()? Maybe one needs to add additional reset calls …
white noise is indicative of the entropy decoding stage being in a wrong
sequence or the vorbis decoder is in “failure mode”. (quote Wikipedia:
“The noise floor approach gives Vorbis its characteristic analog
noise-like failure mode.”)

Also you mention in your original patch email
(http://www.devolution.com/pipermail/sdl/2005-October/070837.html) that
the gaps was a problem for all formats when looping … which other
formats have this issue?

senser wrote:

Hello to all in SDL community ! There is bug in SDL_mixer library that has to
be solved - Gabriel Gambetta <mystml adinet.com.uy> talked about it "In
one of our recent games, we play ogg loops as background music. For
some reason, some songs work fine, but other songs start making
strange noises (slight but noticeable white noise over the music) when
it loops.

I traced the error to music_mixer() inside music.c:

#ifdef OGG_MUSIC
case MUS_OGG:
len = OGG_playAudio(music_playing->data.ogg, stream, len);
if (len > 0 && music_halt_or_loop())
OGG_playAudio(music_playing->data.ogg, stream, len);
break;
#endif

Commenting the two last lines before the break statement fixes the
problem. What is really weird is that these two lines are part of a
patch I submitted myself a long time ago (2006 maybe) to fix
something. I believe the idea was to make looping smoother by filling
the buffer with the start of the new loop instead of leaving it empty,
but obviously I was wrong.

So, the purpose of this message is twofold :

  1. These two lines should be taken out of SDL_Mixer!

  2. Does anyone understand why do these two lines generate static?
    Music sounds better without these two lines, but there’s a barely
    perceptible “gap” when the track should loop.

Thanks,
–Gabriel "
We’re having the same problem in pur game…
This hasn’t been done yet in SVN also. phime studio …


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

-------------- next part --------------
A non-text attachment was scrubbed…
Name: aschiffler.vcf
Type: text/x-vcard
Size: 135 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20080618/2b41240a/attachment.vcf