I have a problem when I play SFX's. I use mmEffectEx() to play them, but they loop eternally. However, mmEffectEx() does not have a loop parameter. Do you have to stop a SFX always, or is there a way to play them only once?
Below the code i use. At the moment I only play one sound using sound_play(SFX_GAME_WON);
Code: Select all
#include <nds.h>
#include <maxmod9.h>
#include <stdio.h>
#include "space-sound.h"
#include "soundbank.h"
#include "soundbank_bin.h"
mm_sound_effect sounds[MSL_BANKSIZE];
mm_sfxhand handlers[MSL_BANKSIZE];
int i;
void sound_load() {
mmInitDefaultMem((mm_addr)soundbank_bin);
for(i = 0; i < MSL_BANKSIZE; i++) {
mmLoadEffect(i);
mm_sound_effect s;
s.id = i;
s.rate = 1024;
s.handle = 0;
s.volume = 220;
s.panning = 128;
sounds[i] = s;
}
}
void sound_unload() {
for(i = 0; i < MSL_BANKSIZE; i++)
mmUnloadEffect(i);
}
void sound_play(int sound) {
handlers[sound] = mmEffectEx(&sounds[sound]);
}
void sound_abort(int sound) {
mmEffectCancel(handlers[sound]);
}