free software for the blind

How to Record both MIC and System Playback on Ubuntu Linux?

(updated on Aug 19, 2015)

On Ubuntu Linux 14.04 with pulseaudio, we can easily record sound from microphone with command `arecord`. We can also system playback with command `parec` although we need to specifiy complicate options. However, it's very hard to record both MIC and system playback. I spend a whole day to google the result and none of them works. So I write a script to do this.

First, install sox and get my scirpt brecord:
sudo apt-get install -y sox
sudo wget -O /usr/bin/brecord
Then, run the script to record with CTRL+C to end recording:
brecord filename
Finally, play recording with:
play filename.wav
There will be 3 new files: filename.1.wav, filename.2.wav and filename.wav. filename.wav is what we want. Now, let me explain what brecord has done. It launches two processes. One for recording microphone, one for recording system playback. Then it uses sox to mix these two audio files into one.