[Asterisk-Users] Monitor and sox mix quality

gw at adcomcorp.com gw at adcomcorp.com
Tue Oct 4 12:40:36 MST 2005


This is what I ended up doing...Using sox to mix then lame to encode.
Ends up with a much larger audio file though. Not a problem, but since
the channels are split it sounds much better as they don't get
artifacts.

Greg

#!/usr/bin/perl
@lines=`ls -1 /var/spool/asterisk/monitor/incoming/9999999999/*in.wav`;
foreach $line (@lines){
    (@splits)=split("in.wav",$line);
    chop(@splits[0]);
    $base=@splits[0];
    $base=~ s/(")/\\\"/g;
    $base=~ s/( )/\\\ /g;
    $base=~ s/(>)/\\\>/g;
    $base=~ s/(<)/\\\</g;
    print `/usr/bin/nice -n 20 /usr/local/bin/sox $base-in.wav -c 2
$base-in-l.wav pan -1`;
    print `/usr/bin/nice -n 20 /usr/local/bin/sox $base-out.wav -c 2
$base-out-r.wav pan 1`;
    print `/usr/bin/nice -n 20 /usr/local/bin/soxmix $base-in-l.wav
$base-out-r.wav $base.wav`;
    print `/usr/bin/nice -n 20 /usr/bin/lame -S --cbr -b32 -m s
$base.wav $base.mp3`;
    `rm -f $base.wav`;
    `rm -f $base-*`;} 
 

-----Original Message-----
From: asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Jonathan
Feally
Sent: Monday, September 19, 2005 2:11 AM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [Asterisk-Users] Monitor and sox mix quality

I have not noticed any issues with quality, just with caller volumes
being way different when mixing 2 channel types (ZAP and SIP
specifically). Here's my custom script for processing the recording
files. Make sure you use option "m" on your monitor command so that the
custom script will run. My script makes a stereo mp3 with the 2 people
split to left/right and makes the 2 sides have an equal max volume. Hope
this helps. You can always modify the script to adjust how the mp3 is
encoded.


extensions.conf:

[globals]
MONITOR_EXEC=/usr/local/bin/2wav2mp3

[macro-callext]
s,1,monitor(wav|${ARG1}_${TIMESTAMP}|m)
s,2,dial(SIP/${ARG1})


root at asterslack2:/usr/local/bin# cat /usr/local/bin/2wav2mp3 #!/bin/sh #
2wav2mp3 - create stereo mp3 out of two mono wav-files # source files
will be deleted # # usage: 2wav2mp3 <wave1> <wave2> <mp3> # #
extensions.conf # use option "m" on monitor command # add this variable
to [globals] # MONITOR_EXEC=/usr/local/bin/2wav2mp3


# location of SOX and SOXMIX
# (set according to your system settings, eg. /usr/bin) SOX="nice -n 20
/usr/bin/sox"
SOXMIX="nice -n 20 /usr/bin/soxmix"
LAME="nice -n 20 /usr/local/bin/lame -S --cbr -b32 -m s"
NORMALIZE="nice -n 20 /usr/bin/normalize --no-progress -a 1.0 --peak"

# command line variables
LEFT=`echo $1 | awk -F".wav" '{print $1}'` RIGHT=`echo $2 | awk -F".wav"
'{print $1}'` OUT=`echo $3 | awk -F".wav" '{print $1}'`

#test if input files exist
test ! -r $LEFT.wav && exit
test ! -r $RIGHT.wav && exit

# convert mono to stereo, adjust balance to -1/1 $NORMALIZE $LEFT.wav
$NORMALIZE $RIGHT.wav # left channel $SOX $LEFT.wav -c 2 $LEFT-tmp.wav
pan -1 # right channel $SOX $RIGHT.wav -c 2 $RIGHT-tmp.wav pan 1

# in case an old version of sox is used, encoding # can be done
afterwards $SOXMIX -v 1 $LEFT-tmp.wav -v 1 $RIGHT-tmp.wav -v 1 $OUT.wav
$LAME $OUT.wav $OUT.mp3


#remove temporary files
test -w $LEFT-tmp.wav && rm $LEFT-tmp.wav test -w $RIGHT-tmp.wav && rm
$RIGHT-tmp.wav test -w $OUT.wav && rm $OUT.wav

#remove input files if successfull
test -r $OUT.mp3 && rm $LEFT.wav $RIGHT.wav # eof


Good Luck!

-Jon


gw at adcomcorp.com wrote:

>Hello All,
>I am using monitor with soxmix, however the quality seems somewhat low 
>after sox converts to mp3.
>
>Does anyone know a way to get a higher quality file?  Some of my lines 
>are coming in on isdn.
>
>Regards,
>Greg
>_______________________________________________
>--Bandwidth and Colocation sponsored by Easynews.com --
>
>Asterisk-Users mailing list
>Asterisk-Users at lists.digium.com
>http://lists.digium.com/mailman/listinfo/asterisk-users
>To UNSUBSCRIBE or update options visit:
>   http://lists.digium.com/mailman/listinfo/asterisk-users
>
>  
>

_______________________________________________
--Bandwidth and Colocation sponsored by Easynews.com --

Asterisk-Users mailing list
Asterisk-Users at lists.digium.com
http://lists.digium.com/mailman/listinfo/asterisk-users
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users



More information about the asterisk-users mailing list