Page 1 of 1

cannot play samples more than once

Posted: Thu Dec 24, 2009 4:46 pm
by jotd
Hi,

I'm currently fighting with MaxMod. The basic demo compiles and works OK, I can even change the sounds and put my .wav files instead and it works.
I've tried to do the same in my game. I'm loading the soundbank from the filesystem OK

Here's my C++ code

mmInitDefault((char*)soundbank_file.c_str());
mmLoadEffect(SFX_ARGH);
mmLoadEffect(SFX_GAME_OVER);

debug("Playing ARGH");
int a = mmEffect(SFX_ARGH);
GsTime::wait(1000); // wait 1 second
mmEffectCancel(a);
debug("Playing GAME OVER");
mmEffect(SFX_GAME_OVER);
GsTime::wait(1000);

It works, but if I don't cancel the effect, the second effect does not play!! It does not work 2 times! If I cancel the second SFX it keeps on playing, and no more sfx play afterwards!!!! what am I doing wrong??


I don't understand, since the example plays 2 sounds perfectly.

I'm using maxmod from devkitpro 1.5. Are there some updated versions with less bugs?

thanks


EDIT: I found the problem: I was using SDL with only video set (sound broken now on recent devkits): I patched SDL so it does not install IRQs and everything works all right!!!!

Re: cannot play samples more than once

Posted: Mon Dec 28, 2009 1:27 am
by WinterMute
Glad you got it working in the end. It might be worth sending a patch to the SDL maintainers if you have the time.

Re: cannot play samples more than once

Posted: Mon Dec 28, 2009 9:32 am
by jotd
WinterMute wrote:Glad you got it working in the end. It might be worth sending a patch to the SDL maintainers if you have the time.
The problem with SDL NDS port is deeper than that. I had to switch to maxmod because SDL sound was not working on NDS. It even froze the system (IRQ?) at some point.

I tried to debug the sound support in SDL, and it uses the getIPC stuff (which is deprecated now). Putting printfs in the ARM9/ARM7 communication code (fifo stuff that I don't get fully) showed that it does not communicate as expected.

so to sum it up on SDL 1.2.9:

- sound not working (and locking the machine)
- SetTimer not working, I had to adapt my main game loop with regulated/timed waits instead of using interrupt handler (works OK on both NDS and PC so all right, but for emulators it won't be as easy!)
- SDL_Delay uses active loops instead of waitforblank for instance, well maybe it's for accuracy sake, but the battery won't like it!

I stick with SDL because I use it heavily for the PC versions of my games.
On the NDS, the graphics support is still 100% functional (even if I have to stick to 256 colors) and allows me to develop on PC and port on NDS in a breeze (now that all compatibility/memory problems have been fixed).

The problem with SDL on a NDS is that it's very limited and too generic. For instance maxmod uses the 16 channels of the DS, whereas SDL performs an unnecessary channel mix => stereo using a lot of CPU and degrading sound output in the process.
Same thing for joysticks. Reading joysticks on NDS is very easy with devkitpro, whereas with SDL you have to go through all abstraction layers, number of controllers, number of directions... too much PC oriented, and it does not work as expected on the NDS anyway (digital thresholds are different, there are interferences with SDL irqs...)

I also tried to link with the provided libSDL.a (binary) on devkit 1.5 and it crashed. I have not tried to recompile reminiscenceDS in 1.5 but I'm sure sound won't work anymore, whereas it uses only SDL.

So to conclude, I removed irq handler installation in SDL because it was not doing anything useful for me. The patch is useful only for people who want to use sound through maxmod and SDL on devkitpro 1.5

Re: cannot play samples more than once

Posted: Sun Jul 04, 2010 5:03 pm
by protomank
Where is this patch?

I am having the same issues with SDL+maxmod and wanted to know that IRQ parts I must disable...

Re: cannot play samples more than once

Posted: Sun Jul 04, 2010 7:16 pm
by jotd
I'm glad that someone is interested

get full source of my game here, includes patched SDL

http://pagesperso-orange.fr/jotd/bagman ... 32-1.1.zip

Re: cannot play samples more than once

Posted: Tue Jul 06, 2010 12:54 am
by protomank
Thanks.
I am developing a SDL-based game similar to Megaman, this will be VERY usefull :D

Disclaimer: More info at http://rockbot.upperland.net