1#!/bin/sh
2# Demo script for processing all audio tracks with a mp3 encoder
3# This variant creates temporary wav files. There is another
4# variant of this script (cdda2mp3), which uses a named pipe
5# instead. This variant needs more disk space than the other one.
6#
7# usage: cdda2mp3.new <name prefix for all mp3 files>
8#
9# list_audio_tracks is a (symbolic) link to cdda2wav
10# and used to generate a list of audio track numbers and start
11# sectors, which in turn are used in a loop to spawn cdda2wav
12# and the post processor on a track by track basis.
13
14#
15# feedback needed!!!!!!!!!!!!!!!!!
16#
17
18# specify the audio track listing program and its options
19LAT=list_audio_tracks
20LAT_OPTIONS=
21
22# specify the sampling program and its options
23# do not specify the track option here!
24CDDA2WAV=cdda2wav
25CDDA2WAV_OPTS='-Owav -H -P0 -q'
26
27# for normal use, comment out the next line with a #
28#DEBUG='-d1'
29
30# specify the post processing program and its options
31MP_CODER=l3enc
32#MP_OPTIONS='2>/dev/null 1>/dev/null'
33MP_OPTIONS='-br 128000'
34#MP_OPTIONS='-hq'
35
36WAVFILE=$$".wav"
37
38FILEPREFIX=${1:-audiotrack}
39
40# clean up wav file on exit, abort, ...
41trap "rm -rf $WAVFILE" 0 2 3 4 6 7 8 10 11 12 13 15
42
43# feed track numbers and start sectors into loop
44$LAT $LAT_OPTIONS | while read TRACK STARTSECTOR;
45do
46  $CDDA2WAV $CDDA2WAV_OPTS -t$TRACK $DEBUG $WAVFILE
47#  echo n | $MP_CODER $WAVFILE $FILEPREFIX$TRACK.mp3 $MP_OPTIONS
48  $MP_CODER $WAVFILE $FILEPREFIX$TRACK.mp3 $MP_OPTIONS
49
50  # check result code
51  RES=$?
52  if [ $RES = 0 ] ; then
53    echo File $FILEPREFIX$TRACK.mp3 finished successfully.
54    rm $WAVFILE
55  else
56    echo File $FILEPREFIX$TRACK.mp3 failed \(result $RES\). Aborted. >&2
57    break
58  fi
59done
60
61