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 > MOD player v1.0

#44009 - DekuTree64 - Sun May 29, 2005 9:25 am

Ok, my little MOD player is in a usable state now. Grab it here. No SFX support yet, but I'll get to that eventually (well, maybe).

It will hopefully drop right into any ndslib projects that want to use it. Check the readme for details.

It should work well with file systems too, although I've only tried it with plain old .incbin'd MOD files.
...or now that I think about it, maybe not. Since you pass it a pointer to the MOD from ARM9, that means ARM9 needs to have access rights on the GBA cart to find the file, but then ARM7 needs access to load it.
Suggestions welcome on how to get around that one :)
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#44013 - Veg - Sun May 29, 2005 10:36 am

Can this simply be used as a standalone DS MOD player?

Where do we put the *.mod files that we want to use?

I try running build.bat, and it tells me 'make is not recognized as an internal or external command, operable program or batch file.'

#44020 - Chetic - Sun May 29, 2005 1:16 pm

I get the two white screens of death.
_________________
Packin':
Grey DS with FlashMe v7
1Gbit XG2T 2005 (Neoflash compatible)
GBAMP, Supercard CF, 512Mb Magic Key 3 and EZFA 256Mbit

#44024 - TheChuckster - Sun May 29, 2005 2:49 pm

Two white screens of death/10'd

#44041 - tepples - Sun May 29, 2005 7:22 pm

Veg wrote:
it tells me 'make is not recognized as an internal or external command, operable program or batch file.'

Then you don't have MSYS in your PATH.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#44060 - DekuTree64 - Sun May 29, 2005 9:44 pm

Veg: It's not set up to be a standalone player, but I could make a MOD appending tool that also appends the number of files it found, and then it could work without recompiling.

For the path, I figured I just didn't have my ndslib set up right, since I don't normally use it. It's pretty much a straight copy of the templateBoth example, so if you can build that, this should work too. My modified build.bat looks like this:
Code:
SET PATH=c:\ndsdev\devkitarm\bin;c:\msys\bin
SET NDSLIBPATH=/c/ndsdev/ndslib/
make
pause


Chetic and Chuckster: Is the double white screen using the template.nds.gba in the arm9 folder in the zip, on hardware and (just to be sure) with multi-ROM off? I tried it just now right out of the zip and it worked fine... I'm using passme+EZF, for hardware comparison.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#44063 - Veg - Sun May 29, 2005 10:09 pm

DekuTree64 wrote:
I could make a MOD appending tool that also appends the number of files it found, and then it could work without recompiling.


That'd be cool, but if it's a lot of work, I'll try to set up the whole ndslib thing. I should probably have done it a while ago anyway.

#44069 - doublec - Sun May 29, 2005 10:40 pm

I had problems with double white screens when linking largish binary files into my own applications with an older devkitpro version. Maybe this is the problem? Upgrading to the latest version fixed it for me.

#44073 - TheChuckster - Sun May 29, 2005 11:21 pm

I am using the ndslib CVS recent as of 1 day ago and Devkit Pro r12. I'm using the build.bat file to compile. The included binary works fine on my FlashMe + NeoFlash GBA cart hardware. However, when I try to compile it myself, the problems occur and I get white screens.

#44076 - dovoto - Mon May 30, 2005 1:09 am

I put it into the updated template and it compiles fine. I get the text out put and it responds to touch but there is no sound. I tried a few quick fixes like DC_FlushAll and putting as much as i could into exram but still no luck...How old is your ndslib build deku?
_________________
www.drunkencoders.com

#44081 - DekuTree64 - Mon May 30, 2005 1:34 am

dovoto wrote:
I put it into the updated template and it compiles fine. I get the text out put and it responds to touch but there is no sound. I tried a few quick fixes like DC_FlushAll and putting as much as i could into exram but still no luck...How old is your ndslib build deku?


I grabbed devkitarm off sourceforge and ndslib from the zip on your site yesterday, and those worked fine. Just now though, I grabbed ndslib from CVS and am getting the same problems you are.

