I want to generate a beep sound with a specific frequency and length (for different sound signals) using the system beeper (and only the speakers if beeper is not available
The most basic beep is still '\a' , if your terminal supports it:
fprintf(stdout, "\aBeep!\n" );