PC Speaker

Started by
5 comments, last by Mastaba 19 years, 8 months ago
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
(0110101101000110)The Murphy Philosophy: Smile . . . tomorrow will be worse.
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')
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
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.
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
(0110101101000110)The Murphy Philosophy: Smile . . . tomorrow will be worse.
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.
.
Middle C is 256Hz, from what I can remember.
If at first you don't succeed, redefine success.
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.
.

This topic is closed to new replies.

Advertisement