home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Sound / SoX / CHEAT < prev    next >
Text File  |  1999-07-18  |  4KB  |  111 lines

  1. CHEAT SHEET
  2. -----------
  3.  
  4. This is a cheat sheet of examples using SOX to do various common 
  5. sound file conversions.  The file format examples are starting
  6. to become dated.  Any offers to update this document to explain 
  7. the ends and outs of each format would be appreciated.
  8.  
  9. In general, sox will attempt to take an input sound file format and
  10. convert it to a new file format using a similar data types and sample
  11. rates.  For instance "sox monkey.au monkey.wav" would try and convert
  12. the mono 8000Hz u-law .au file to a 8000Hz u-law .wav file.
  13.  
  14. If an output format doesn't support the same data types as the input
  15. file then Sox will generally select a default format to save it in.
  16. You can select a data type of your choice using command line options.
  17. You can also override data type values to have a output file of
  18. higher or lower percision data (and thus higher or lower file size).
  19.  
  20. Most file formats that contain complete headers will automatically
  21. convert to a similar format.  This means .wav, .aiff, and .voc files
  22. will readily convert to each other without the need of complex
  23. command lines.
  24.  
  25. If you create a sound file and you can not play it, check to make
  26. sure your sound card to play a file using this data type.
  27.  
  28. SOX is great to use along with other command line programs.  The
  29. currently most used example is to use mpg123 to convert mp3 files
  30. in to wav files.  The following command line will do this:
  31.  
  32. mpg123 -b 10000 -s filename.mp3 | sox -t raw -r 44100 -s -w -c 2 - filename.wav
  33.  
  34. The SUN examples below all assume you have the old SUN voice-quality 8khz 
  35. u-law hardware.  If you do then you will want to have all your .au
  36. files in this format so that you cat do thinks like
  37. "cat soundfile.au > /dev/audio" and you will hear a good file.
  38. If the .AU file doesn't have a proper header, then you'll need the second 
  39. command line to let sox know the values.  If the .AU has a proper
  40. header then you can remove the "-r 8000 -U -b" in front of 
  41. "file.au".
  42.  
  43. SUN .au to Mac .snd:
  44.  
  45.     sox file.au -r 11025 -t ub file.snd
  46. or:
  47.     sox -t ul -r 8000 file.au -r 11025 -t ub file.snd
  48.  
  49. When you copy the file to the Mac, you'll have to set
  50. the sample rate by hand.
  51.  
  52. Mac .snd to SUN .au
  53.  
  54.     sox -r 11025 -t ub file.snd -r 8000 -U -b file.au
  55.  
  56. The Mac file might also be at sample rates 5012, 22050, or 44100.
  57.  
  58. PC .voc to SUN .au
  59.  
  60.     sox file.voc -r 8000 -U -b file.au
  61.  
  62. SUN .au to PC .voc 
  63.  
  64.     sox file.au file.voc 
  65. or:
  66.     sox -r 8000 -t ul file.au file.voc 
  67.  
  68. SUN .au to WAV - without clipping
  69.     
  70.     sox file.au -s -w file.wav
  71. or:
  72.     sox -t ul -r 8000 file.au -s -w file.wav
  73.  
  74. WAV to SUN .au
  75.     
  76.     sox file.wav -r 8000 -U -b file.au
  77.  
  78. WAV to VOC
  79.     sox file.wav -u -b file.voc
  80.  
  81. VOC to WAV
  82.     sox file.voc file.wav
  83.  
  84. Any file to SUN .au
  85.  
  86. sox -t auto file.X -c 1 -t aiff - |  sox -t aiff - -r 8000 -U -b -t au file.au
  87.  
  88. Just convert file format without making a disk file.
  89. Example: convert input stream in AIFF format to output stream in WAV format:
  90.  
  91. sox -t aiff - -t wav -
  92.  
  93. Some people try to put this kind of command in scripts.
  94.  
  95. It is important to understand how the internals of Sox work when
  96. working with compressed audio, including u-law, a-law, ADPCM, or GSM.
  97. Sox takes ALL input data types and converts them to uncompressed
  98. 32-bit signed data.  It will then convert this internal version into
  99. the requested output format.  This means unneeded noise can be introduced
  100. from decompressing data and then recompressing, such as would happen
  101. when reading u-law data and writing back out u-law data.  If possible,
  102. specify the output data to be uncompressed PCM.
  103.  
  104. Under DOS, you can convert several using something similar to the
  105. following command line:
  106.  
  107. FOR %X IN (*.RAW) DO sox -r 11025 -w -s -t raw $X $X.wav
  108.  
  109. Good luck!
  110.  
  111.