TIP: Merging mono call recordings into stereo

System: Trixbox 2.2 CE with FreePBX 2.5.x, runs Asterisk 1.2.x

After I read about FreeSWITCH’s ability to record calls in stereo, with the inbound leg as one (maybe left) channel, and the outbound leg as the other (maybe right) channel), I wanted to replicate it with my system.

Turns out, Asterisk 1.2 uses MixMonitor to mix recordings after the call is done. MixMonitor uses res_monitor.o for this, which actually calls soxmix.

Checking the sox documentation on my system revealed that I did not have the proper version to use the “-M” switch to merge recordings instead of the default, which is to mix recordings.

So, I downloaded version 14.3.0 from the sox website, checked the configure command for available options, and decided to try it with ogg and flac support.

I extracted the tarball into /root/sox-14.3.0 for testing purposes, but later moved it to /usr/local/sox-14.3.0 for additional testing and final use.

Unfortunately I could not seem to find the proper libraries for flac support, although configure found some of them and kept trying to use them.

So, my configure command looked like this:

I was then able to run make, and test the new binary from /usr/local/sox-14.3.0/src/ to see if it would work. It did. Next step.

I looked at setting up an alias for soxmix to call “sox -M”, but that didn’t seem to work, so I created a short bash script:

#!/bin/bash
/usr/local/sox-14.3.0/src/sox -M $1 $2 $3

I moved /usr/bin/soxmix to /usr/bin/soxmix.back and moved the bash script to /usr/bin/soxmix as its replacement. Making sure it was chown root:root, and chmod 775 so it would work properly.

Then, a couple of test calls, checked the recordings, and hooray! The inbound leg becomes the left channel, and the outbound leg becomes the right channel in a stereo file.

It’s a little weird to listen to, but the benefits are that each channel can be isolated or adjusted in an audio editor (like Audacity), in order to get what you need. Perhaps the speakers were talking over each other, or one sneezed as the other was giving a critical phone number, or one speaker was really quiet. Previously, there was not much you could do. Now, just adjust that channel.

Hope it helps someone else.

DionV