Playing an effect from memory buffer

support for the gba/nds sound library from

Moderator: eKid

Post Reply
Posts: 5
Joined: Sun Apr 01, 2012 9:58 am

Playing an effect from memory buffer

Post by icedaddy » Sat Apr 14, 2012 5:55 pm

Experimenting with MAXMOD I was trying to play a sound that I had loaded from the filesystem. The docs refer to mmEffectExt for playing external sounds; however, the code would not link. I had a look at the maxmod source and it appears the prototype for mmEffectExt is there but no implementation - hence link error.

I noticed on the forums that mmEffectEx could be used but I have had no joy. Below is my simple test code. Am I doing something stupid?

Code: Select all

/* MaxMod test */

#include <nds.h>
#include <filesystem.h>
#include <maxmod9.h>
#include <stdio.h>
#include "soundbank.h"
#include "soundbank_bin.h"

int main(int argc, char **argv) {


	// load a sample from nitro
	FILE* pFile = fopen("test.ima", "rb");
	u32 size = 3788;
	void* pBuf = malloc(size);
	fread(pBuf, size, 1, pFile);

	mm_ds_sample sample;
	sample.loop_start = 0;
	sample.length = size/8;		// size in words - 4bit data
	sample.format = 2;
	sample.repeat_mode = 2;
	sample.base_rate = 250; 	// 8000Hz *1024/32768 = pBuf;

	mm_sound_effect sound;
	sound.sample = &sample;
	sound.rate = 1024;
	sound.handle = 0;
	sound.volume = 255;
	sound.panning = 128;


	while(true) swiWaitForVBlank();

	return 0;
The sound effect I am trying to play is IMA ADPCM, 8000Hz. It plays fine if I use:

Code: Select all

soundPlaySample(pBuf, SoundFormat_ADPCM, size, 8000, 127, 64, 0, 0);
Similarly if I play a sound from the soundbank wirh maxmod using mmEffect that works also.


Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest