I'm steamlining the discussion between Titmouse and myself, down to just the important information, for anyone else that may be interested in using Titmouse's improved sound libraries.
DevkitPro has two included sound libraries: asnd and aesnd (aesnd is supposed to be an improved version of asnd). They can NOT both be used in the same application; you must use one or the other. Unfortunately, DevkitPro has it set up so that you must use asnd if you want to use MP3 or OGG files, and you must use aend if you want to use MOD files. But I wanted to use both MOD files and MP3 or OGG for different background music tracks.
Titmouse made an improved version of the OGG player that works with aesnd (OGG is just as good or better than MP3, so I can convert any music to OGG format). To use Titmouse's modified OGG library, first you need to install Tremor. Download the files from that Wiibrew page, but do NOT install them to the default folders. Instead, copy the Tremor files to these folders:
libogc\ +- include\ +-- tremor\ +--- config_types.h +--- ivorbiscodec.h +--- ivorbisfile.h +--- ogg.h +--- os_types.h +- lib\ +-- wii\ +--- libvorbisidec.a
Next, download the oggplayer example from Titmouse's Google Code project page: http://code.google.com/p/wii-bolt-thrower/downloads/list
Titmouse uses a modified aesnd function to allocate voices in a better way (I'll get to that below), so in order to compile this example, you'll need to change back to the default function. Go into the oggplayer.cpp file, around line 211 and comment out the line:
m_DedicatedOggVorbisVoice = AESND_AllocateFixedVoice(VoiceCallBackFunction);
And un-comment the line:
//m_DedicatedOggVorbisVoice = AESND_AllocateVoice(VoiceCallBackFunction);
Now you should be able to compile and run the example, and use it as a base to import the code into your own project.
To do that, make sure you have the the libs included in your MAKEFILE: -lvorbisidec -laesnd and #include "oggplayer.h" in your source code
Then you can place oggplayer.cpp and oggplayer.h in with your source code (optionally, oggplayer.h can be placed in with the DevkitPro files in: \libogc\include\ so that all your projects will have access to it, but you'll still have to have a copy of oggplayer.cpp with your source files, since I have no idea how to compile it into a library that might be installed into DevkitPro so that all your projects would have access to it...).
Note that the oggplayer uses c++ code rather than just c, so if you want to integrate this into your own projects, you have to make sure your source files are named like main.cpp rather than main.c -- I'm not that knowledgable on what all differences that will make, but my own code compiled fine as c++ rather than c, though the compiler is a bit more picky about the way some functions are declared or used (for example, I had to use AESND_Init() instead of AESND_Init(NULL) as the DevkitPro example show -- c++ tells you that's too many arguments).
One other note: if you have an OGG file playing, be sure you issue the MyOggPlayer.Stop() command before you try to start a new OGG file playing, or it will crash after a few times of doing that.
The default MOD file player, gcmodplay, is ok for playing MOD files, but that's all it does.
Solution 2: Titmouse has a modified GRRMOD library that can be used to play MOD, IT, XM, and S3M format files, giving you a lot more options for music.
To install, grab the files from Titmouse's Google Code project:
You need the files:
Copy them to your DevkitPro folders:
Download the example project files to see how to make use of it:
and all the example music files in the folder:
That should help you see how to implement GRRMOD into your own projects.
Main points: include the libs in your makefile: -lgrrmod -laesnd and in your source code, #include "grrmod.h"
One tip: in both GRRMOD and the default GCMODPLAY, I ran into a glitch where if you try to stop a MOD file from playing, about 5% of the time it will randomly glitch out and make a horrible noise until you start a new MOD file.... So if you have a need to stop a MOD file without immediately starting a new one, instead just set the MOD volume to 0 and let it keep playing silently.... Then when you are ready to start a new MOD file, you can Stop the previous one, then reset the volume back up to normal, and then start the new file playing.
Issue 3 (unresolved for me) :
aesnd is supposed to be an improved version of asnd, but the function for assigning voice channels in aesnd is not good. It does not properly re-use a voice that is done playing.
Titmouse modified aesnd with a better voice allocation function (as he described here: http://forum.wiibrew.org/read.php?11,68659,68659 ), but I have not been able to get it to work with my setup....
It seems like it should be as simple as replacing my aesnd files with Titmouse's modified ones:
But when I do that and compile my game, the sound playback is distorted. However, Titmouse is able to compile my game just fine using his modified files. So I don't really know what to do about this issue....
I just wish the DevkitPro people would implement Titmouse's changes to the default version, since these changes are a big improvement.
--Mr. Reaper 22:47, 27 August 2012 (CEST)