beep() volume

This is a discussion on beep() volume within the C++ Programming forums, part of the General Programming Boards category; is there any way to change the volume of a beep() function in c++? Or can the internal speaker not ...

  1. #1
    Registered User JTtheCPPgod's Avatar
    Join Date
    Dec 2001
    Posts
    44

    beep() volume

    is there any way to change the volume of a beep() function in c++?
    Or can the internal speaker not change in volume?

  2. #2
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    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

  3. #3
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    but it requires very advanced calculations and programming in assembler.
    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!)

    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!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Volume of a Cone Equation always equals 0
    By Devolution in forum C Programming
    Replies: 11
    Last Post: 01-28-2009, 03:13 AM
  2. linux beep function
    By Calef13 in forum C++ Programming
    Replies: 7
    Last Post: 07-14-2007, 02:39 AM
  3. I need to play a pre recorded vox file using C
    By m.sudhakar in forum C Programming
    Replies: 4
    Last Post: 11-17-2006, 06:59 PM
  4. Help! Right Math, Wrong Output
    By verd in forum C Programming
    Replies: 12
    Last Post: 03-15-2005, 07:49 PM
  5. What am I doing wrong? Help please...
    By SprinterSteve in forum C Programming
    Replies: 9
    Last Post: 04-17-2003, 10:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21