Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

The Audio Subsystem - Or why don't my MP3's work and how can we fix it

edited 2007 Sep 11 in Developers
<i>This post was originally made by <b>Yagisan</b> on the dengDevs blog. It was posted under the categories: Add-ons, Beta 6, Blog, Engine, Game Resource Packs, Games, jDoom, jHeretic, jHexen, Mac OS X, Platforms, Releases, Unix/Linux, Version 1.9, Windows.</i>

Recently we have been receiving bug reports that mp3 files will not play in Doomsday. After extensive testing, I can confirm that the users are correct, mp3 files won't play - and that it isn't Doomsday at fault.

The core of the problem is that SDL_mixer (<a target="_blank" href=""></a>;) uses SMPEG (<a target="_blank" href=""></a>;) to decode mp3 files. This works well with mp3 files with an id3v1 tag, or no tag. (id3v1 tags are at the end of the file), but a lot of newer or retagged mp3 files utilise id3v2.x tags. These tags are pre-pended to the mp3 file, causing SMPEG to not identify them as mp3 files. As you can see development has stagnated there for the last few years.

I propose that we implement a new audio plugin utilising SDL_sound (<a target="_blank" href=""></a>;) it adds support for formats that were removed when FMOD was deleted, and supports newer mp3 files. It should also allow us to utilise multiple music tracks if we wish (<a target="_blank" href=""></a>;)

Plain SDL supports CD audio playback - a feature we lost when FMOD was removed - we could take the opportunity to add that support back in to this plugin.
I'm happy to start making this new plugin, but I will need help, as I'm not a sound/music guru.

Being a new sound plugin, we could probably release beta6 without it, but I'd imagine the users would be disappointed with the sound support not changing between betas.

Thoughts, Feedback, and Code welcome


  • From what I've seen, SDL_sound is just a library that gives you audio samples from the source file you've specified, hiding all the details of the decoding (if any), and conversion (if any). SDL_sound doesn't actually play any sounds.

    So we could just make a copy of SDL_mixer, call it e.g. SDL_mixer2, and make it use SDL_sound to load the sample data and then SDL_mixer to play it, just like it is doing now. No distinction needs to be made between sound effects and music inside the plugin, apart from always reserving a channel for the music.

    When SDL_mixer2 is working well enough, we can make it the default sound plugin.
  • I'm loath to fork a copy of SDL_mixer - my reading of the SDL_sound docs indicate it is a full mixer like SDL_mixer. I'll investigate it further after I get some sleep.
  • Duh. I was looking at the 1.0.1 documentation. The 2.0 one indeed seems to have mixer functionality, so reusing SDL_mixer probably won't be necessary.
  • A skeleton plugin has been committed, and will be expanded as time allows.
  • we now successfully init and close the new sdl_sound plugin under *nix. It sould work under OSX/Win32 as well, but currently does not yet play sounds. On my system it produces the following diaganostic output:

    Sfx_Init: Initializing SDL_sound...
    Initialising SDL_sound
    SDL_Sound: Compiled with SDL_sound version 1.0.1
    SDL_Sound: Linked with SDL_sound version 1.0.1
    SDL_Sound: Supported sound decoders:
    SDL_Sound: MPEG-1 Layer 3 audio through SMPEG decoder
    SDL_Sound: MP3 decoding via internal mpglib decoder
    SDL_Sound: Play modules through MikMod decoder
    SDL_Sound: Microsoft WAVE audio format decoder
    SDL_Sound: Audio Interchange File Format decoder
    SDL_Sound: Sun/NeXT audio file format decoder
    SDL_Sound: Ogg Vorbis audio through VorbisFile decoder
    SDL_Sound: Creative Labs Voice format decoder
    SDL_Sound: Raw audio decoder
    SDL_Sound: Shorten-compressed audio data decoder
    SDL_Sound: SPEEX speech compression format decoder
    S_Init: OK.
  • This is likely to be delayed a while. I've no time to work on it at the moment, and the current nvidia drivers cause my main development box to reboot any time an opengl program is started.
Sign In or Register to comment.