From my first couple of tests, the problem does seem to be that ARM7 isn't getting any commands, like the ARM9 is never flushing them from the cache/write buffer. I'll keep fiddling with it for a while and see if I can find what's wrong.


EDIT: Turns out the problem was in the ARM9 makefile, there was no ARM7 bin specified so it was pulling in the default instead of the one in the project... Might want to fix that in the lib. Should be
Code:
ARM7BIN := -7 $(CURDIR)/../../arm7/arm7.bin


Updated the zip on my site with the new version.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#44106 - Chetic - Mon May 30, 2005 10:52 am

DekuTree64 wrote:
Chetic and Chuckster: Is the double white screen using the template.nds.gba in the arm9 folder in the zip, on hardware and (just to be sure) with multi-ROM off? I tried it just now right out of the zip and it worked fine... I'm using passme+EZF, for hardware comparison.


No, I always use .nds because it's 50 times faster than flashing .ds.gba on my EZFA.
I guess maybe you should have someone take a look at it? (I'm assuming you don't have wifi yourself.)
_________________
Packin':
Grey DS with FlashMe v7
1Gbit XG2T 2005 (Neoflash compatible)
GBAMP, Supercard CF, 512Mb Magic Key 3 and EZFA 256Mbit

#44127 - dovoto - Mon May 30, 2005 4:43 pm

Thanks...missed that when updateing my templates for devkitarm r12. Fixed it and uploaded to the cvs and the zip.

Just so you know there is a sync register that can be used to pass commands back and forth which will interupt the other processor. This makes comms a lot cleaner.

Usage:

on arm7:
Code:


void commandRecieved(void)
{
     //low four bits of IPC_SYNC are the command
     
     //do stuff
}
int main(blah..)
{
    ....
    irqSet(IRQ_IPC_SYNC, commandRecieved);
   
    IPC_SYNC =  IPC_IRQ_ENABLE;

     ...
}


on arm9

Code:

IPC_SEND_COMMAND(command);


I use this on my mp3 player at the moment and it works well.
For some reason my irq code causes conflicts with swi calls (i have not implemented a proper irq handler yet).
_________________
www.drunkencoders.com

#44138 - TheChuckster - Mon May 30, 2005 5:19 pm

Now I can see the message on the bottom screen but all I hear is buzzing even with the included binary ROM and TouchX/Y don't update.

#44167 - DekuTree64 - Mon May 30, 2005 8:59 pm

dovoto wrote:
Just so you know there is a sync register that can be used to pass commands back and forth which will interupt the other processor. This makes comms a lot cleaner.

Thanks ;)

TheChuckster wrote:
Now I can see the message on the bottom screen but all I hear is buzzing even with the included binary ROM and TouchX/Y don't update.

Sent you a PM. Sounds like it's a problem related to uploading via WMB, so it's kinda tricky to find what's wrong when I can't test things myself.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#44479 - Darkain - Thu Jun 02, 2005 3:31 am

just tried messing around w/ the mod-player for a bit. i like the idea of having one out in the open like this. :)

would just like to point out tho... have you tried using other MOD files yet? the test file i tried using had the audio samples cut off about 1/4th the way into some of the samples. (the samples are large vocal sections)
_________________
-=- Darkain Dragoon -=-
http://www.darkain.com
DarkStar for Nintendo DS

#44505 - Mollusk - Thu Jun 02, 2005 11:54 am

Ok, I tried it now and it works almost perfectly... The main mod works well, but other mods I've tried just don't feel good (they have clicks/resets). Are there some things I missed ?

#44539 - DekuTree64 - Thu Jun 02, 2005 6:30 pm

Hmm, I haven't had any samples cutting off, and I have tried some mega-sample mods. A couple of songs didn't sound quite right though, but they never sounded right on the GBA version of the player either.

On one, some of the notes just sound a tiny bit off-pitch. The other, pitch slides do bad things. Seems to be wrapping around. Now that I think about it, I think I am letting the periods get close enough to 0 on an unsigned variable for that to happen... I'll fix it later today.

Darkain/Mollusk, if either of you has a minute, would you mind mailing me the mods that caused problems? You can send them to my hotmail account, which is the same as my username, but with a hotmail.com at the end. I'll try them out and see if I can find where the clicks are happening.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#44540 - Mollusk - Thu Jun 02, 2005 6:35 pm

Ok, I'll send them in an hour or two...
Is it possible to add some simple SFX support ? It would just be loading a sound to a given channel not used by the mod player, right ? Lots of people don't use it yet just because of that...

#44554 - DekuTree64 - Thu Jun 02, 2005 8:27 pm

Mollusk wrote:
Ok, I'll send them in an hour or two...

Thanks.
Quote:
Is it possible to add some simple SFX support ?

Possible of course, but I haven't decided how to handle it yet. SFX will have to be loaded into RAM, but I'm trying to steer clear of having to use malloc/free on them.

One possibility would be to make SFX lists, where you tell it a bunch of sounds to load, and they just go into the memory pool with the song, but starting from the top down. Then if you get too many sounds/too big of a song, they'll run into eachother in the middle of the pool and die.

The advantage is that they would all be pre-loaded at the start of a map or whatever, and you'd know exactly how much memory they take. Disadvantage is that you'd have to know every sound that could need to be played on the map ahead of time.

Any other ideas?
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#44556 - strager - Thu Jun 02, 2005 8:37 pm

My (rather stupid) idea:
Have every sound compressed (via software) and put into memory. When it is time to play a sound, extract it quickly (needs to be super-optimized) into a temporary buffer and play it. Will cause a small delay, but gets rid of the overflow problem (most of the time). Same goes for the patterns (for the most part).

I'm no coding guru, but I think this can be accomplished in 20 lines or less.

Or am I completely off and don't have a clue..?

#44559 - tepples - Thu Jun 02, 2005 9:46 pm

If you're looking for only about 4 bits per sample (2:1 vs. the 8-bit samples used in .mod and most .s3m) , audio can be compressed rawther well wtih rapid decompression and minimal audible noise. [plug]Here's some code to do it.[/plug]
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#44715 - Mollusk - Sat Jun 04, 2005 3:53 pm

Just wondering, what audio channels are used ? SInce we can play some sounds using the tutorials out there, would it be possible to use the exact same tutorials to add sound effects, just being careful at not using the same audio channels, or is this impossible ?

#44752 - DekuTree64 - Sun Jun 05, 2005 1:48 am

Mollusk wrote:
Just wondering, what audio channels are used ? SInce we can play some sounds using the tutorials out there, would it be possible to use the exact same tutorials to add sound effects, just being careful at not using the same audio channels, or is this impossible ?


Depends on how many channels your mod uses. If it's an 8 channel mod, it will use channels 0-7. Any above that are safe to use.

There's also the channelBlocked flags in sndVars on the ARM7 that will tell the player not to touch particular channels nomatter what.


As for the bugs, it turns out there was a whole slew of them.
1. I wasn't setting my "shadow" sound channels' loop length to 0 when playing non-looping samples, so things were looping when they shouldn't.

2. I was loading samples with DMA, and dividing the size by 4 because I didn't know the ndslib function did it too.

3. Sample offsets were throwing the loops off. Now it's set up so if a sample offset goes past the loop start, it just starts playing from the loop start (since the hardware can't jump back to before where you start from).

4. Vibrato/tremolo were totally screwy. I was reading off the end of the tables for sine and random modes, and not resetting the vibrato slide amount to 0 after stopping it (that's what was causing the slight off-pitchness). Now it uses temporary vars instead of storing them in the channel structs.

New zip here. Thanks to all who helped catch the bugs!
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#44767 - Darkain - Sun Jun 05, 2005 3:07 am

pimpness, works like a charm. compiles much MUCH smaller now too. instead of a large 400+KB file for code+MOD, its now down to 173KB (142KB just for the MOD). it plays perfectly now. not sure if ya ever got it in the email i sent, but ya, its nice n good now.

anywho, i just sat here and listening to the entire thing, and noticed something. it didnt loop at the end. how much would it take to implement this feature? /me is dieing to get some decent in-game music going. :)
_________________
-=- Darkain Dragoon -=-
http://www.darkain.com
DarkStar for Nintendo DS

