gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > looping sound?

#150858 - iprice - Wed Feb 13, 2008 6:40 pm

The example in devkit does not let you loop the sound. How can you call arm9 code to set channel 0 to repeating? I have tried a function in arm7 and an extern call from arm9........

I want a certain tune to loop but other samples not to. As I call the looping tune first I assume it will always use channel 0.

Any suggestions?

#150861 - silent_code - Wed Feb 13, 2008 8:01 pm

have you checked gbatek?
http://nocash.emubase.de/gbatek.htm

Quote:
40004x0h - NDS7 - SOUNDxCNT - Sound Channel X Control Register (R/W)
...
Bit27-28 Repeat Mode (0=Manual, 1=Loop Infinite, 2=One-Shot, 3=Prohibited)

#150863 - Dwedit - Wed Feb 13, 2008 8:04 pm

What is the difference between 0=manual and 2=one shot?
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#150864 - iprice - Wed Feb 13, 2008 8:15 pm

How do I access ARM7 code from ARM9?

#150866 - tepples - Wed Feb 13, 2008 8:35 pm

iprice wrote:
How do I access ARM7 code from ARM9?

You write an ARM9 program, you write an ARM7 program, and you have the ARM9 program tell the ARM7 program what to do.

As far as I can tell, if you use the ARM9 template, you don't get much if any control of looping. You could use the combined template and change the sound code.


EDIT: finish an incomplete sentence
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.


Last edited by tepples on Thu Feb 14, 2008 3:11 am; edited 1 time in total

#150867 - DekuTree64 - Wed Feb 13, 2008 8:45 pm

Dwedit wrote:
What is the difference between 0=manual and 2=one shot?

One-shot stops after the length you specify. Manual just plays forever until it goes off the end of memory and probably crashes the system, like the GBA sound DMA.

iprice wrote:
How do I access ARM7 code from ARM9?

Usually communication is done using shared memory or the IPC FIFO registers (I wrote a nice system for this which you can get from this post). For looping sounds, you do need something more than the libnds play sound function, because you need some way to stop it later. Granted, that could be as simple as a "stop all sounds" function if you're only changing music on level transitions or something.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#150868 - silent_code - Wed Feb 13, 2008 8:49 pm

Quote:
How do I access ARM7 code from ARM9?

i haven't done it, yet, but there's a inter-processor communication fifo. that's the way to go, iirc.

there's one or two sound libs around the forum, check out how they do it (sources or mail the author.)

about the difference between manual and one-shot... dunno. ;^p you've got to try it out!

#150888 - iprice - Thu Feb 14, 2008 11:22 am

Is there a way of starting a sound with arm9 code but having extra parameters such as looping and/or channel select?

#150905 - Dwedit - Thu Feb 14, 2008 6:08 pm

You can't loop sound if you are using the default ARM7 binary. The default ARM7 binary is garbage.
You can see the source code to the default ARM7 binary in "C:\devkitPro\examples\nds\templates\combined\arm7". Note that it ORs "sound_one_shot" onto anything you pass in, and only tries to play sounds at the beginning of vblank.

I suggest you switch your project to build both ARM7 and ARM9 binaries. Then I recommend you use DekuTree64's IPC library, which works great for me.

I'll edit this post with a quick "How To" for the IPC library.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."