
What is sox
?
sox
(Sound eXchange) is a command-line utility for audio recording, editing, processing, and format conversion. It works natively with macOS CoreAudio and is highly useful when paired with virtual audio devices like BlackHole or Loopback.
Installation
Install via Homebrew:
brew install sox
For MP3 support, use FFmpeg:
brew install ffmpeg
Record Audio from Devices
Record from the built-in microphone:
sox -t coreaudio "External Microphone" mic.wav
Record system audio routed through a virtual device like BlackHole
:
sox -t coreaudio "BlackHole 16ch" system.wav
You don’t have to use BlackHole, but you need a virtual audio device to record system audio separately, because macOS does not allow direct capture of system output natively.
Record both simultaneously:
sox -t coreaudio "BlackHole 16ch" system.wav &
sox -t coreaudio "Built-in Microphone" mic.wav
To stop: Ctrl+C
(foreground) or kill %1
(background).
Check if a Recording is Running
ps aux | grep sox
Stop all sox recordings:
pkill sox
Basic Audio Processing Examples
Trim and fade:
sox input.wav output.wav trim 0 30 fade 0.5 30 0.5
Normalize volume:
sox input.wav output.wav norm
Convert format:
sox input.wav output.mp3
Tips
- Use
ffmpeg -f avfoundation -list_devices true -i ""
to list macOS audio devices. - Combine with
sox --combine merge
for multi-channel outputs. - Diarization and more advanced labeling requires external tools (e.g., Whisper + pyannote).
Reference
- Official site: http://sox.sourceforge.net/
man sox
orsox --help
for full command list.