The Audio Subsystem - Or why don't my MP3's work and how can we fix it
<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="http://www.dengine.net/blog/wp-admin/iterateMapElementList">http://www.libsdl.org/projects/SDL_mixer/</a>) uses SMPEG (<a target="_blank" href="http://svn.icculus.org/smpeg/trunk/">http://svn.icculus.org/smpeg/trunk/</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="http://icculus.org/SDL_sound/">http://icculus.org/SDL_sound/</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="http://svn.icculus.org/SDL_sound/trunk/mixer/tutorial.txt?rev=534&view=auto">http://svn.icculus.org/SDL_sound/trunk/mixer/tutorial.txt?rev=534&view=auto</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
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="http://www.dengine.net/blog/wp-admin/iterateMapElementList">http://www.libsdl.org/projects/SDL_mixer/</a>) uses SMPEG (<a target="_blank" href="http://svn.icculus.org/smpeg/trunk/">http://svn.icculus.org/smpeg/trunk/</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="http://icculus.org/SDL_sound/">http://icculus.org/SDL_sound/</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="http://svn.icculus.org/SDL_sound/trunk/mixer/tutorial.txt?rev=534&view=auto">http://svn.icculus.org/SDL_sound/trunk/mixer/tutorial.txt?rev=534&view=auto</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
Comments
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.
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.