#!/bin/bash if [ "$1" == "" ]; then PROG=`basename $0` echo "" echo " build-saudio enhances audio quality of poorly recorded telephone " echo " conversations by converging left and right channels into a single " echo " channel of substantial higher bitrate. The low sample rate is then " echo " converted to 44.1 kHz and can then be recorded on a old-fashioned " echo " audio cd-rom in (j)oint stereo " echo "" echo " Usage : $PROG \"fancy.file_ - _name.mp3\" " echo "" echo " build-saudio v0.1.1 has been tested with : " echo "" echo " vbr2linear.custom version: 1.4.1 " echo " mpg123 version: 0.68, 1.3.1, 1.12.1 and 1.16.0 " echo " sox: Version 12.17.4 and sox: SoX v14.4.1 " echo " LAME version 3.92, LAME 64bits version 3.98.4." echo " and LAME 64bits version 3.99.5 (http://lame.sf.net) " echo "" else MPG_VERSION=`mpg123 --version | awk '{print $2}'` SOX_VERSION=`sox --version | awk '{print $3}'` VBR_TEMP=/tmp/vbr2linear.$$ if [ "$MPG_VERSION" == "1.16.0" ]; then mpg123 -n 10 -o dummy "$1" > $VBR_TEMP 2>&1 fi if [ "$MPG_VERSION" == "1.12.1" ]; then mpg123 -n 10 -o dummy "$1" > $VBR_TEMP 2>&1 fi if [ "$MPG_VERSION" == "1.3.1" ]; then mpg123 -n 10 -o dummy "$1" > $VBR_TEMP 2>&1 fi if [ "$MPG_VERSION" == "0.68" ]; then mpg123 -n 10 -a /dev/null "$1" > $VBR_TEMP 2>&1 fi if [ "$SOX_VERSION" == "v14.3.0" ]; then BITS_OPT=" -b 16 " elif [ "$SOX_VERSION" == "v14.4.1" ]; then BITS_OPT=" -b 16 " else BITS_OPT=" -w " fi TITLE=`cat "$VBR_TEMP" | grep Title: |\ sed 's/Artist:.*$//' |\ sed 's/^.*Title:/Title:/' |\ sed 's/Title: //' |\ sed 's/Title: //' | sed 's/ *$//'` ARTIST=`cat "$VBR_TEMP" | grep Artist: |\ sed 's/Comment:.*$//' |\ sed 's/^.*Artist:/Artist:/' |\ sed 's/Artist: //' |\ sed 's/Artist: //' | sed 's/ *$//'` COMMENT=`cat "$VBR_TEMP" | grep Comment: |\ sed 's/Album:.*$//' |\ sed 's/^.*Comment:/Comment:/' |\ sed 's/Comment: //' |\ sed 's/Comment://' | sed 's/ *$//'` ALBUM=`cat "$VBR_TEMP" | grep Album: |\ sed 's/Year:.*$//' | sed 's/^.*Album:/Album:/' |\ sed 's/Album: //' |\ sed 's/Album: //' | sed 's/ *$//'` YEAR=`cat "$VBR_TEMP" | grep Year: |\ sed 's/Genre:.*$//' |\ sed 's/^.*Year:/Year:/' |\ sed 's/Year: //' |\ sed 's/Year: //' | sed 's/ *$//'` GENRE=`cat "$VBR_TEMP" | grep Genre: |\ sed 's/^.*Genre:/Genre:/' |\ sed 's/Genre: //' |\ sed 's/Genre: //' | sed 's/ *$//'` LGENRE=`lame --genre-list | grep "$GENRE"` if [ "$LGENRE" == "" ]; then GENRE=Speech fi BASE=`echo "$1" | sed 's/\.mp3//'` # # adjust your desired bandwith here. If for instance # when playing your input mp3 with mpg123 shows : # MPEG 2.0 layer III, 64 kbit/s, 16000 Hz stereo # you would choose twice the displayed kbit rate # so 128k, inside the vbr2linear.custom command # then select
= 128 . vbr2linear.custom "$BASE".mp3 0 128 mono sox --i "$BASE".wav sox -S "$BASE".wav -r 44.1k -e signed -b 16 "$BASE"44.wav sox --i "$BASE"44.wav sox -S "$BASE"44.wav -e signed -b 16 -c 2 "$BASE"44s.wav sox --i "$BASE"44s.wav # # adjust your desired bandwith here. # if previously you had 128k above you would select # twice that amount, so 256 i.e. inside the lame # command : -b 256 # echo " Creating $BASE-stereo.mp3" lame --tt "$TITLE" --ta "$ARTIST" --tl "$ALBUM" \ --ty "$YEAR" --tc "$COMMENT" --tg "$GENRE" \ -h -b 256 "$BASE"44s.wav "$BASE"-stereo.mp3 touch -r "$BASE".mp3 "$BASE"-stereo.mp3 echo " Done ..." rm "$BASE".wav "$BASE"44.wav "$BASE"44s.wav rm "$VBR_TEMP" fi exit 0