Playback stops
Posted: Tue Sep 14, 2010 9:17 pm
Hi,
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:
The above version behaves as expected. Then I wraped the calls in a minimal class like this:
That version also works fine, but if I make any method virtual, the first time the sound will be played, but later I get the following error "Stopping channel 4 due to zero length". Am I doing something wrong in here?
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();