Sign in to follow this  

Assembly sound programming

This topic is 4815 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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?


Share this post


Link to post
Share on other sites
Quote:
Original post by darookie
Quote:
Original post by kordova
The speaker.

It won't work on any recent OS, though.
It's working on XP. (Probably due to XP's 16-bit emulation.)

Quote:
Original post by darookie
If you use DOS, you can hook up with the timer interrupt.
Good point. That'd make more sense than putting it in the loop I suppose. I'll try it out. Thanks!

Quote:
Original post by darookie
Do you really want to use the PC speaker?
I want to generate sound in a simple and painless fashion.

[Edited by - kordova on October 11, 2004 9:00:08 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by kordova
Quote:
Original post by darookie
Do you really want to use the PC speaker?
I want to generate sound in a simple and painless fashion.

The Win32 waveout API can help you with that.
There's an article here that describes it pretty well.

Good luck,
Pat.

Share this post


Link to post
Share on other sites

This topic is 4815 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this