A SOX 1KHz Sinewave Generator Using A Batch File…

Print Friendly

By wisecracker

Hi all…

I don’t think this has been done before but I am open to being corrected…

This batch file generates a 65536 byte binary file to give 8 seconds of pure sinewave at the earphone/speaker output(s)…

It uses ONLY a default Windows 32 bit installation, to Windows 7, except for the installation of SOX

Notepad was the _main_ editor… ;o)

Hopefully the code section does NOT corrupt the binary part which is 8 bytes in size.
If it does then let me know on here and I will post a pointer from where to grab it…
(Hmmm, just did a preview and it looks as though it does… ;o( )

Enjoy…

Code:

REM Prevent echoing to the CLI...
@ECHO OFF
CLS

REM Generate a pure 1KHz sinewave using SOX...
REM $VER: SOX_DEMO.BAT_Version_0.00.10_(C)2013_B.Walker_G0LCU.

REM This script uses standard Notepad and a default Windows 32 bit install ONLY...
REM It requires no extra installs except SOX itself...
REM The 8 bytes of binary was also generated inside the default Windows OS to windows 7... ;o)

REM Create an 8 byte binary _string_ first for 1 complete sinewave cycle...
SET "rawfile=€&&€ÙþÙ"

REM Write the 8 bytes of binary data to disk in your default TEMP folder...
ECHO | SET /P="%rawfile%" > %TEMP%.SINEWAVE.RAW

REM Append to the file in powers of 2 to 8*(2^13) = 65536 bytes...
FOR /L %%n IN (1,1,13) DO TYPE %TEMP%.SINEWAVE.RAW >> %TEMP%.SINEWAVE.RAW

REM The path is where a default install of SOX resides...
REM Now play the tone burst for around 8 to 9 seconds...
C:PROGRA~1SOX-14-4-1SOX -b 8 -r 8000 -e unsigned-integer -c 1 %TEMP%.SINEWAVE.RAW -d

REM 1KHz sinewave demo end...
REM ENjoy finding simple solutions to often very difficult problems...


…read more

Source: FULL ARTICLE at The UNIX and Linux Forums

FavoriteLoadingAdd to favorites

Leave a Reply

Your email address will not be published. Required fields are marked *