SFX without looping?

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

Moderator: eKid

Post Reply
Posts: 1
Joined: Wed Jan 13, 2010 12:42 pm

SFX without looping?

Post by martijnversluis » Wed Jan 13, 2010 12:49 pm


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() {
	for(i = 0; i < MSL_BANKSIZE; 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++)

void sound_play(int sound) {
	handlers[sound] = mmEffectEx(&sounds[sound]);

void sound_abort(int sound) {

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

Re: SFX without looping?

Post by eKid » Tue Jan 19, 2010 5:32 pm

The sound will loop if there is looping information in the wav file itself (stored in the 'sampler chunk'). I'm not sure how you created the wav file but you need to remove that loop point somehow (unless there is some other bug in maxmod causing this...).

Posts: 4
Joined: Wed Feb 24, 2010 1:49 pm

Re: SFX without looping?

Post by n315on » Thu Feb 25, 2010 1:11 pm

Another thing to look at is make sure your function being called is not in a loop. I had similar problems with adding and subtracting from scores.

EDIT: (Update). I copied your functions into one of my programs using three WAV files, and did not get looping sounds. Your functions where better written than mine, so I'll just probably continue to use them, so thank you for that.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest