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 > Audio codec recommendations

#72394 - Lazy1 - Sat Feb 18, 2006 7:12 am

Can someone reccommend an audio decoder which is small ( both in filesize and code size ) and can run on the arm7?
I have tried lowmem tremor ( fixed point ogg decoder ) but that is too big and won't fit into the arm7 binary.

It must be run on the arm7 since the wolfenstein game logic and yet to be optimized software renderer take up all of the arm9's time.

I just looked at GSM but at anything less than 48000hz the music starts to sound bad and each song is still over 2mb ( registered wolf3d has 27 music tracks ).

Any suggestions on a decoder or docs on how to increase the max arm7 size are appreciated.

#72402 - gladius - Sat Feb 18, 2006 8:16 am

Didn't wolfenstien use simple MIDI? That should be really easy to emulate on the DS. Just write a small MIDI player and grab some general midi samples that are ADPCM compressed for size and you are good to go.

The arm7 can access data from main 4 megabytes of ram, so you can store the samples there if neccesary as well.

I also see it has a SNES port. You could always use my PocketSPC arm7 core :). That way each song would only be 64k.

#72403 - Lazy1 - Sat Feb 18, 2006 8:59 am

Nope, it used a different format ( IMF ).
The SDL port I'm porting from comes with an OPL2 emulator but unfortunately it does not run on the DS.

Adplug can play/read imf files but uses the same emulator which had me converting the files on the PC first.
It only takes a few seconds to convert each song and generally sounds good, nothing compared to a real soundblaster but still good.

I was really hoping to use ogg files, the size was good ( < 600kb per song ) and the library had ARM optimizations.

#72408 - gladius - Sat Feb 18, 2006 10:38 am

Oops, I see. Well, IMF is a more complicated beast. Doing OPL emulation on the arm7 is possible, although it might require some custom asm.

I took a quick glance at adplug and it seems that the OPL emulator isn't that complicated. What prevents it from running on the DS?

#72410 - Lazy1 - Sat Feb 18, 2006 11:00 am

It's been a while since I tried it but I believe a call to malloc() was failing.
In addition I do not know ARM assembly, or the OPL specs so writing my own emulator is out :(

[EDIT]
Oddly enough, it's initializing fine now - hmm, I wonder what was causing it to fail before.
Oh well, now I gotta figure out how to use this thing :)

#72441 - tepples - Sat Feb 18, 2006 4:51 pm

The Super NES and Atari Jaguar versions of Wolfenstein 3D used what sounded like tracked music. Any modplayer should do the trick.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#72494 - Lazy1 - Sun Feb 19, 2006 12:27 am

I'm porting the SDL version where the music is basically hardware adlib commands.
I have looked at the OPL emulator and it looks like it could work on the ds but it is not documented very well.
Also undocumented is the original music code that came with the SDL wolfenstein port, all the OPL commands are there but there are no comments saying what they do or why they're there.

I've looked into adlib programming but all the documents I've found either don't explain enough or expect you to already be an expert on sound.
I can't give up on this either, if I get that OPL emulator working no sound conversion is needed on the PC side and everyone can have not only music but other digital sfx like picking up ammo, ect...

If anyone has worked with adlib sounds or the YM3812 directly let me know, I need help on this one.

Thanks for all the suggestions so far.

#72608 - Lazy1 - Mon Feb 20, 2006 11:31 am

Well, I've looked at a few OPL examples but nothing helped me understand anything.
I saw a lot of emulator projects that use the emulator, but all they need to do is redirect I/O accesses to it and don't have to know anything about the OPL chip itself.
I did find an IMF player which worked by writing data to OPL registers, however my lack of sound knowledge caused the output to be only .45s long and just random noise.

Either I _somehow_ figure this out or find a suitable format to convert the music into - wolf3d won't have music or digitized sound.
I just can't understand sound programming :(

Edit:
_Some_ success, I managed to get recognizable music dumped into a .raw file. It's mostly there except it's extremely sensitive to timing and I have no idea how sound timing works, I'm only getting sound because I'm using hardcoded numbers which seem to be close.

Edit again:
I tried getting the emulator running on the arm7 with no luck ( malloc failed ) and on the arm9 ( way too slow ).

So, it looks like some conversion is needed inorder for this to work.
I looked at GSM again, although it gives a nice filesize it messes up the quieter tones.
I still have to fix my imf->raw dumper since the OPL emulator was specifically modified to play things from wolf3d. Playing them through adplug has some really annoying side-effects.