source: flacrip/trunk/burnflac @ 5

Last change on this file since 5 was 1, checked in by peter, 13 years ago

initial import of current flacrip files into the trunk

  • Property svn:executable set to *
File size: 1.2 KB
Line 
1#!/bin/bash
2
3# burn a CD from one or more FLAC files
4
5#TODO: option to do "cdrdao simulate" instead of "write"?
6COMMAND=write
7
8#TODO: option to normalize the wav files?
9
10if [ $# -eq 0 ]; then
11    echo "Need at least one FLAC file"
12    exit 127
13fi
14
15# use a tmp dir for the cdda and toc files
16BURNFLAC_TMP=`mktemp -d -p /tmp burnflac.XXXXXX`
17#echo $BURNFLAC_TMP
18
19# counter for the wav files
20i=0
21
22TOC_FILE="$BURNFLAC_TMP/cdda.toc"
23echo "CD_DA" > $TOC_FILE
24
25# shift off the arguments one by one
26while [ $# -gt 0 ]; do
27    let i=$i+1
28   
29    FLAC_FILE=$1
30    WAV_FILE="$BURNFLAC_TMP/cdda-$i.wav"
31
32    shift
33
34    if [ ! -r $FLAC_FILE ]; then
35        echo "$FLAC_FILE not found"
36        exit 192
37    fi
38
39    CUESHEET=$(metaflac --export-cuesheet-to - $FLAC_FILE 2> /dev/null)
40
41    if [[ -z $CUESHEET ]]; then
42        # no cuesheet in the FLAC file
43        # fake up a one-track TOC file
44        cat <<END >> $TOC_FILE
45TRACK AUDIO
46FILE "$WAV_FILE" 0
47END
48    else
49        # substitute the wav filename for the flac filename
50        echo "$CUESHEET" \
51        | perl -pe'BEGIN { $wav = shift; } s/\".*?\" FLAC/$wav WAVE/' "$WAV_FILE" \
52        | cue2toc - \
53        | sed s/CD_DA// \
54        >> $TOC_FILE
55    fi
56
57    flac -d -o $WAV_FILE $FLAC_FILE
58
59done
60
61cdrdao $COMMAND --eject $TOC_FILE
62
63rm -rf $BURNFLAC_TMP
Note: See TracBrowser for help on using the repository browser.