Different volume when using mm_ds_sample

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

Moderator: eKid

Post Reply
arne
Posts: 2
Joined: Sat May 16, 2009 5:17 pm

Different volume when using mm_ds_sample

Post by arne » Sun May 17, 2009 12:11 am

Hi,
I tried to add background music to my game using a wav file (8bit, 16kHz). Everything works fine if I load the file like this.

Code: Select all

mmInitDefaultMem( (mm_addr)soundbank_bin );
mmLoadEffect(SFX_QUOD);
mm_sound_effect bgSound = { SFX_QUOD, 1<<10, 0, 200, 127};
mmEffectEx(&bgSound);
But when I use the mm_ds_sample struct to loop it like the following, the volume is hardly a quarter of the original.

Code: Select all

mmInitDefaultMem( (mm_addr)soundbank_bin );
mmLoadEffect(SFX_QUOD);
mm_ds_sample bgSample = {2995, 202533, 0, 1, 1<<9, (void*)&soundbank_bin[SFX_QUOD]};
mm_sound_effect bgSound = { (mm_word)&bgSample, 1<<10, 0, 200, 127};
mmEffectEx(&bgSound);
Is there something I'm missing like a flag or is this simply supposed to be this way? I looked at the documentation but there is not much on looping, updated to the latest release with no effect and even tried to raise the volume of the file to compensate for this but it is still way too low so any help on this would be appreciated.

Thanks in advance. :-)

So long,
Arne


EDIT:
I probably should have seen this coming... The problem was on my side all along. Of course, soundbank_bin[SFX_1] doesn't point to the start of SFX_1 but near the start of the first effect where I had another file with lower volume. -.-

So another question: Is there any way to get the offset of an effect in the soundbank?

eKid
Posts: 65
Joined: Sat Dec 06, 2008 6:07 pm
Contact:

Re: Different volume when using mm_ds_sample

Post by eKid » Wed May 20, 2009 3:59 pm

Hello! Here are some solutions:

1) Find a program that can add set loop points in wav files.

2) Store the sound effect in a module file (modules contain loop point info)

3) (the method you are trying)...
The first 32-bit word of the soundbank contains two halfwords containing the module and sample count. The next two words are reserved. Two tables follow (starting at byte12) they contain pointers to the module and sample files. I think the sample pointers come first, so to get the address of a sample it should be something like:

Code: Select all

const mm_ds_sample *getSampleAddress( int index ) {
    return (const mm_ds_sample*)( ((char*)soundbank_bin) + ((u32*)soundbank_bin)[3 + index] );
}
I don't have the doc about the soundbank format around at the moment so this might be slightly incorrect...

arne
Posts: 2
Joined: Sat May 16, 2009 5:17 pm

Re: Different volume when using mm_ds_sample

Post by arne » Wed May 20, 2009 6:53 pm

Thanks a lot!

I concentrated so hard on doing it one way that I didn't see any other. So I'll go get me a tracker then.

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests