October 26, 2024
Chicago 12, Melborne City, USA
C#

Bell sound works, but Beep does not produce sound without using headphones


Exactly the title. I am trying to use Beep from windows.h in C, however the beep sound (I’m talking about the one similar to the "BIOS beep") does not work as intended unless I have my headphones on. Even the alternative MessageBeep(-1) does not produce any sound without headphones, however BEL or '\a' gives the MessageBox sound as intended.

I do have speakers on without the help of the headphones, since I can play music without them. I did notice a suspecting thing though — when I press the volume mixer it should play a sound, but that only happens when I am on headphones. No such sound when I’m using the internal speaker.

I also did a sound test of my internal speaker from the Windows Settings; both left and right play the test sound okay.

Anyway, here’s a summary snippet.

#include <stdio.h>
#include <windows.h>
int main(void) {
    // Plays nothing on internal, basically equivalent to Sleep(2000).
    // Meanwhile, it does its intended function on headphones.
    Beep(1000, 2000);
    // This produces a message box sound on headphones, 
    // but does not produce anything on the internal speaker.
    MessageBeep(-1);
    // This produces a message box sound, not the BIOS beep sound.
    printf("\a");
    return 0;
}

I appreciate any help, thank you!



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video