I've encapsulted in my own classes some calls of Maxmod, but I found a problem that I'm not sure where it comes from. By experimenting, it looks like if my classes have virtual functions, the sound system will not work as expected. Let me show you a working example of using MaxMod directly and the test I checked (in the examples I load the soundbank from FAT with a call like this mmInitDefault("nitro:/audio/soundbank.bin") ):
MaxMod version:
Code: Select all
mmLoad (MOD_TEST1);
mmStart (MOD_TEST1, MM_PLAY_LOOP);
// After 2 seconds
mmStop();
mmUnload (MOD_TEST1);
mmLoad (MOD_TEST2);
mmStart (MOD_TEST2, MM_PLAY_LOOP);
Code: Select all
class SoundModule
{
public:
SoundModule()
{
}
~SoundModule() { }
int GetId () const
{
return _id;
}
void Load (const int id)
{
_id = id;
mmLoad (id);
}
void Unload ()
{
mmUnload (_id);
}
void Play ()
{
mmStart(_id, MM_PLAY_LOOP);
}
void Stop ()
{
mmStop();
}
protected:
int _id;
};
// Later in the code
SoundModule* sound1 = new SoundModule;
sound1->Load (MOD_TEST1);
sound1->Play();
// And some seconds later
sound1->Stop();
sound1->Unload();
sound1->Load (MOD_TEST2);
sound1->Play();