# # burn_audio -- A script for converting MP3s to WAVs for burning with cdrdao. # # REQUIRES: cdrdao (for burning); lame (for decoding MP3s) # NOTE: Make sure /etc/cdrdao.conf contains a line specifying the device, e.g.: # write_device: "/dev/cdrw0" # This is a modified version of the loops posted on the Arch Linux Wiki at: # http://wiki.archlinux.org/index.php/Creating_gapless_audio_CDs_from_MP3_HOWTO # # USAGE: # ./burn_audio [-gap | -nogap] FILES_PATH TEMP_PATH # ARGUMENTS: # -gap Add a 2-second silence before each track. # -nogap No silence will be added before tracks (i.e. gapless). # if [ -z $3 ] ; then echo "ERROR: Not enough arguments." echo "You need to specify the following:" echo " - either -gap or -nogap," echo " - the path to the directory with the MP3s you want to burn, and" echo " - the path to a working directory (which will be created by this script)." echo echo "e.g.: ./burn_audio -nogap ~/music /tmp/to_burn" exit 1 fi if [ ! -z $4 ] ; then echo "ERROR: Too many arguments." echo "You provided more than 3 arguments (the 4th argument you entered was: $4)." exit 1 fi if [ $1 == "-gap" ] ; then echo "A 2-second silence will be added before each track." BURN_WITH_GAP = "true" else if [ $1 == "-nogap" ] ; then echo "The tracks will be written gaplessly." else echo "ERROR: Invalid argument: $1" echo "Either -gap or -nogap is required as the first argument." exit 1 fi fi if [ ! -d $2 ] ; then echo "ERROR: The FILES_PATH does not exist." exit 1 fi FILES_PATH="$2" TEMP_PATH="$3" mkdir -p $TEMP_PATH for file in $FILES_PATH/*.mp3 ; do lame --decode "$file" "$TEMP_PATH/$file.wav" done cd $TEMP_PATH { echo "CD_DA" for file in *.wav ; do echo "TRACK AUDIO" if [ $BURN_WITH_GAP = "true" ] ; then echo "PREGAP 00:02:00" else fi echo "FILE \"$file\" 0" done } > TOC echo "Please review the TOC file created before burning." less TOC echo "Begin burning to disc? [y/n] " read if [ $REPLY == "y" || $REPLY == "Y" ] ; then echo "Executing command: cdrdao write TOC" cdrdao write TOC else echo "Aborting." exit 0 fi