Playback stops

support for the gba/nds sound library from www.maxmod.org

Moderator: eKid

Post Reply
surffer3d
Posts: 4
Joined: Tue Aug 17, 2010 12:08 am

Playback stops

Post by surffer3d » 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:

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);
The above version behaves as expected. Then I wraped the calls in a minimal class like this:

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();
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?

zeromus
Posts: 212
Joined: Wed Mar 31, 2010 6:05 pm

Re: Playback stops

Post by zeromus » Wed Sep 15, 2010 6:12 am

The casual reader might be interested in the fact that "Stopping channel 4 due to zero length" is a desmume error message.

I think the virtual functions are just a red herring. Humor me and try something: add a swiWaitForVblank() call between every single maxmod function call and see if that fixes it.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests