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.

Audio > MOD format questions

#27257 - SmileyDude - Thu Oct 07, 2004 6:01 pm

So, I'm thinking of going back, and re-writing my MOD tracker that I was working on almost two years ago. I've been looking at all of the MOD documents that I could find, and there are a few things that I am curious about.

First is the period -- I understand what the period is, but I was wondering what approaches are used in converting that period into a usable frequency. The method I took originally was to build a table of u16s that ranged from 0-4095, and just looked up the period in that table.

I just looked in libmikmod to see how they do it, and apparently, they have a table of periods they search through to find note numbers, and then I assume (haven't looked) that they convert that note number to an actual frequency elsewhere.

The third approach would be to do the division either at load time or when the frequency needs to change.

So, my question is which one should I use? I really don't like that 8k table that I have in my current version -- seems like a bit of a waste. So, I'm really looking at either the second or third option. I like the mikmod method, because it makes it really easy to display notes if I wanted (not necessary in a game, but for a standalone player it's kinda nice). But, it seems as if the mikmod method throws away information that might make the song sound different.

Am I just worrying too much about nothing here? Does it really make much of a difference if the original period said 603, and I end up using 610 instead, because that was the closest match in the table?

Also, is the third option really feasible on the GBA? Without hardware divide, the period to frequency conversion could be a tad on the slow side -- but, since it only needs to be done when the note changes, or could even be pre-calculated as part of the load routine, it might not be that big of a deal.

EDIT -- I just realized that I said I had a few questions. Well, I did at the start, but I'll just ask the others later :D
_________________
dennis