dos command prompt for producing sound

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
nikihela
Posts: 1
Joined: 05 Mar 2013 05:31

dos command prompt for producing sound

#1 Post by nikihela » 15 Mar 2013 16:09

What is the dos command prompt for producing sound at a certain frequency? I used to know this well. There is a dos command that you type followed by or preceeded by a number such as 19550 which is a specific frequency the computer would then produce. I'd like help with the actual command and the syntax for using it. I've forgotten it altogether otherwise. Thanks.
____________________
Last edited by nikihela on 17 Mar 2013 14:02, edited 1 time in total.

mfm4aa
Posts: 70
Joined: 13 Feb 2013 14:02
Location: Europe

Re: dos command prompt for producing sound

#2 Post by mfm4aa » 15 Mar 2013 16:39

There is no DOS command making noise.

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: dos command prompt for producing sound

#3 Post by Squashman » 15 Mar 2013 16:44

dont remember doing this in batch but do recall doing it in basic many many years ago.

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: dos command prompt for producing sound

#4 Post by Ed Dyreen » 15 Mar 2013 16:46

nikihela wrote:What is the dos command prompt for producing sound at a certain frequency? I used to know this well. There is a dos command that you type followed by or preceeded by a number such as 19550 which is a specific frequency the computer would then produce. I'd like help with the actual command and the syntax for using it. I've forgotten it altogether otherwise. Thanks.
The only character that produces sound is the BELL character. The command you used was an external command. Google cSound.COM

CSOUND is freeware by Horst Schaeffer - no warranties of any kind
15 DEC 1996

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: dos command prompt for producing sound

#5 Post by abc0502 » 15 Mar 2013 17:20

There is another way, not involving numbers but it works.

Code: Select all

rundll32 user32.dll,MessageBeep

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: dos command prompt for producing sound

#6 Post by foxidrive » 16 Mar 2013 03:11

Qbasic should still output sound - available on Win9x cdroms and from MSDos.

It's a dos based BASIC IDE.

EDIT:

Qbasic and Csound don't reliably produce sound in Windows 8.

Aacini
Expert
Posts: 1914
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: dos command prompt for producing sound

#7 Post by Aacini » 20 Mar 2013 21:40

nikihela wrote:What is the dos command prompt for producing sound at a certain frequency? I used to know this well. There is a dos command that you type followed by or preceeded by a number such as 19550 which is a specific frequency the computer would then produce. I'd like help with the actual command and the syntax for using it. I've forgotten it altogether otherwise. Thanks.


More than 20 years ago I wrote SOUND.COM auxiliary program that sound the speaker at a given frequency, and distributed a few copies of it. Perhaps you used one of those copies? :)

I have resurrected that program. Its parameters are several frequency/duration pairs; the frequency is given in Hertz and the duration in ticks where one tick=1/18.2065 second, that is, 18 ticks are equal to one second, approximately. For example, the command below play the first four notes of "Frère Jacques" (Brother John) popular french song for half second each:

Code: Select all

SOUND 349/9 392/9 440/9 349/9

I also wrote an auxiliary file with definitions for standard frequencies and durations of musical notes:

Code: Select all

@echo off

rem SOUND-INC.BAT Auxiliary definition file for SOUND.COM command
rem Antonio Perez Ayala


rem Standard note durations in ticks for BPM=273:

set W=16&       set H=8&        set Q=4&        set E=2
set W.=24&      set H.=12&      set Q.=6&       set E.=3
set W..=28&     set H..=14&     set Q..=7


rem Standard frequencies in Hertz per note for octaves 1 to 7

set notes=0
for %%a in (B A# A G# G F# F E D# D C# C) do (
   set /A notes+=1
   set note[!notes!]=%%a
)

rem Define octave 7
set i=0
for %%a in (3951 3729 3520 3322 3136 2960 2794 2637 2489 2349 2217 2093) do (
   set /A i+=1
   for %%i in (!i!) do set !note[%%i]!7=%%a
)

rem Define octaves 6 down to 1
for /L %%o in (6,-1,1) do (
   set /A o=%%o+1
   for /L %%i in (1,1,%notes%) do (
      set /A "!note[%%i]!%%o=(!note[%%i]!!o!+1)/2"
   )
)

rem Standard value to insert silences (rests):
set R=10


rem SOUND-INC.BAT End of File

The auxiliary variables allows to write simple melodies in a very easy way. For example:

Code: Select all

@echo off
setlocal EnableDelayedExpansion

rem Example of a melody played via SOUND.COM auxiliary program
rem Antonio Perez Ayala

if not exist Sound.com call :MakeSound.com

rem Load standard duration and note values
call Sound-Inc

rem Redefine Half and Quarter note durations to play this melody faster
set H=6
set Q=3

rem Define parts that repeats of "MOROS y CRISTIANOS" (MOOR and CRISTIAN) melody
rem (folkloric mexican music), divided in four quarters per |measure|.

rem       4 / 4       |      1       2        3        4 |      1       2        3       4
set MyC_Part1_1and2of4=%C5%/%Q% %R%/%Q% %C5%/%Q% %B4%/%Q% %C5%/%Q% %R%/%Q% %G4%/%Q% %R%/%Q%

rem                   |      1       2        3        4 |      1       2        3        4 |      1        2        3        4 |      1-2      3-4
set   MyC_Part1_3-4of4=%G4%/%Q% %R%/%Q% %A4%/%Q% %B4%/%Q% %C5%/%Q% %R%/%Q% %B4%/%Q% %A4%/%Q% %G4%/%Q% %F4%/%Q% %E4%/%Q% %F4%/%Q% %G4%/%H%  %R%/%H%

rem                   |      1       2        3        4 |      1       2        3        4 |      1        2        3        4
set     MyC_Part2_6of8=%G4%/%Q% %R%/%Q% %D4%/%Q% %F4%/%Q% %E4%/%Q% %R%/%Q% %C4%/%Q% %E4%/%Q% %G4%/%Q% %F4%/%Q% %E4%/%Q% %D4%/%Q%

rem Play the melody appending missed parts

sound %MyC_Part1_1and2of4%  %MyC_Part1_1and2of4%
sound %MyC_Part1_3-4of4%
rem Repeat Part 1
sound %MyC_Part1_1and2of4%  %MyC_Part1_1and2of4%
sound %MyC_Part1_3-4of4%

rem                   |      1       2        3        4 |
sound %MyC_Part2_6of8% %E4%/%Q% %R%/%Q% %C4%/%Q% %E4%/%Q%
rem                   |      1-2              3-4        |
sound %MyC_Part2_6of8% %C4%/%H%          %R%/%H%
rem Repeat Part 2
sound %MyC_Part2_6of8% %E4%/%Q% %R%/%Q% %C4%/%Q% %E4%/%Q%
sound %MyC_Part2_6of8% %C4%/%H%          %R%/%H%

goto :EOF


rem Create Sound.com auxiliary program (requires Debug.com DOS command)

:MakeSound.com
(
echo E100  EB 33 53 79 6E 74 61 78 3A 20 53 4F 55 4E 44 20
echo E110  66 72 65 63 75 65 6E 63 79 2F 74 69 63 6B 73 20
echo E120  2E 2E 2E 0D 0A 24 00 00 00 00 00 2E FE 0E 2A 01
echo E130  2E FF 2E 26 01 B0 1C B4 35 CD 21 89 1E 26 01 8C
echo E140  06 28 01 8D 16 2B 01 B0 1C B4 25 CD 21 8C D8 8E
echo E150  C0 50 B0 B6 E6 43 58 8A 0E 80 00 32 ED E3 0B 8D
echo E160  3E 81 00 B0 20 FC F3 AE 75 0D 52 8D 16 02 01 B4
echo E170  09 CD 21 5A E9 98 00 8D 75 FF AC 3C 20 74 FB 3C
echo E180  30 72 F1 3C 39 77 ED 2C 30 8A D8 32 FF B9 0A 00
echo E190  AC 3C 30 72 0E 3C 39 77 0A 25 0F 00 93 F7 E1 03
echo E1A0  D8 EB ED 3C 2F 75 68 81 FB 0F 27 77 1C 83 FB 14
echo E1B0  7C 17 BA 12 00 33 C0 F7 F3 50 E6 42 8A C4 E6 42
echo E1C0  58 50 E4 61 0C 03 E6 61 58 AC 3C 30 72 41 3C 39
echo E1D0  77 3D 2C 30 8A E0 AC 3C 30 72 0C 3C 39 77 08 2C
echo E1E0  30 D5 0A 8A E0 EB EF 3C 0D 74 04 3C 20 75 20 0A
echo E1F0  E4 74 0B 88 26 2A 01 80 3E 2A 01 00 75 F9 50 E4
echo E200  61 24 FC E6 61 58 80 7C FF 0D 74 03 E9 6B FF 50
echo E210  E4 61 24 FC E6 61 58 C5 16 26 01 B0 1C B4 25 CD
echo E220  21 32 C0 B4 4C CD 21
echo RCX
echo 127
echo NSOUND.COM
echo W
echo Q
) | debug > NUL
exit /B

