[Back to overview]

resample_soxr --help

resample_soxr (version 0.8 of frankl's stereo utilities)

USAGE:

  resample_soxr [options] 

  By default this program works as a resampling filter for stereo audio 
  streams in raw double format (in some programs denoted FLOAT64_LE).

  Here 'filter' means that input comes from stdin and output is
  written to stdout. Use pipes and 'sox' or other programs to deal with 
  other stream formats. 

  Alternatively, this program can use as input any sound file that can be 
  read with 'libsndfile' (flac, wav, ogg, aiff, ...). This  can be 
  a file in the file system or in shared memory (see '--file' and
  '--shmname' options). In this case it is also possible to read only a 
  part of the file.

  The main options are the input sample rate and the output sample rate.

  The volume of the output can be changed and a RACE filter can be applied
  to the output; see options '--volume', '--race-delay' and '--race-volume'.
  If instead of these options their values are given in a file via 
  '--param-file', then these parameters can be changed while the program
  is running. See 'volrace --help' for more information.

  This program uses the 'soxr' standalone resampling library (see
  https://sourceforge.net/projects/soxr/) with the highest quality 
  settings, all computations are done with 64-bit floating point 
  numbers.

  The computation is similar to using 'sox' with effect 'rate -v -I'.
  But 'sox' applies all effects internally to 32-bit signed integer
  samples (that is, the 64-bit input precision is lost).

  OPTIONS
  
  --inrate=floatval, -i floatval
      the input sample rate as floating point number (must not be an 
      integer). Default is 44100. In case of file input this value is
      overwritten by the sampling rate specified in the file (so, this
      option is not needed).

  --outrate=floatval, -o floatval
      the output sample rate as floating point number (must not be an 
      integer). Default is 192000.

  --channels=intval, -c intval
      number of interleaved channels in the input. Default is 2 (stereo).
      In case of input from a file this number is overwritten by the 
      the number of channels in the file.

  --buffer-length=intval, -b intval
      the size of the input buffer in number of frames. The default
      (and minimal value) is 8192 and should usually be fine.

  --phase=floatval, -P floatval
      the phase response of the filter used during resampling; see the 
      documentation of the 'rate' effect in 'sox' for more details. This
      is a number from 0 (minimum phase) to 100 (maximal phase), with 
      50 (linear phase) and 25 (intermediate phase). The default is 25,
      and should usually be fine.

  --band-width=floatval, -B floatval
      the band-width of the filter used during resampling; see the 
      documentation of the rate effect in 'sox' for more details. The value
      is given as percentage (of the Nyquist frequency of the smaller 
      sampling rate). The allowed range is 74.0..99.7, the default is 91.09
      (that is the filter is flat up to about 20kHz).

  --precision=floatval, -e floatval
      the bit precision for resampling; higher values cause higher CPU usage.
      The valid range is 16.0..33.0, the default is 33.0 and should usually
      be fine (except lower CPU usage is essential).

  --file=fname, -f fname
      name of an input audio file (flac, wav, aiff, ...). The default
      is input from stdin.

  --shmname=sname, -i sname
      name of an audio file in shared memory. The default
      is input from stdin.

  --toint32, -I
      output 32-bit integer samples instead of double floats.

The follwing three option allow to read only part of the input, but this is
only possible for input from file or shared memory.

  --start=intval, -s intval
      number of the frame to start from. Default is 0.
  
  --until=intval, -u intval
      number of frame to stop. Must be larger than start frame.
      Default is the end of the audio file.

  --number-frames=intval, -n intval
      number of frames (from start frame) to write.
      Default is all frames until end of the audio file.

And here are options for volume and RACE filtering of output.

  --volume=floatval, -v floatval
      the volume as floating point factor (e.g., '0.5' for an attenuation
      of 6dB). A small attenuation (say, 0.9) can be useful to avoid 
      intersample clipping. Default is 1.0, that is no volume change.
      The default is '1.0', that is no volume change.

  --replay-gain=floatval, -r floatval
      the value of --volume is multiplied by this factor.
      The default is '1.0'. This can be useful if the volume is changed
      during runtime via a --param-file.

  --race-delay=val, -d val
      the delay for RACE as (integer) number of samples (per channel).
      Default is 12.

  --race-volume=floatval, -a floatval
      the volume of the RACE signal copied to the other channel.
      Default is '0.0', that is no RACE filter.

  --param-file=fname, -F fname
      the name of a file which can be given instead of the previous three
      options. That file must contain the values for --volume, 
      --race-delay and --race-volume, separated by whitespace.
      This file is reread by the program when it was changed, and the
      parameters are faded to the new values. This way this program can
      be used as volume (and RACE parameter) control during audio playback.
      The file may only contain the value of --volume, in this case RACE
      will be disabled.

  --fading-length=intval, -l intval
      number of frames used for fading to new parameters (when the
      file given in --param-file was changed). Default is 44100, for high 
      sample rates a larger value may be desirable.

  --help, -h
      show this help.

  --verbose, -p
      shows some information during startup and operation.

  --version, -V
      show the version of this program and exit.

   EXAMPLES

   Convert a file 'musicfile' that can be read by 'sox' to a 96/32
   wav-file using a pipe:
      ORIGRATE=`sox --i musicfile | grep "Sample Rate" | \
                cut -d: -f2 | sed -e "s/ //g"`
      sox musicfile -t raw -e float -b 64 - | \
          resample_soxr --inrate=$ORIGRATE --outrate=96000 --volume=0.9 | \
          sox -t raw -e float -b 64 -c 2 -r 96000 - -e signed -b 32 out.wav

   If 'resample_soxr' can read 'musicfile' this can also be achieved by:
      resample_soxr --file=musicfile --outrate=96000 --volume=0.9 | \
          sox -t raw -e float -b 64 -c 2 -r 96000 - -e signed -b 32 out.wav

   During room measurements I notice that the clocks in my DAC and my 
   recording soundcard are slightly different. Before computing an 
   impulse response I correct this with a command like:
      sox recfile.wav -t raw -e float -b 64 - | \
          resample_soxr -i 96000 -o 95999.13487320 | \
          sox -t raw -e float -b 64 -c 2 -r 96000 - -e signed -b 32 \
          reccorrected.wav

   Read input from file in shared memory, resample to 192k, apply race 
   filter and pipe into 'brutefir' convolver:

      cptoshm --file=data.flac --shmname=/pl.flac
      resample_soxr --shmname=/pl.flac --param-file=/tmp/volraceparams \
           --outrate=192000  --fading-length=100000 | \
        brutefir /tmp/bfconf | ...