Asterisk, and other worldly endeavours.

A blog by Leif Madsen

Posts Tagged ‘MixMonitor() sox mixing asterisk script

Manually mixing files created by MixMonitor()

So last night I did a system update between 11:30pm and 5:00am. One of the things I forgot to do when I was moving to the new system was to install sox so that MixMonitor() could mix the -in and -out files automatically for me. I still had the recordings, but I needed to get them mixed. I first installed sox so that all new recorded files would be mixed for me. I also needed the soxmix application to mix the files together for me. 🙂

I created a little bash script to do this for me. Some of my files had different numbers of fields, but I think the common format for Asterisk is 5 fields (separate with a hyphen) followed by either -in.wav or -out.wav. The following script takes the files in the /var/spool/asterisk/monitor/merge/ directory, and mixes them together to a single file, then places them in the /var/spool/asterisk/monitor/ directory.


for NAME in $(find /var/spool/asterisk/monitor/merge/ -maxdepth 1 -type f | cut -d "/" -f7 | cut -d "-" -f1-5)
#                                                                                         fields we want  ^^^

        if [ -e $MERGE_PATH/$IN -a -e $MERGE_PATH/$OUT ]
                echo "Both IN and OUT files exist. Creating $MERGE"
                soxmix $MERGE_PATH/$IN $MERGE_PATH/$OUT $WRITE_PATH/$MERGE
                mv $MERGE_PATH/$IN $MERGE_PATH/done/
                mv $MERGE_PATH/$OUT $MERGE_PATH/done/
                echo "Skipping the creating of $MERGE due to IN and OUT not being found"
        echo ""

Written by Leif Madsen

2009/06/30 at 1:19 pm