|
|
########################################
####################
# Here's a script to play around with or whatever
########################################
####################
########################################
####################
# It is convenient to go into the riptool shell
# & do things manually, (e.g., edit tracks,
# edit track list, download files, etc.).
########################################
###################
# Tip: You can use 0 for track# (in track_list file) if wav file is
# already available, because you've already ripped it,
# or whatever.
#
#!/bin/sh
########################################
###################
# riptool - track ripper manager #
# - uses cdparanoia, cdrdao, lame, mpg321, oggenc #
########################################
###################
# Change editor if needed (i.e, vi, emacs, jed, joe, etc.)
RIP_EDITOR="pico +2" # put cursor on the second line
#--------------------------------------------------------
menu() {
echo
echo " riptool"
echo " ^^^^^^^"
echo
echo "(a) Strip all tracks from CD"
echo "(c) Create track list"
echo "(m) Create mp3s from wavs"
echo "(n) Normalize wav files"
echo "(o) Create oggs from wavs"
echo "(p) Play list"
echo "(r) Rip tracks from list"
echo "(s) Shell"
echo "(q) Quit"
echo "(w) Write CD"
echo "(x) Make wavs from mp3s"
echo "Choose c, m, n, o, p, r, s, w, or q"
read MENU_SELECT
return
}
#----------------------------------------------------------
strip_all_tracks_from_CD () {
# -D Can cdrecord -scanbus to get numbers
# -B Copies each track into a separate file
# -vall maximum verbosity
cdda2wav -vall cddb=0 -D1,0,0 -B -Owav
return
}
#----------------------------------------------------------
track_list_cmd_mgr() {
echo "<track #> <track_title.wav>" > track_list_$$
$RIP_EDITOR track_list_$$
TRACKLIST='yes'
return
}
#----------------------------------------------------------
rip_cmd() {
echo "#!/bin/sh" > rip_cmd_$$
while read LINE
do
RESULT=$(echo $LINE | grep '^[0-9]\{1,3\}')
if [ "$RESULT" = "" ]
then
continue
fi
echo "echo \"Place disc in tray\"" >> rip_cmd_$$
echo "echo \"to rip track# => $RESULT\"" >> rip_cmd_$$
echo "eject" >> rip_cmd_$$
echo "echo \"Press 't' to close tray\"" >> rip_cmd_$$
echo "read CLOSETRAY" >> rip_cmd_$$
echo "while [ \"\$CLOSETRAY\" = 't' ]" >> rip_cmd_$$
echo "do " >> rip_cmd_$$
echo "eject -t" >> rip_cmd_$$
echo "cdparanoia --verbose -z $RESULT" >> rip_cmd_$$
echo "CLOSETRAY=''" >> rip_cmd_$$
echo "done" >> rip_cmd_$$
done < track_list_$$
chmod 700 rip_cmd_$$
echo
echo
echo " Ripping track"
echo " ^^^^^^^^^^^^^"
../rip_cmd_$$
return
}
#----------------------------------------------------------
rip_cmd_mgr() {
if [ "$TRACKLIST" = "" ]
then
echo "***************************"
echo "* Create track list first *"
echo "***************************"
echo
return
fi
rip_cmd
return
}
#----------------------------------------------------------
cleanup() {
rm -i *_$$
rm -i cd.toc
return
}
#----------------------------------------------------------
play_mgr() {
if [ "$TRACKLIST" = "" ]
then
return
fi
while read LINE
do
RESULT=$(echo $LINE | grep 'wav$')
if [ "$RESULT" != "" ]
then
PLAYTRACK=$( echo $RESULT | sed 's/^[0-9]\{1,3\}//g')
echo "Playing $PLAYTRACK"
play $PLAYTRACK
fi
done < track_list_$$
return
}
#----------------------------------------------------------
cd_write_mgr() {
clear
echo "Writing cd_toc file ..."
progress_indicator &
PI=$!
echo "CD_DA" > cd.toc
while read LINE
do
TMPX=$(echo $LINE | grep '^[0-9]\{1,3\}')
TMPZ=$(echo $TMPX | sed 's/^[0-9]\{1,3\}//g')
RESULT=$(echo $TMPZ | sed 's/ *^//g')
if [ "$RESULT" != "" ]
then
echo "TRACK AUDIO" >> cd.toc
echo "AUDIOFILE \"$RESULT\" 0" >> cd.toc
fi
done < track_list_$$
/bin/kill -9 $PI
echo -n -e 'Done\r\c'
eject
echo "Press 't' to close tray"
read CLOSETRAY
while [ "$CLOSETRAY" = 't' ]
do
eject -t
cdrdao write --overburn --driver generic-mmc cd.toc
CLOSETRAY=""
done
return
}
#----------------------------------------------------------
normalize_tracks() {
normalize -m *.wav
return
}
#---------------------------------------------------------
create_mp3s() {
for i in *.wav;
do
lame --verbose --preset extreme $i `basename $i .wav`.mp3;
done
}
#---------------------------------------------------------
create_wavs_from_mp3s () {
for i in *.mp3;
do
madplay -v -o `basename $i .mp3`.wav $i;
done
}
#---------------------------------------------------------
create_oggs() {
for i in *.wav; do oggenc -q 10 $i; done
}
#----------------------------------------------------------
progress_indicator () {
DASH=( '|\r\c' '/\r\c' '-\r\c' '\\\r\c' )
while [ 1 ]
do
for i in 1 2 3 4
do
echo -e -n "${DASH[i]}"
done
done
return
}
#-----------------------------------------------------------
create_shell () {
PS1="riptool-[\w]<\#> "
export PS1
sh
return
}
#----------------------------------------------------------
########
# MAIN #
########
while [ "$QUIT" != 'yes' ]
do
menu
case $MENU_SELECT in
a) strip_all_tracks_from_CD;;
c) track_list_cmd_mgr;;
r) rip_cmd_mgr;;
w) cd_write_mgr;;
p) play_mgr;;
q) QUIT='yes';;
n) normalize_tracks;;
m) create_mp3s;;
o) create_oggs;;
s) create_shell;;
x) create_wavs_from_mp3s;;
*) echo "No such option";;
esac
done
#-----------------------------------------------
cleanup
exit 0
################## end riptool ######################
|
|