Jump to content
  • Advertisement
Sign in to follow this  
MrPoopypants

PC Speaker

This topic is 5173 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 know this is a rather broad question, but how would I go about playing the PC speaker at different frequencies, amplitudes and lengths of time? I've been looking all over the web for tutorials, and all the example code I've tried has not worked. I'm looking for a solution in either C++ or Java. Thanks

Share this post


Link to post
Share on other sites
Advertisement
I don't think its possible with java, and I'm fairly certain it is only possible in C++ using an old 16-bit compiler (Borland C++ 4.02 had a function for it). You could also use inline assembly, but I'm fairly certain it will onyl work in 16-bit mode (aka 'dos')

Share this post


Link to post
Share on other sites
With windows platform SDK, use Beep( dwFreq, dwDuration );

EDIT: Be aware that Beep is synchronous : you'll need to execute it in a different thread if you want to run something else.

Share this post


Link to post
Share on other sites
Ah ok, the beep function works.

But, now I how do I go about determining different notes.

From by limited knowledge of music it seems like one can arbitrarily pick a frequency range and divide by 8 to get the frequency of each note. (For example: I'll define my octave between 600Hz-1000Hz. Range of Octave = 400 Hz. Divide by 8 = 50. So a C = 400 Hz, D = 450 Hz, etc...)
Am i somewhat right or just completely off?
Thanks

Share this post


Link to post
Share on other sites
The A above middle C is 440 hertz. The A below middle C is 220 hertz. And to find the change in hertz per note, you would divide by 7, not 8.

Share this post


Link to post
Share on other sites
Quote:
Original post by python_regious
Middle C is 256Hz, from what I can remember.


The International Standard Pitch for middle C is about 282 Hz. However, there is nothing stopping one from using a different scale and defining middle C as 256 Hz, as has been done by many composers.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!