# 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.

## 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 on other sites
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 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 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 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 on other sites
Middle C is 256Hz, from what I can remember.

##### Share on other sites
Quote:
 Original post by python_regiousMiddle 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.

1. 1
Rutin
32
2. 2
3. 3
4. 4
5. 5

• 13
• 73
• 11
• 10
• 14
• ### Forum Statistics

• Total Topics
632967
• Total Posts
3009578
• ### Who's Online (See full list)

There are no registered users currently online

×