home *** CD-ROM | disk | FTP | other *** search
/ Groovy Bytes: Behind the Moon / groovybytes.iso / GROOVY / SND_TOOL / WM10.ZIP / DOC.DAT / soxtips.txt < prev    next >
Encoding:
Text File  |  1995-08-30  |  5.0 KB  |  131 lines

  1.  SOX usage:
  2.  
  3.      SOX [options] <from-file-args> <to-file-args> [<effect> [<effect-args>]]
  4.  
  5.  First off: the -V option makes SOX print out its idea of what it is doing.  
  6.  -V is your friend.
  7.  
  8.      SOX -V <from-file-args> <to-file-args>
  9.  
  10.  <from-file-args> and <to-file-args> are the same. They are a series of options
  11.  followed by a file name. The suffix on the file name usually is the file 
  12.  format type. The "-t xx" option overrides this and tells SOX that the file 
  13.  format is "xx". The "-u/-s/-U" arguments say that the file is in unsigned, 
  14.  signed, or u-law format. The "-b/-w" arguments say that the file is in byte- 
  15.  or word-size (2 byte) samples. The "-r number" argument says that the sample 
  16.  rate of the file is "number".
  17.  
  18.  The extensions ub, uw, sb, sw, and ul correspond to raw data files of formats 
  19.  unsigned byte, unsigned word, signed byte, signed word, and u-law byte. Thus, 
  20.  "-t ul" is shorthand for "-t raw -U -b".
  21.  
  22.  These conversions clip data and thus reduce sound quality, so be careful:
  23.  
  24.                              ■ Word to u-law.
  25.                              ■ Word to byte.
  26.                              ■ U-law to byte.
  27.                              ■ Reduction in sample rate.
  28.  
  29.  Any reduction in the sample data rate loses information and adds noise. An 
  30.  increase in the data rate doesn't lose much information, but does add noise.  
  31.  See the note below on low-pass filtering.
  32.  
  33.  To convert U-law to something else without clipping, you'll have to convert 
  34.  it to (signed or unsigned) words, which will double the size of the file.
  35.  
  36.  Auto files:
  37.  
  38.  The "Auto" file type reads an unknown file and attempts to discern its binary 
  39.  format.
  40.  
  41.  AIFF files:
  42.  
  43.  AIFF files come with complete headers and other info. They can in fact have 
  44.  multiple sound chunks and picture chunks. SOX only reads the first sound 
  45.  chunk. 
  46.  
  47.  WAV files:
  48.  
  49.  WAVs use the RIFF format, which is Microsoft's needless imitation of AIFF. 
  50.  See above comments.
  51.  
  52.  AIFF and RIFF files need their own librarian programs; SOX can only do a small
  53.  fraction of what they need.
  54.  
  55.  It's best if you can copy or store files in AIFF or WAV format. The sample 
  56.  rate and binary format are marked; also comments may be added to the file.
  57.  
  58.  Sun AU files:
  59.  
  60.  Most AU files you find are in 8khz 8-bit u-law format. This format was the 
  61.  first sound hardware Sun made available. Some of the files have correct 
  62.  headers; some do not. If the file has the header, this should convert it to
  63.  another format:
  64.  
  65.      SOX <file>.AU <to-file-args>
  66.  
  67.  If not, this reads a raw u-law 8khz file:
  68.  
  69.      SOX -t ul -r 8012 <file>.AU <to-file-args>
  70.  
  71.  To convert a file to an old-style Sun .au file:
  72.  
  73.      SOX <from-file-args> -r 8012 -U -b <file>.AU
  74.  
  75.  AU format can have any speed and several data sizes; you need to specify 
  76.  "-r 8012 -U -b" to force SOX to use the old Sun format.
  77.  
  78.  Mac files:
  79.  
  80.  Mac files come in SND, AIFF, and HCOM formats, among others; these are the 
  81.  most common.
  82.  
  83.  SND files are in unsigned byte format with no header. They are either 11025, 
  84.  22050, or 44100 Hz. The speed seems to be a "resource" and doesn't get 
  85.  transported to Unix when the files are. Thus, you just have to know.
  86.  
  87.      SOX -r 11025 -t ub <file>.SND <to-file-args>
  88.      SOX <from-file-args> -r 11025 -t ub <file>.SND
  89.  
  90.  PC files:
  91.  
  92.  There are several PC sound file formats. VOC is common; it has headers. SND 
  93.  and SNDR are for some DOS sound package; I don't know much about them. WAV is 
  94.  the official Microsoft Windows format. WAV has format options for compressed 
  95.  sound; SOX doesn't implement this yet.  
  96.  
  97.  Effects:
  98.  
  99.  A sound effect may be applied to the sound sample while it is being copied 
  100.  from one file to another. Copy is the default effect; i.e. do nothing. 
  101.  Changing the sample rate requires the "rate" effect. This applies a simple 
  102.  linear interpolation to the sample. This is a poor-quality sample changer. 
  103.  After doing a rate conversion, you should try doing a low-pass filter to throw
  104.  away some of the induced noise. Pick a center frequency about 85% of the 
  105.  lower of the two frequencies, or 42.5% of the lower of the two sample rates. 
  106.  (The maximum frequency in a sample is 1/2 of the sample rate).
  107.  
  108.      SOX -r 8000 <file.xx> -r 22050 <tmp.yy>
  109.      SOX <tmp.yy> <file.yy> lowp 3400
  110.  
  111.  or:
  112.  
  113.      SOX -r 44100 <file.xx> -r 22050 <tmp.yy>
  114.      SOX <tmp.yy> <file.yy> lowp 9592
  115.  
  116.  Listen to both <tmp.yy> and <file.yy> and see if the low-pass filter helps. 
  117.  Be sure to do the low-pass filter before clipping the data to a smaller binary
  118.  word size. Say you have a 16-bit CD-quality (44100 hz) AIFF file that you want
  119.  to convert to a Mac sound resource:
  120.  
  121.      SOX -r 44100 <file>.AIFF -r 11025 tmp.sw
  122.      SOX tmp.sw -t ub <file>.MAC lowp 9371
  123.  
  124.  not:
  125.  
  126.      SOX -r 44100 <file>.AIFF -r 11025 tmp.ub
  127.      SOX tmp.ub -t ub <file>.MAC lowp 9371
  128.  
  129.  because you want to do the low-pass filter while you still have sixteen-bit 
  130.  data.
  131.