Sox: Managing audio recording and playing

PHOTO EMBED

Mon Aug 29 2022 14:27:12 GMT+0000 (Coordinated Universal Time)

Saved by @marcopinero #bash

# duration time of file:
#   ej: sox --i -D test.ogg

  sox --i -D <sound file>

# play sound to default output
#    Linux/OSX?: 

  sox <sound file> -d

#    Windows: 

  sox <sound file> -t waveaudio
  
# record sound from default input:
#    Linux/OSX?: 

  sox -t alsa <output file>
  
#    Windows:
  
  sox -t waveaudio -d <output file>
  
# play sound from starting time (secs) (trim):
#    Linux/OSX?:

  sox <sound file> -d trim <n secs>
  
#    Windows:

  sox <sound file> -t waveaudio trim <n secs>
  
# split big file into small files with equal time fraction:
#    %1n = autoincremental: 1,2,3...

  sox <input file> <output file>_%1n.ogg trim 0 <secs> : newfile : restart
  
# concatenate small files into one:

  sox <input file1> <input file2> ... <input filen> <output file>

# cut silences with tolerance:

  sox in.wav out.wav silence -l 1 0.1 1% -1 2.0 1%
content_copyCOPY

Managing sound play/record using sox (cross os)