Page 1 of 1

AGI Sound Resources

Posted: Wed Jun 25, 2003 12:28 pm
by davinci
Hey guys,

I'm not sure if this is the right forum, but I couldn't find a more suitable one. I have a question about the sound resources in the AGI. I'm currently writing a AGI interpreter for Java (yes, another one) and I have managed to load en read/see logic, picture and view resources, however the sound resources (PCjr) get me confused. to convert to the right frequency I need to do some bit shifting and divide the number through some other number, now I did that, but the frequencies just don't make sense... some are like +40kHz, some frequencies are zero... Now I'm sure the PCjr had good sound for its time, but 112000Hz is more than enough to talk to whales... but it doesn't make sense for game music. It might be some endian problem... I tried to use the code in the AGI specifications on the helllabs website, but it just doesn't seem to make sense... anyone attempted anything like this?

Re:AGI Sound Resources

Posted: Fri Jun 27, 2003 3:05 pm
by ark
I have written code that was able to successfully read AGI sound resources and print out the notes that were in them. The way you read the frequency is to divide 111860 by the frequency divisor that's stored in the sound resource. The frequency divisor is stored in bytes 3 and 4 of the set of 5 bytes that make up a note. It is equal to:

(((byte3 & 0x3f) << 4) | (byte4 & 0x0f))

So, divide 111860 by the result of that, and you should have the frequency. You should only get anywhere near 111860 Hz as your frequency if the frequency divisor is 1.