#8664 - ka_wright - Thu Jul 17, 2003 3:12 pm
Which is preferable? - Writing or obtaining sample mixing code, or does the GBA have some other way of playing multiple samples?
Thanks in advance,
Ken.
#8667 - DekuTree64 - Thu Jul 17, 2003 4:39 pm
Well, the GBA has 2 WAV chanels, and the 4 tone generators GBC had, so you can probably get away with just 2 channels for sound effects, but the music will either have to be GBC style, or you write/download a mixer.
I made a mixer that uses a constant 11% CPU time with 6 total channels, 2 pitched channels to each side (4 chn MOD style), and 2 panned, but not pitched channels for sound effects. The sfx channels just play at whatever the main mixing rate is. I got tired of working on it before I finished the MOD player for it though, but if you want to try writing your own MOD player, I'd be happy to upload the mixer.
#8670 - Touchstone - Thu Jul 17, 2003 6:48 pm
DekuTree64 wrote: |
I made a mixer that uses a constant 11% CPU time with 6 total channels, 2 pitched channels to each side (4 chn MOD style), and 2 panned, but not pitched channels for sound effects. |
I'm curious to know how you resampled your sounds (pitched or whatever it is called when you play the sound in another frequency than what it was originally stored in) and if your algorithm produced good sound quality. I tried to simply do a linear interpolation but it just didn't sound good. Eventually it struck me that I probably missed important peaks in the original sound and it's just not as easy as interpolating between the originial samples. I never figured out how to do this properly though. Any help would be greatly appreciated.
_________________
You can't beat our meat
#8677 - tepples - Thu Jul 17, 2003 8:56 pm
Most modplayer engines for small computer systems such as the GBA just use nearest-neighbor resampling, which causes significant aliasing. If the aliasing annoys you, try using samples that aren't so strongly tonal in the upper half of their frequency response. Yes, this may mean light low-pass filtering or storing the sample at a higher frequency or both.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#8681 - DekuTree64 - Thu Jul 17, 2003 10:52 pm
Yes, it uses nearest neighbor. The quality isn't that good (you can hear some pretty bad aliasing when you ramp the pitch up and down), but I think it's ok for the speed. Takes less than 1K of IWRAM too. 380 bytes, I think. I set up a little demo of it, but I'm having some trouble getting it from my programming computer to this one with an internet connection. This one's floppy drive doesn't work, so I tried zipping it into 64K chunks and transferring it as savegames on my flash cart, but it didn't work... I'll post later if I can come up with something.
#8702 - Touchstone - Fri Jul 18, 2003 10:40 am
Ok, cool. I'll have a go at nearest neighbor. Thanks.
_________________
You can't beat our meat
#8728 - DekuTree64 - Fri Jul 18, 2003 5:49 pm
Ok, I finally got it to work. Had to make a ROM with the whole zip file as an array, and check the data map to see where it was. It's at http://www.angelfire.com/wizard/deku/program/sndmix.zip. Full source and everything, cause I've learned so much from everyone here I figure it's time I gave something back^_^
It works on VBA, but skips occasionally, and makes little clicks when looping, but it seems to work fine on hardware. No clicks at all, using the same headphones I had on the computer. Check the readme for more details.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku