Difference between revisions of "SoX (Sound eXchange)"

From HalfgeekKB
Jump to navigation Jump to search
 
Line 1: Line 1:
''SoX (Sound eXchange)'' is a GPL command-line sound processor available from http://sox.sourceforge.net/.
+
'''SoX (Sound eXchange)''' is a GPL command-line sound processor available from http://sox.sourceforge.net/.
  
 
I haven't used it yet, but I wanted to start taking notes on it; it may become useful for writing sound scripts. :-)
 
I haven't used it yet, but I wanted to start taking notes on it; it may become useful for writing sound scripts. :-)

Revision as of 16:48, 9 November 2005

SoX (Sound eXchange) is a GPL command-line sound processor available from http://sox.sourceforge.net/.

I haven't used it yet, but I wanted to start taking notes on it; it may become useful for writing sound scripts. :-)

boutell.com scripts

Concatenating two .wav files

This is from http://www.boutell.com/scripts/catwav.html.

#!/bin/sh
sox $1 -r 44100 -c 2 -s -w /tmp/$$-1.raw
sox $2 -r 44100 -c 2 -s -w /tmp/$$-2.raw
cat /tmp/$$-1.raw /tmp/$$-2.raw > /tmp/$$.raw
sox -r 44100 -c 2 -s -w /tmp/$$.raw $3
rm /tmp/$$*.raw

Generating silence

This is from http://www.boutell.com/scripts/silence.html. Even though I like Perl a whole lot, I'd probably be inclined to just dd from /dev/null and sox it as a raw file.

#!/usr/bin/perl

$seconds = $ARGV[0];
$file = $ARGV[1];
if ((!$seconds) || ($file eq "")) {
        die "Usage: silence seconds newfilename.wav\n";
}

open(OUT, ">/tmp/$$.dat");
print OUT "; SampleRate 8000\n";
$samples = $seconds * 8000;
for ($i = 0; ($i < $samples); $i++) {
        print OUT $i / 8000, "\t0\n";
}
close(OUT);

system("sox /tmp/$$.dat -b -r 44100 -c 2 -s -w $file");
unlink("/tmp/$$.dat");