Previous program create SOUND.COM file. Note that this program use DEBUG.COM DOS command; if you have not it, you may create SOUND.COM.HEX file with just the hexadecimal digits of the code with no spaces and convert they to the .COM equivalent file with HexToBin.bat conversion program.

I need to update this program to Win-32 API format in order to use it in 64-bits Windows versions.

Enjoy! :D

Antonio

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: dos command prompt for producing sound

#8 Post by foxidrive » 20 Mar 2013 22:49

When I try sound 1000/180 in Windows 8 32 bit there is no sound produced, and the prompt returns after 10 seconds or so.

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: dos command prompt for producing sound

#9 Post by Squashman » 21 Mar 2013 04:42

I look forward to the 64 bit version.

Aacini
Expert
Posts: 1914
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: dos command prompt for producing sound

#10 Post by Aacini » 21 Mar 2013 05:36

foxidrive wrote:When I try sound 1000/180 in Windows 8 32 bit there is no sound produced, and the prompt returns after 10 seconds or so.


Yes, the program check the given values and produce sound only if the frequency is in 20-9999 range. The upper limit is the "0F 27" 16-bits value (in reversed order) at offset 1A9, and the lower limit is the "14" 8-bits value at offset 1AF, so you may modify these values and use SOUND.COM with a different valid range of frequencies.

This is a more detailed description of the required changes: decimal value 9999 is 270F in hexadecimal; you may check this with SET /A 0x270F command. The bytes 27 0F are placed in reversed order at positions 10 and 11 in the line that start with echo E1A0, so you may modify these bytes with the hexadecimal value for the upper limit you wish. In the same way, the lower limit is the "14" that appear at end of the same line.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: dos command prompt for producing sound

#11 Post by foxidrive » 21 Mar 2013 08:15

Que? I used 1 kHz. There was no sound. Your batch file produced no sound.

Aacini
Expert
Posts: 1914
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: dos command prompt for producing sound

#12 Post by Aacini » 21 Mar 2013 13:09

Oops! I thought you reported that precisely with sound 1000/180 the program produce no sound, but I assumed that with other values the program works correctly (and confused 1000 with 10000). :oops:

So SOUND.COM does not produce sound with Windows 8 32-bits, although the delay code works correctly? It is possible that Win-8 does not allow the .COM code to access the speaker circuitry like previous versions. SOUND.COM works perfectly in my Windows XP, but my first tests with SOUND.EXE Win-32 API code in the same Windows XP mark a run-time error!

Antonio

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: dos command prompt for producing sound

#13 Post by foxidrive » 21 Mar 2013 15:31

It occurs to me that the later model motherboards no longer have an onboard piezo electic speaker, as a cost saving measure. I think mine doesn't have one.

Can your utility output sound from the sound card instead?

carlsomo
Posts: 91
Joined: 02 Oct 2012 17:21

Re: dos command prompt for producing sound

#14 Post by carlsomo » 16 Apr 2013 21:22

I use this, try googling

Code: Select all

c:\>buzzer.exe
BUZZER v0.7
Copyright (c) 2009 by LovePimple

Sounds a tone of the specified frequency for a duration in milliseconds.
Usage: BUZZER <frequency> <duration> [number of beeps] [delay between beeps]

Frequency: 37 - 17000 Hz | Duration: 50 - 20000 ms
Number of beeps: 0 - 1000 | Delay between beeps: 10 - 5000 ms

+-------------------------------------------------+
| C      |  131  |  262  |  523  |  1040  |  2093 |
| C#/Db  |  139  |  277  |  554  |  1103  |  2217 |
| D      |  147  |  294  |  587  |  1176  |  2349 |
| D#/Eb  |  156  |  311  |  622  |  1241  |  2489 |
| E      |  165  |  330  |  659  |  1311  |  2637 |
| F      |  175  |  349  |  698  |  1391  |  2794 |
| F#/Gb  |  185  |  370  |  740  |  1488  |  2960 |
| G      |  196  |  392  |  784  |  1568  |  3136 |
| G#/Ab  |  208  |  415  |  831  |  1662  |  3322 |
| A      |  220  |  440  |  880  |  1760  |  3520 |
| A#/Bb  |  233  |  466  |  932  |  1866  |  3729 |
| B      |  248  |  494  |  988  |  1973  |  3951 |
+-------------------------------------------------+


Post Reply