Page 1 of 1

Is There A Quicker Way To Make The BEEP Sound In Batch?

Posted: 31 May 2011 17:18
by nitt
Is There A Quicker Way To Make The BEEP Sound In Batch?

The only way I know of how to make the BEEP sound is by echoing the BELL character, which is Ascii number 7. Since I can't exactly type the BELL character, I wrote a quick script to retrieve it for me:

Code: Select all

@echo off
echo wscript.echo(chr(7)) > ~tmp.vbs
for /f %%a in ('cscript ~tmp.vbs') do (set beep=%%a)
del ~tmp.vbs
echo %beep%
pause


This sets the variable "beep" to the bell. Now if I echo "%beep%" it will make the BEEP noise.

I was thinking of just making a BEEP command in C++, but I wanted to do it without using any commands other than the built-in ones.

And also if you can provide a way to use this without using a TEMP file. That would help.

Re: Is There A Quicker Way To Make The BEEP Sound In Batch?

Posted: 31 May 2011 17:23
by Cleptography
Good question, never really messed around with the sounds in win, I know of the vbscript way you have displayed, I know autoit can do this easily.

Re: Is There A Quicker Way To Make The BEEP Sound In Batch?

Posted: 31 May 2011 17:26
by orange_batch
echo:

(bullet character)

Ctrl+G in Command Prompt to type it.

Re: Is There A Quicker Way To Make The BEEP Sound In Batch?

Posted: 31 May 2011 17:30
by dbenham
nitt wrote:Since I can't exactly type the BELL character, I wrote a quick script to retrieve it for me:

You can type the BELL character. Simply press <Ctrl>G (hold down control key and press G). Alternatively you can hold down the <Alt> key and type 007 on the numeric key pad. The <Alt> method words for any char value betwee 1-255. If you can't get this directly in your editor, you can do it in a command window and echo the value to a file. Your editor should be able to work with it there.

Dave Benham

Re: Is There A Quicker Way To Make The BEEP Sound In Batch?

Posted: 31 May 2011 17:31
by nitt
orange_batch wrote:echo:

(bullet character)

Ctrl+G in Command Prompt to type it.


Oh, that works. xP

-T-h-a-t-w-o-u-l-d-b-e-A-l-t-+-7-,-I-'-m-s-o-d-u-m-b-.-A-l-t-c-o-d-e-s-a-r-e-A-s-c-i-i-.-

I just checked and echoing the bullet character doesn't seem to work in a Batch script... Mine works still, though. :/

Also I just checked Ctrl+G also gets you the bullet character. So type in "echo" then press Ctrl+G and press enter and it beeps.

Re: Is There A Quicker Way To Make The BEEP Sound In Batch?

Posted: 31 May 2011 17:31
by Cleptography
Learn something new everyday.
Nice trick.

Re: Is There A Quicker Way To Make The BEEP Sound In Batch?

Posted: 31 May 2011 17:32
by Cleptography
Now is there a way in batch that can control the frequency like in autoit?

Re: Is There A Quicker Way To Make The BEEP Sound In Batch?

Posted: 31 May 2011 17:34
by orange_batch
No.

Re: Is There A Quicker Way To Make The BEEP Sound In Batch?

Posted: 31 May 2011 17:40
by Ed Dyreen
:lol: :lol: XP .CMD &.BAT compatible :!: :!:

Code: Select all

CSOUND 523 659 523 659 523
CSOUND 1046 1318 1046
CSOUND 220(2) 294(4)
CSOUND 1046,2093,1318,2637,1568,3136,2093,4186(4)
CSOUND 4186,2093,3136,1568,2637,1318,2093,1046(4)
CSOUND 523 0(17) 523 0(17) 523 0(17) 523 0(17) 1046(6)


It is com of 1kb, if u tell me how, I decompile it for u with debug, so I can post the ASM code :!:

Re: Is There A Quicker Way To Make The BEEP Sound In Batch?

Posted: 31 May 2011 17:43
by nitt
Ed Dyreen wrote::lol: :lol: XP compatible :!: :!:

Code: Select all

CSOUND 523 659 523 659 523
CSOUND 1046 1318 1046
CSOUND 220(2) 294(4)
CSOUND 1046,2093,1318,2637,1568,3136,2093,4186(4)
CSOUND 4186,2093,3136,1568,2637,1318,2093,1046(4)
CSOUND 523 0(17) 523 0(17) 523 0(17) 523 0(17) 1046(6)


It is com of 1kbs, if u tell me how, I decompile it for u with debug, so I can post the ASM code :!:


CSOUND? That's on XP? I've never heard of that command...
DEBUG also isn't on my 64bit. :<

I wanted to be able to write COM files from the console but there wasn't DEBUG, so I wrote COMWRITER. If you care to see that PM me.

Re: Is There A Quicker Way To Make The BEEP Sound In Batch?

Posted: 31 May 2011 17:45
by Cleptography
we can do it like this to

Code: Select all

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.

Re: Is There A Quicker Way To Make The BEEP Sound In Batch?

Posted: 31 May 2011 17:49
by Ed Dyreen
What is the command? I really don't know?

Don't remember, we use it sometimes when debugging ???

CSOUND.COM > DEBUG /???? "CSOUND.TXT"

Where do I drop this file, so you can get to it :?:

Re: Is There A Quicker Way To Make The BEEP Sound In Batch?

Posted: 02 Jun 2011 08:25
by Ed Dyreen

Re: Is There A Quicker Way To Make The BEEP Sound In Batch?

Posted: 02 Jun 2011 08:34
by nitt


CSOUND is a 16bit COM file. It doesn't work on my computer.

However, I did write a BEEP command in C++, so it doesn't use .NET framework like my others do. Ir lets you specify the frequency and the duration of the beep.

http://dl.dropbox.com/u/10434417/releases/commands/BEEP.exe

It's actually a very basic script. Here is all it took:

Code: Select all

#include <windows.h>
#include <iostream>
#include <fstream>

int main(int argcount,char* args[])
{
    if (args[1] != 0)
    {
    int freq = atoi(args[1]);
    int dur = atoi(args[2]);
    Beep(freq,dur);   
   

 if (args[1][0] == '/' && args[1][1] == '?')
    {
    std::cout << "\nPlays a BEEP with a specified duration and frequency.\n\nBEEP [frequency] [duration]\n\nExample: BEEP 1000 500\n";
    }
   
    }
    else
    {
        std::cout << "BEEP /? for help.\n";
        }
}


There's actually a Beep function in c++.