Bug in MMUtil?

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

Moderator: eKid

Post Reply
ChillyWilly
Posts: 2
Joined: Thu Apr 14, 2011 1:51 am

Bug in MMUtil?

Post by ChillyWilly » Thu Apr 14, 2011 2:22 am

I have been working on sound support for the 32X, and mmutil seems like the perfect preprocessor for music and sound effects. While making a few changes to make the 32X handle it easier (like changing the endianness of words and longs), I believe I ran across a pretty substantial bug.

Look at when you tell it to out put a MAS file:

Code: Select all

        output_size = Write_MAS( &mod, v_flag, false );
and when you tell it to make a soundbank:

Code: Select all

    Write_MAS( mod, false, true );
Now look at the proto for Write_MAS():

Code: Select all

int Write_MAS( MAS_Module* mod, bool verbose, bool msl_dep )
Clearly we have a boolean flag we pass to tell the difference between just writing a MAS file in general versus one written as part of a soundbank. Why? Because when you create a soundbank, all the samples in the music and any sound effects get put in a separate temporary file, while the music goes in a different temporary file. The soundbank is made by outputting the two files along with the appropriate parapointers to the samples and songs. A MAS file by itself must have the samples in the music since it won't have the separate sample file.

The problem is Write_MAS() ignores the bool and outputs the samples anyway. So now you have extra samples in your soundbank. The Write_MAS() function should be checking msl_dep before outputting the samples, and the sample parapointers should instead be the msl_index. What's funny is the MAS flags byte DOES have the msl_dep flag:

Code: Select all

    write8( (u8)((mod->link_gxx ? 1 : 0) | (mod->old_effects ? 2 : 0) | (mod->freq_mode ? 4 : 0) | (mod->xm_mode ? 8 : 0) | (msl_dep ? 16 : 0) | (mod->old_mode ? 32 : 0)) );
This at least doubles the samples from the music, and depending on how many samples are identical between songs, could be SUBSTANTIALLY higher! If you had ten songs with all the same instruments for each, you're actually using ELEVEN times the space! :o

ChillyWilly
Posts: 2
Joined: Thu Apr 14, 2011 1:51 am

Re: Bug in MMUtil?

Post by ChillyWilly » Sat Apr 16, 2011 2:48 am

Okay, a closer look at Write_Sample() shows this:

Code: Select all

    if( samp->msl_index == 0xFFFF )
So the sample DATA is only written if msl_index is 0xFFFF; i.e., this is a unique sample. Otherwise, only the header is written, which has info we need. So it's good. Sorry about any confusion - it was on my side. :oops:

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests