Assembly sound programming
I've found in one of my assembly books, code for a function that'll generate sound at a certain frequency for a certain duration in milliseconds. I've done some work with it and understand that to write simple melodies I'll just have to encode the notes/frequencies and duration of each. That's not really a problem.
However, I'm not sure how to properly integrate this with the small scale game I'm writing (likely something Mario-ish).
Right now, I sit in a loop that checks for a run flag. If the flag is not set, jump to begin again, otherwise check/apply input etc.
The flag is set in my callback function that is called 18.2 times per second. I'm working on a better timer but I plan on it working in the same fashion anyway.
My question is, if I write a little melody, how do I integrate it with my main loop? Since playing a frequency for xms blocks any further processing for xms, I obviously can't be constantly generating sound. Could I get away, in a 20 loops per second scenario, with generating sound for 1/40s each loop? I'm going to test this out after I've cleaned up some implementation details, but I though I'd ask before I spend too much time on what may be the wrong path.
Cheers.
Quote:Original post by kordova
The speaker.
[wow]
If you use DOS, you can hook up with the timer interrupt.
It won't work on any recent OS, though.
Do you really want to use the PC speaker?
Quote:Original post by darookieIt's working on XP. (Probably due to XP's 16-bit emulation.)Quote:Original post by kordova
The speaker.
It won't work on any recent OS, though.
Quote:Original post by darookieGood point. That'd make more sense than putting it in the loop I suppose. I'll try it out. Thanks!
If you use DOS, you can hook up with the timer interrupt.
Quote:Original post by darookieI want to generate sound in a simple and painless fashion.
Do you really want to use the PC speaker?
[Edited by - kordova on October 11, 2004 9:00:08 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement