is there any way to change the volume of a beep() function in c++?
Or can the internal speaker not change in volume?
is there any way to change the volume of a beep() function in c++?
Or can the internal speaker not change in volume?
The internal speaker can only play single tones in one volume.
But it is possible to play normal sound too, like mp3 files, but it requires very advanced calculations and programming in assembler.
I'm not sure, but I think the technique is based on playing single tones very very briefly and thus being able to control the membrane of the speaker directly.
Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling
Exactly! The circuit that the speaker is connected to can be programmed as a multivibrator. You program a counter and it puts-out square waves 'till you tell it to stop. It can also be programmed as a one-shot. This way you can control the volume with pulse-width-modulation. But, you have to trigger every single one-shot pulse with your software. To generate a 5kHz tone this way, you have to write to the one-shot 5000 times per second. (No problem unless you're running a multitasking OS!)but it requires very advanced calculations and programming in assembler.
If I REALLY needed to control the volume I'd do it with hardware... add a potentiometer, or a resistor.
If the beep is just annoying and you want to permanently turn it off, you can unplug it from the motherboard!