#!/usr/bin/perl #srchange_pickL.pl # 2005-05-28 created based on srchange.pl #Author: Mafuyu Kitahara #Purpose: sox: sample rate change, and pick Left channel from a stereo file #Argument: suffix (e.g. wav, aiff) and output sample rate (e.g. 48000, 22500, 8000...) #Input: all files in the current dir #Output: [original name][sample rate].[suffix] die "Usage: perl ~/bin/srchange_pickL.pl [suffix] [sample rate]\n" unless @ARGV; #message print "srchange.pl: change sampling rate using sox\n"; print "Usage: perl srchange.pl [suffix] [sample rate]\n"; print "Example: perl srchange.pl wav 48000\n"; $suffix = $ARGV[0]; $sr = $ARGV[1]; #dir opendir(DIR, "."); @files = (); @files = grep(/(\.$suffix$)/, readdir(DIR)); closedir(DIR); # print @files; # loop for $file (@files) { $basename = `basename $file .$suffix`; chomp($base = $basename); $out = substr($basename, -5, 4); print "processing $base, sr at $sr\n"; `sox $file -r $sr -c 1 ${out}.${suffix} pick -l`; print "$file .... done\n"; } print "all done\n";