PC Speaker Beeps

This is a discussion on PC Speaker Beeps within the C Programming forums, part of the General Programming Boards category; I saw a function a while back which allowed you to chose the pitch of a pc speaker beep (and ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,220

    Question PC Speaker Beeps

    I saw a function a while back which allowed you to chose the pitch of a pc speaker beep (and length)
    it was something like this:

    beepyOn(pitch);
    sleep(1);
    beepyOff();

    can anyone tell me if there is an ansi function for this
    (i don't want printf("\a") because it doesn't let me chose a length)
    or if there is a non-ansi function that is available on djgpp

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    140
    sound(frequency);

    to turn off the speaker call nosound();

    they arent standard but I think djgpp has them in pc.h

    edit:
    and for the length that you want just put a delay() in between ther sound() and nosound().

    int Sound4delay(int frequency, int delay)
    {
    sound(frequency);
    delay(delay);
    nosound();
    return 0;
    }
    Last edited by stupid_mutt; 01-16-2002 at 12:45 PM.

  3. #3
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,220
    It does, thanks.

  4. #4
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,220
    but now i can't get delay(1000) working.

    and sleep() is in seconds on gcc.

    grrr.

    might be to do with win2k, because delay works fine on my win98se machine

  5. #5
    Hamster without a wheel iain's Avatar
    Join Date
    Aug 2001
    Posts
    1,385
    sound, delay and nosound dont work in Borland C++Builder
    (hey basic scores a point here with BEEP)

    i suppose you could write the sound functions in assembler and call them if you really need to.
    Monday - what a way to spend a seventh of your life

  6. #6
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,220
    Yeah I was just making a morse code thing in my bottomless pit of savage, eye-watering boredom.

    Originally posted by iain
    sound, delay and nosound dont work in Borland C++Builder
    (hey basic scores a point here with BEEP)

    i suppose you could write the sound functions in assembler and call them if you really need to.

  7. #7
    Registered User dune911's Avatar
    Join Date
    Sep 2001
    Posts
    140
    another problem:
    i want my program to play some music using the pc speaker sound. i am using win2k and djgpp and i want something like C-D-E-F-G-A-H-C in different lenghts - is there a way to do this?

  8. #8
    Registered User
    Join Date
    Sep 2001
    Posts
    140
    Mutt dos library has a function just for that, too bad djgpp uses such weird assembly or you could use it
    Acos is good

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Outputting many beeps through the pc speaker
    By rllovera in forum C Programming
    Replies: 18
    Last Post: 11-21-2006, 12:24 AM
  2. Replies: 1
    Last Post: 10-27-2006, 02:21 PM
  3. PC Issue: Repeated Long Beeps
    By alphaoide in forum Tech Board
    Replies: 8
    Last Post: 07-19-2005, 09:46 AM
  4. Using PC Speaker and NOT the sound card in a console...
    By Trauts in forum A Brief History of Cprogramming.com
    Replies: 19
    Last Post: 04-09-2003, 09:52 PM
  5. PC Speaker...
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 04-03-2002, 08:19 AM

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