Jump to content

How to make a sound from PC Speaker using 9x GUI batch?


Sfor

Recommended Posts

I've been trying to make a beep by using batch file in a DOS window of 95/98 system. All I could get was a very short sound same as the Windows error condition sound.

Without GUI everything is working as it should to, but in DOS window the PC Speaker sounds are less than audible.

Link to comment
Share on other sites


I wouldn't say it is a ding.wav like sound. It's rather the sound generated when a wrong key is pressed. It's more a tick than a soud. So, it's hardly audible and hardly useful.

Edited by Sfor
Link to comment
Share on other sites

Second try:<br /><br />rundll32 shell32.dll,Control_RunDLL user32.dll,MessageBeep,-1<br /><br />Instead of -1 you can also try 0, 16, 32, 48, 64

Edit:

Ehm, sorry, this doesn't work.

Edited by Mijzelf
Link to comment
Share on other sites

Are you helped by a small executable?

#include <dos.h>
#include <stdlib.h>
#include <stdio.h>

int main( int argc, char **argv )
{
if( argc != 3 )
{
printf( "use beep frequency (Hz) duration (sec)\n" );
return 0;
}

sound( atoi( argv[ 1 ] ) );
sleep( atoi( argv[ 2 ] ) );
nosound();
return 0;
}

Compiled version here

Link to comment
Share on other sites

Well. The program works. But, a batch made that way is hardly a portable one.

Also, I made my own program in Borland Pascal. The resulting EXE file is just a half size of a COM made by C compler.

Program Beep;

uses CRT;

var Tone,Duration: Word;
Check: Integer;

begin
if ParamCount<=2 then
begin
Writeln;
Writeln ('BEEP Frequency Duration');
Writeln;
Writeln (' Frequency - Hz');
Writeln (' Duration - mS');
Writeln;
Tone:=800;
Duration:=1000;
end
else
begin
VAL (ParamStr(1),Tone,Check);
VAL (ParamStr(2),Duration,Check);
end;
Sound (Tone);
Delay (Duration);
NoSound;
end.

Link to comment
Share on other sites

Certain things in 95/98 are backward when it comes to the API, so you have to code for them in assembler instead to get the functionality (which is a pain to be truthful). The program solution is the only valid one for 95/98 for this reason (the HLLs posted have this functionality).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...