home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 November / Chip_2004-11_cd1.bin / zkuste / dolby / download / sox / sox12174.exe / sox12174 / soxexam.txt < prev    next >
Text File  |  2003-03-23  |  21KB  |  538 lines

  1. SoX(1)                               SoX(1)
  2.  
  3.  
  4.  
  5. NAME
  6.        soxexam - SoX Examples (CHEAT SHEET)
  7.  
  8. CONVERSIONS
  9.        Introduction
  10.  
  11.        In  general,  SoX will attempt to take an input sound file
  12.        format and convert it into a new file format using a simi¡
  13.        lar  data  type    and sample rate.  For instance, "sox mon¡
  14.        key.au monkey.wav" would try and convert the  mono  8000Hz
  15.        u-law  sample  .au file that comes with SoX to a 8000Hz u-
  16.        law .wav file.
  17.  
  18.        If an output format doesn't support the same data type  as
  19.        the  input  file     then SoX will generally select a default
  20.        data type to save it in.     You  can  override  the  default
  21.        data  type  selection by using command line options.  This
  22.        is also useful for producing an output file with higher or
  23.        lower precision data and/or sample rate.
  24.  
  25.        Most  file  formats that contain headers can automatically
  26.        be read in.  When working with  header-less  file  formats
  27.        then  a user must manually tell SoX the data type and sam¡
  28.        ple rate using command line options.
  29.  
  30.        When working with header-less files (raw files),     you  may
  31.        take  advantage of the pseudo-file types of .ub, .uw, .sb,
  32.        .sw, .ul, and .sl.  By  using  these  extensions     on  your
  33.        filenames  you  will not have to specify the corresponding
  34.        options on the command line.
  35.  
  36.        Precision
  37.  
  38.        The following data types and formats can be represented by
  39.        their  total  uncompressed bit precision.  When converting
  40.        from one data type to another care must be taken to insure
  41.        it  has    an  equal  or greater precision.  If not then the
  42.        audio quality will be degraded.    This is not always a  bad
  43.        thing  when  your  working with things such as voice audio
  44.        and are concerned about disk space  or  bandwidth  of  the
  45.        audio data.
  46.  
  47.            Data Format    Precision
  48.            ___________    _________
  49.            unsigned byte    8-bit
  50.            signed byte    8-bit
  51.            u-law           14-bit
  52.            A-law           13-bit
  53.            unsigned word   16-bit
  54.            signed word     16-bit
  55.            ADPCM           16-bit
  56.            GSM           16-bit
  57.            unsigned long   32-bit
  58.            signed long     32-bit
  59.            ___________    _________
  60.  
  61.        Examples
  62.  
  63.        Use  the     '-V' option on all your command lines.     It makes
  64.        SoX print out its idea of what is going on.  '-V' is  your
  65.        friend.
  66.  
  67.        To  convert from unsigned bytes at 8000 Hz to signed words
  68.        at 8000 Hz:
  69.  
  70.      sox -r 8000 -c 1 filename.ub newfile.sw
  71.  
  72.        To convert from Apple's AIFF  format  to     Microsoft's  WAV
  73.        format:
  74.  
  75.      sox filename.aiff filename.wav
  76.  
  77.        To  convert  from mono raw 8000 Hz 8-bit unsigned PCM data
  78.        to a WAV file:
  79.  
  80.      sox -r 8000 -u -b -c 1 filename.raw filename.wav
  81.  
  82.        SoX may even be used to convert    sample    rates.     Downcon¡
  83.        verting    will  reduce  the bandwidth of a sample, but will
  84.        reduce storage space on your disk.  All    such  conversions
  85.        are  lossy  and    will  introduce     some  noise.  You should
  86.        really pass your sample through a low pass filter prior to
  87.        downconverting  as  this will prevent alias signals (which
  88.        would sound like additional noise).  For example     to  con¡
  89.        vert from a sample recorded at 11025 Hz to a u-law file at
  90.        8000 Hz sample rate:
  91.  
  92.      sox infile.wav -t au -r 8000 -U -b -c 1 outputfile.au
  93.  
  94.        To add a low-pass filter (note use of stdout for output of
  95.        the first stage and stdin for input on the second stage):
  96.  
  97.      sox infile.wav -t raw -s -w -c 1 - lowpass 3700  |
  98.        sox    -t  raw -r 11025 -s -w -c 1 - -t au -r 8000 -U -b
  99.        -c 1 ofile.au
  100.  
  101.        If you hear some clicks and pops when converting to  u-law
  102.        or  A-law,  reduce  the output level slightly, for example
  103.        this will decrease it by 20%:
  104.  
  105.      sox infile.wav -t au -r 8000 -U -b -c 1  -v  .8  output¡
  106.        file.au
  107.  
  108.  
  109.        SoX is great to use along with other command line programs
  110.        by passing data between the programs using pipelines.  The
  111.        most  common example is to use mpg123 to convert mp3 files
  112.        in to wav files.     The following command line will do this:
  113.  
  114.      mpg123 -b 10000 -s filename.mp3 | sox -t raw -r 44100 -s
  115.        -w -c 2 - filename.wav
  116.  
  117.        When working with totally  unknown  audio  data    then  the
  118.        "auto"  file  format  may be of use.  It attempts to guess
  119.        what the file type is and then you  may    save  it  into    a
  120.        known audio format.
  121.  
  122.      sox -V -t auto filename.snd filename.wav
  123.  
  124.        It  is  important  to  understand how the internals of SoX
  125.        work with compressed audio including u-law, A-law,  ADPCM,
  126.        or  GSM.     SoX takes ALL input data types and converts them
  127.        to uncompressed 32-bit signed data.  It will then  convert
  128.        this  internal  version    into the requested output format.
  129.        This means additional noise can be introduced from  decom¡
  130.        pressing     data and then recompressing.  If applying multi¡
  131.        ple effects to audio data, it is best to save the interme¡
  132.        diate  data  as    PCM  data.   After  the     final    effect is
  133.        performed, then you can specify it as a compressed  output
  134.        format.    This will keep noise introduction to a minimum.
  135.  
  136.        The  following  example applies various effects to an 8000
  137.        Hz ADPCM input file and then end up with the final file as
  138.        44100 Hz ADPCM.
  139.  
  140.      sox firstfile.wav -r 44100 -s -w secondfile.wav
  141.      sox secondfile.wav thirdfile.wav swap
  142.      sox thirdfile.wav -a -b finalfile.wav mask
  143.  
  144.        Under  a DOS shell, you can convert several audio files to
  145.        an new output format using something similar to    the  fol¡
  146.        lowing command line:
  147.  
  148.      FOR %X IN (*.RAW) DO sox -r 11025 -w -s -t raw $X $X.wav
  149.  
  150. EFFECTS
  151.        Special       thanks     goes     to     Juergen      Mueller
  152.        (jmeuller@uia.au.ac.be) for this write up on effects.
  153.  
  154.        Introduction:
  155.  
  156.        The core problem is that you need some experience in using
  157.        effects in order to say "that any old  sound  file  sounds
  158.        with  effects  absolutely hip". There isn't any rule-based
  159.        system which tell you  the  correct  setting  of     all  the
  160.        parameters for every effect.  But after some time you will
  161.        become an expert in using effects.
  162.  
  163.        Here are some examples which can be used     with  any  music
  164.        sample.     (For  a sample where only a single instrument is
  165.        playing, extreme parameter  setting  may     make  well-known
  166.        "typically"  or    "classical"  sounds. Likewise, for drums,
  167.        vocals or guitars.)
  168.  
  169.        Single effects will be explained and some given    parameter
  170.        settings that can be used to understand the theory by lis¡
  171.        tening to the sound file with the added effect.
  172.  
  173.        Using multiple effects in parallel or in series can result
  174.        either  in  a  very  nice  sound or (mostly) in a dramatic
  175.        overloading in variations of sounds such that your ear may
  176.        follow the sound but you will feel unsatisfied. Hence, for
  177.        the first time using effects try to compose them as  mini¡
  178.        mally  as  possible.  We     don't    regard the composition of
  179.        effects in the examples because too many combinations  are
  180.        possible and you really need a very fast machine and a lot
  181.        of memory to play them in real-time.
  182.  
  183.        However, real-time playing of sounds will greatly speed up
  184.        learning     and/or     tuning     the  parameter settings for your
  185.        sounds in order to get that "perfect" effect.
  186.  
  187.        Basically, we will use the "play" front-end of  SoX  since
  188.        it is easier to listen sounds coming out of the speaker or
  189.        earphone instead of  looking  at     cryptic  data    in  sound
  190.        files.
  191.  
  192.        For  easy  listening  of file.xxx ("xxx" is any sound for¡
  193.        mat):
  194.  
  195.          play file.xxx effect-name effect-parameters
  196.  
  197.        Or more SoX-like (for "dsp" output on  a     UNIX/Linux  com¡
  198.        puter):
  199.  
  200.           sox  file.xxx  -t ossdsp -w -s /dev/dsp effect-name
  201.        effect-parameters
  202.  
  203.        or (for "au" output):
  204.  
  205.          sox file.xxx -t sunau -w -s  /dev/audio  effect-name
  206.        effect-parameters
  207.  
  208.        And for date freaks:
  209.  
  210.          sox file.xxx file.yyy effect-name effect-parameters
  211.  
  212.        Additional options can be used. However, in this case, for
  213.        real-time playing you'll need a very fast machine.
  214.  
  215.        Notes:
  216.  
  217.        I played all examples in real-time on a Pentium    100  with
  218.        32 MB and Linux 2.0.30 using a self-recorded sample ( 3:15
  219.        min long in "wav" format with 44.1  kHz    sample    rate  and
  220.        stereo 16 bit ).     The sample should not contain any of the
  221.        effects. However, if you take any  recording  of     a  sound
  222.        track  from radio or tape or CD, and it sounds like a live
  223.        concert or ten people are playing  the  same  rhythm  with
  224.        their  drums or funky-grooves, then take any other sample.
  225.        (Typically, less then four different  instruments  and  no
  226.        synthesizer  in the sample is suitable. Likewise, the com¡
  227.        bination vocal, drums, bass and guitar.)
  228.  
  229.        Effects:
  230.  
  231.        Echo
  232.  
  233.        An echo effect can be naturally found  in  the  mountains,
  234.        standing     somewhere  on    a  mountain and shouting a single
  235.        word will result in one or more repetitions  of    the  word
  236.        (if  not, turn a bit around and try again, or climb to the
  237.        next mountain).
  238.  
  239.        However, the time difference between shouting and  repeat¡
  240.        ing is the delay (time), its loudness is the decay. Multi¡
  241.        ple echos can have different delays and decays.
  242.  
  243.        It is very popular to use echos to play an instrument with
  244.        itself  together, like some guitar players (Brain May from
  245.        Queen) or vocalists are doing.  For music samples of  more
  246.        than one instrument, echo can be used to add a second sam¡
  247.        ple shortly after the original one.
  248.  
  249.        This will sound as if  you  are    doubling  the  number  of
  250.        instruments playing in the same sample:
  251.  
  252.          play file.xxx echo 0.8 0.88 60.0 0.4
  253.  
  254.        If  the    delay is very short, then it sound like a (metal¡
  255.        lic) robot playing music:
  256.  
  257.          play file.xxx echo 0.8 0.88 6.0 0.4
  258.  
  259.        Longer delay will sound like an open air     concert  in  the
  260.        mountains:
  261.  
  262.          play file.xxx echo 0.8 0.9 1000.0 0.3
  263.  
  264.        One mountain more, and:
  265.  
  266.          play file.xxx echo 0.8 0.9 1000.0 0.3 1800.0 0.25
  267.  
  268.        Echos
  269.  
  270.        Like  the  echo    effect, echos stand for "ECHO in Sequel",
  271.        that is the first echos takes the input,     the  second  the
  272.        input  and  the    first  echos, the third the input and the
  273.        first and the second echos, ... and so on.  Care should be
  274.        taken  using many echos (see introduction); a single echos
  275.        has the same effect as a single echo.
  276.  
  277.        The sample will be bounced twice in symmetric echos:
  278.  
  279.          play file.xxx echos 0.8 0.7 700.0 0.25 700.0 0.3
  280.  
  281.        The sample will be bounced twice in asymmetric echos:
  282.  
  283.          play file.xxx echos 0.8 0.7 700.0 0.25 900.0 0.3
  284.  
  285.        The sample will sound as if played in a garage:
  286.  
  287.          play file.xxx echos 0.8 0.7 40.0 0.25 63.0 0.3
  288.  
  289.        Chorus
  290.  
  291.        The chorus effect has its name because it  will    often  be
  292.        used  to     make  a single vocal sound like a chorus. But it
  293.        can be applied to other instrument samples too.
  294.  
  295.        It works like the echo effect with a short delay, but  the
  296.        delay  isn't  constant.    The delay is varied using a sinu¡
  297.        soidal or  triangular  modulation.  The    modulation  depth
  298.        defines    the range the modulated delay is played before or
  299.        after the delay. Hence the delayed sound will sound slower
  300.        or  faster,  that  is  the  delayed sound tuned around the
  301.        original one, like in a chorus where some vocals are a bit
  302.        out of tune.
  303.  
  304.        The typical delay is around 40ms to 60ms, the speed of the
  305.        modulation is best near 0.25Hz and  the    modulation  depth
  306.        around 2ms.
  307.  
  308.        A single delay will make the sample more overloaded:
  309.  
  310.          play file.xxx chorus 0.7 0.9 55.0 0.4 0.25 2.0 -t
  311.  
  312.        Two delays of the original samples sound like this:
  313.  
  314.           play  file.xxx  chorus 0.6 0.9 50.0 0.4 0.25 2.0 -t
  315.        60.0 0.32 0.4 1.3 -s
  316.  
  317.        A big chorus of the sample is (three additional samples):
  318.  
  319.          play file.xxx chorus 0.5 0.9 50.0 0.4  0.25  2.0  -t
  320.        60.0 0.32 0.4 2.3 -t       40.0 0.3 0.3 1.3 -s
  321.  
  322.        Flanger
  323.  
  324.        The  flanger  effect  is     like  the chorus effect, but the
  325.        delay varies between 0ms and maximal 5ms.  It  sound  like
  326.        wind blowing, sometimes faster or slower including changes
  327.        of the speed.
  328.  
  329.        The flanger effect is widely used in funk and soul  music,
  330.        where  the  guitar  sound  varies frequently slow or a bit
  331.        faster.
  332.  
  333.        The typical delay is around 3ms to 5ms, the speed  of  the
  334.        modulation is best near 0.5Hz.
  335.  
  336.        Now, let's groove the sample:
  337.  
  338.          play file.xxx flanger 0.6 0.87 3.0 0.9 0.5 -s
  339.  
  340.        listen  carefully between the difference of sinusoidal and
  341.        triangular modulation:
  342.  
  343.          play file.xxx flanger 0.6 0.87 3.0 0.9 0.5 -t
  344.  
  345.        If the decay is a bit lower, than the effect  sounds  more
  346.        popular:
  347.  
  348.          play file.xxx flanger 0.8 0.88 3.0 0.4 0.5 -t
  349.  
  350.        The drunken loudspeaker system:
  351.  
  352.          play file.xxx flanger 0.9 0.9 4.0 0.23 1.3 -s
  353.  
  354.        Reverb
  355.  
  356.        The reverb effect is often used in audience hall which are
  357.        to small or contain too many many visitors  which  disturb
  358.        (dampen)     the  reflection  of  sound at the walls.  Reverb
  359.        will make the sound be perceived as if it were in a  large
  360.        hall.   You  can try the reverb effect in your bathroom or
  361.        garage or sport halls by shouting loud some words.  You'll
  362.        hear the words reflected from the walls.
  363.  
  364.        The biggest problem in using the reverb effect is the cor¡
  365.        rect setting of the (wall) delays such that the    sound  is
  366.        realistic  and  doesn't    sound like music playing in a tin
  367.        can or has overloaded feedback which destroys any illusion
  368.        of  playing  in    a big hall.  To help you obtain realistic
  369.        reverb effects, you  should  decide  first  how    long  the
  370.        reverb should take place until it is not loud enough to be
  371.        registered by your ears. This is be done     by  varying  the
  372.        reverb  time "t".  To simulate small halls, use 200ms.  To
  373.        simulate large halls, use 1000ms.  Clearly, the    walls  of
  374.        such a hall aren't far away, so you should define its set¡
  375.        ting be given every wall its delay time.     However, if  the
  376.        wall  is     to  far away for the reverb time, you won't hear
  377.        the reverb, so the nearest wall    will  be  best    at  "t/4"
  378.        delay  and  the    farthest at "t/2". You can try other dis¡
  379.        tances as well, but it won't sound  very     realistic.   The
  380.        walls  shouldn't stand to close to each other and not in a
  381.        multiple integer distance to each other (  so  avoid  wall
  382.        like:  200.0  and 202.0, or something like 100.0 and 200.0
  383.        ).
  384.  
  385.        Since audience halls do have a lot of walls, we will start
  386.        designing one beginning with one wall:
  387.  
  388.          play file.xxx reverb 1.0 600.0 180.0
  389.  
  390.        One wall more:
  391.  
  392.          play file.xxx reverb 1.0 600.0 180.0 200.0
  393.  
  394.        Next two walls:
  395.  
  396.           play  file.xxx  reverb  1.0 600.0 180.0 200.0 220.0
  397.        240.0
  398.  
  399.        Now, why not a futuristic hall with six walls:
  400.  
  401.          play file.xxx reverb 1.0  600.0  180.0  200.0  220.0
  402.        240.0 280.0 300.0
  403.  
  404.        If  you    run  out of machine power or memory, then stop as
  405.        many applications as possible (every interrupt  will  con¡
  406.        sume  a    lot  of     CPU time which for bigger halls is abso¡
  407.        lutely necessary).
  408.  
  409.        Phaser
  410.  
  411.        The phaser effect is like the flanger effect, but it  uses
  412.        a  reverb  instead  of  an  echo     and does phase shifting.
  413.        You'll hear the difference in the examples comparing  both
  414.        effects    (simply change the effect name).  The delay modu¡
  415.        lation can be sinusoidal or triangular, preferable is  the
  416.        later  for  multiple  instruments.  For    single instrument
  417.        sounds, the sinusoidal phaser effect will give  a  sharper
  418.        phasing    effect.      The  decay shouldn't be to close to 1.0
  419.        which will cause dramatic feedback.  A good range is about
  420.        0.5 to 0.1 for the decay.
  421.  
  422.        We will take a parameter setting as for the flanger before
  423.        (gain-out is lower since feedback  can  raise  the  output
  424.        dramatically):
  425.  
  426.          play file.xxx phaser 0.8 0.74 3.0 0.4 0.5 -t
  427.  
  428.        The drunken loudspeaker system (now less alcohol):
  429.  
  430.          play file.xxx phaser 0.9 0.85 4.0 0.23 1.3 -s
  431.  
  432.        A popular sound of the sample is as follows:
  433.  
  434.          play file.xxx phaser 0.89 0.85 1.0 0.24 2.0 -t
  435.  
  436.        The sample sounds if ten springs are in your ears:
  437.  
  438.          play file.xxx phaser 0.6 0.66 3.0 0.6 2.0 -t
  439.  
  440.        Compander
  441.  
  442.        The  compander effect allows the dynamic range of a signal
  443.        to be compressed or expanded.  For  most     situations,  the
  444.        attack  time (response to the music getting louder) should
  445.        be shorter than the decay time because our ears    are  more
  446.        sensitive  to  suddenly    loud  music than to suddenly soft
  447.        music.
  448.  
  449.        For example, suppose you are listening to  Strauss'  "Also
  450.        Sprach  Zarathustra" in a noisy environment such as a car.
  451.        If you turn up the volume enough to hear the soft passages
  452.        over  the  road noise, the loud sections will be too loud.
  453.        You could try this:
  454.  
  455.            play          file.xxx         compand        0.3,1
  456.        -90,-90,-70,-70,-60,-20,0,0 -5 0 0.2
  457.  
  458.        The  transfer  function    ("-90,...")  says  that very soft
  459.        sounds between -90 and -70  decibels  (-90  is  about  the
  460.        limit  of  16-bit  encoding)  will remain unchanged.  That
  461.        keeps the compander from boosting the volume  on     "silent"
  462.        passages     such  as  between movements.  However, sounds in
  463.        the range -60 decibels to 0 decibels (maximum volume) will
  464.        be boosted so that the 60-dB dynamic range of the original
  465.        music will be compressed 3-to-1 into a 20-dB range,  which
  466.        is wide enough to enjoy the music but narrow enough to get
  467.        around the road noise.  The -5 dB output gain is needed to
  468.        avoid  clipping (the number is inexact, and was derived by
  469.        experimentation).  The 0 for the initial volume will  work
  470.        fine for a clip that starts with a bit of silence, and the
  471.        delay of 0.2 has the effect of causing  the  compander  to
  472.        react a bit more quickly to sudden volume changes.
  473.  
  474.        Changing the Rate of Playback
  475.  
  476.        You  can     use stretch to change the rate of playback of an
  477.        audio sample while preserving the pitch.     For  example  to
  478.        play at 1/2 the speed:
  479.  
  480.          play file.wav stretch 2
  481.  
  482.        To play a file at twice the speed:
  483.  
  484.          play file.wav stretch .5
  485.  
  486.        Other  related  options are "speed" to change the speed of
  487.        play (and changing the pitch accordingly), and  pitch,  to
  488.        alter  the pitch of a sample.  For example to speed a sam¡
  489.        ple so it plays in 1/2 the time (for  those  Mickey  Mouse
  490.        voices):
  491.  
  492.          play file.wav speed 2
  493.  
  494.        To raise the pitch of a sample 1 while note (100 cents):
  495.  
  496.          play file.wav pitch 100
  497.  
  498.  
  499.  
  500.        Other  effects (copy, rate, avg, stat, vibro, lowp, highp,
  501.        band, reverb)
  502.  
  503.        The other effects are simple to use. However, an "easy  to
  504.        use manual" should be given here.
  505.  
  506.        More effects (to do !)
  507.  
  508.        There  are  a lot of effects around like noise gates, com¡
  509.        pressors, waw-waw, stereo effects and so on.  They  should
  510.        be  implemented,     making     SoX  more useful in sound mixing
  511.        techniques coming together with a great variety of differ¡
  512.        ent sound effects.
  513.  
  514.        Combining effects by using them in parallel or serially on
  515.        different channels needs some easy mechanism which is sta¡
  516.        ble for use in real-time.
  517.  
  518.        Really  missing are the the changing of the parameters and
  519.        starting/stopping of  effects  while  playing  samples  in
  520.        real-time!
  521.  
  522.        Good luck and have fun with all the effects!
  523.  
  524.         Juergen Mueller         (jmueller@uia.ua.ac.be)
  525.  
  526.  
  527. SEE ALSO
  528.        sox(1), play(1), rec(1)
  529.  
  530. AUTHOR
  531.        Juergen Mueller       (jmueller@uia.ua.ac.be)
  532.  
  533.        Updates by Anonymous.
  534.  
  535.  
  536.  
  537.             December 11, 2001           SoX(1)
  538.