SoX - A Sound Converter for DOS and Unix

Creating soundfiles to describe physical systems requires three components. A data file which describes the system, a program that converts this data file into a sound format and a program which will play the sound file.
In many cases the data file will be similar to a file which you use to create a plot. The file to make a two dimensional plot of a sine wave will generally look some thing like,
0	0
0.4	0.3894
0.8	0.7174
1.2	0.9320
1.6	0.9996
2.0	0.9093
2.4	0.6755
 .	 .
 .	 .
Now SoX and most other sound programs can only deal with integers in the range 0 to 255 or 1 to 256 and they need only a set of y-values. To avoid getting confused which program uses which range, we just use a range of 1 to 255. So in theory our data file could look like,
128
177
219
246
254
243
214
 .	
 .	
The sine wave oscillates between -1 and 1 and we want to rescale this to an oscillation between 1 and 255. What you have to do is multiply the old value times 127 and then add 128. This kind of file will work perfectly if you own a Macintosh and have a program like Soundwave. SoX however wants its input file not in ASCII but in binary (=unreadable for normal mortals) format and unfortunately there is no way to display binary data in a useful way, but if you have a file with ASCII data and want to convert it into binary youi can download, compile and use this small C program.
As soon as you have your binary data file and you have SoX installed on your system, you can use it to create your sound file. SoX has lots of options many of which you hopefully never have to use. Most of our soundfiles were created using the following command,

sox -t raw -u -b -r 8000 oldfile.dat -r 8000 -u newfile.au

This takes the binary data file and converts it into a .au. Look at the website for SoX to find out what all the options actually mean.
After that all you need is a program that will play .au files and you probably also want to configure your browser so it plays soundfiles automatically. One of the many websites which have this kind of information is also maintained by NACSE.


Back to the sound page