#44770 - DekuTree64 - Sun Jun 05, 2005 4:00 am

Yeah, the ROM-bloater was the huge 256KB array I had for the memory pool. When I tried it without VAR_IN_EXRAM it didn't bloat the ROM, but didn't run either. Might have put it in TCM. How do you tell the ndslib makefiles to spit out a map file to see where everything is? It doesn't seem to accept -map when using g++ as the linker.

Anyway, I just hardcoded the pool to address 0x2200000 in the new one, which I don't necessarily like, but it works for a small demo. I guess I could just give up my hatred of new[] and use it instead...

And to answer the actual question, you can use a Bxx in the song to make it loop. More flexible than looping in code so I didn't bother adding it.


Oh, and Dovoto, if you're around, where are those IPC interrupt defines you mentioned before? They don't seem to be anywhere in ndslib, but I would like to do some better comm code to make it work with loading music from filesystems on the GBA cart.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#44791 - dovoto - Sun Jun 05, 2005 9:57 am

I seem to have lost my IPC defines...not sure how i did that :) I will make new ones tomorrow. It sounds awesome though..might be nice to include it as an add-on for ndslib.
_________________
www.drunkencoders.com

#44792 - dovoto - Sun Jun 05, 2005 9:59 am

tepples wrote:
If you're looking for only about 4 bits per sample (2:1 vs. the 8-bit samples used in .mod and most .s3m) , audio can be compressed rawther well wtih rapid decompression and minimal audible noise. [plug]Here's some code to do it.[/plug]


It seems you use a technique similer to adpcm which the DS can play back in hardware...i think compression of sound samples and effects would be pretty slick since playback would be free.
_________________
www.drunkencoders.com

#44800 - strager - Sun Jun 05, 2005 2:43 pm

DekuTree64 wrote:
How do you tell the ndslib makefiles to spit out a map file to see where everything is? It doesn't seem to accept -map when using g++ as the linker.


Type -M "mapname.map", or try it without a space (or quotes). The map file will be printed in the same directory as the resulting .elf file (as I've known...).

I haven't gotten Wifi-Me to work, so I can't test it (yet) for any bugs I might find, but when I do find mmy FlashCard, this'll definately be my first tryout. :-)

#45668 - dovoto - Mon Jun 13, 2005 4:43 pm

I got the ipc defines for sync in finaly as well as an example. Hope work still continues on the mod player.
_________________
www.drunkencoders.com

#46378 - GPFerror - Thu Jun 23, 2005 9:52 pm

very cool, just tested it in latest ideas 1.0.0.5 and while the timing is off on the playback(emu related im guessing), you can actually hear the mod file in the emulator.

#72594 - knight0fdragon - Mon Feb 20, 2006 6:38 am

since im not familiar with the older versions of the lib.... any idea on what to do with this line??

extern const u16 notePeriodTable[] VAR_IN_IWRAM ;

im assuming i need it to point to 0x03800000 but ill grab someone elses take since i cant seem to get this to properly work to make it compat with the new version
_________________
http://www.myspace.com/knight0fdragonds

MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206

#72600 - DekuTree64 - Mon Feb 20, 2006 8:27 am

You can just remove the VAR_IN_IWRAM. It looks like the latest ARM7 linkscript puts variables in iwram by default, and it would still run fine with the table in main RAM anyway.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#72730 - dovoto - Tue Feb 21, 2006 6:31 am

DekuTree64 wrote:
You can just remove the VAR_IN_IWRAM. It looks like the latest ARM7 linkscript puts variables in iwram by default, and it would still run fine with the table in main RAM anyway.


About time for an update...been like a year! :)
_________________
www.drunkencoders.com