1159b3361Sopenharmony_ci### (c)2000-2011 Robert Hegemann 2159b3361Sopenharmony_ci### 3159b3361Sopenharmony_ci### /<path>/<artist>/<year>-<album>/<track-no> <title> 4159b3361Sopenharmony_ci### 5159b3361Sopenharmony_ci### SRC_ROOT : where the CD are located 6159b3361Sopenharmony_ci### DST_ROOT : where newly encoded tracks should go 7159b3361Sopenharmony_ci### DONE_ROOT : where verified encoded tracks are located 8159b3361Sopenharmony_ci### LAME_EXE : points to program 9159b3361Sopenharmony_ci### LAME_OPT : what options to use 10159b3361Sopenharmony_ci################################################################ 11159b3361Sopenharmony_ci_V=2 12159b3361Sopenharmony_ciSRC_ROOT=/windows/W/CD 13159b3361Sopenharmony_ciDST_ROOT=/windows/Z/mp3v${_V}wg 14159b3361Sopenharmony_ciDONE_ROOT=/windows/Z/mp3v${_V}wg 15159b3361Sopenharmony_ciLAME_EXE=lame-399 16159b3361Sopenharmony_ciLAME_OPT="-V${_V} --quiet --noreplaygain --id3v2-only" 17159b3361Sopenharmony_ci 18159b3361Sopenharmony_ciSKIP_DONE_FOLDER_EXISTS=1 19159b3361Sopenharmony_ciSKIP_DEST_FOLDER_EXISTS=1 20159b3361Sopenharmony_ciSCAN_ALBUM_GAIN_ONLY=0 21159b3361Sopenharmony_ci 22159b3361Sopenharmony_cicase "$0" in 23159b3361Sopenharmony_ci mk_album_gain.sh) SCAN_ALBUM_GAIN_ONLY=1;; 24159b3361Sopenharmony_ciesac 25159b3361Sopenharmony_cicase "$1" in 26159b3361Sopenharmony_ci --scan-gain-only) SCAN_ALBUM_GAIN_ONLY=1;; 27159b3361Sopenharmony_ciesac 28159b3361Sopenharmony_ciif [ $SCAN_ALBUM_GAIN_ONLY = 1 ] 29159b3361Sopenharmony_cithen 30159b3361Sopenharmony_ci SKIP_DONE_FOLDER_EXISTS=0 31159b3361Sopenharmony_ci SKIP_DEST_FOLDER_EXISTS=0 32159b3361Sopenharmony_cifi 33159b3361Sopenharmony_ci 34159b3361Sopenharmony_ciif (test -e "${SRC_ROOT}") 35159b3361Sopenharmony_cithen 36159b3361Sopenharmony_ci if test -e "${DST_ROOT}" 37159b3361Sopenharmony_ci then 38159b3361Sopenharmony_ci : 39159b3361Sopenharmony_ci else 40159b3361Sopenharmony_ci mkdir "${DST_ROOT}" 41159b3361Sopenharmony_ci fi 42159b3361Sopenharmony_ci 43159b3361Sopenharmony_ci for _artist in "${SRC_ROOT}"/* 44159b3361Sopenharmony_ci do 45159b3361Sopenharmony_ci _ARTIST=$(basename "${_artist}") 46159b3361Sopenharmony_ci DST_ARTIST=${DST_ROOT}/${_ARTIST} 47159b3361Sopenharmony_ci DS2_ARTIST=${DONE_ROOT}/${_ARTIST} 48159b3361Sopenharmony_ci echo "${_ARTIST}" 49159b3361Sopenharmony_ci 50159b3361Sopenharmony_ci VARIOUS_ARTISTS_MODE=0 51159b3361Sopenharmony_ci case "${_ARTIST}" in 52159b3361Sopenharmony_ci "Various" | "Various Artists" ) 53159b3361Sopenharmony_ci VARIOUS_ARTISTS_MODE=1 54159b3361Sopenharmony_ci ID3_ALBUM_ARTIST="Various Artists" 55159b3361Sopenharmony_ci ;; 56159b3361Sopenharmony_ci "Musik Express" ) 57159b3361Sopenharmony_ci VARIOUS_ARTISTS_MODE=2 58159b3361Sopenharmony_ci ID3_ALBUM_ARTIST="Various (ME)" 59159b3361Sopenharmony_ci ;; 60159b3361Sopenharmony_ci *) 61159b3361Sopenharmony_ci VARIOUS_ARTISTS_MODE=0 62159b3361Sopenharmony_ci ID3_ALBUM_ARTIST=${_ARTIST} 63159b3361Sopenharmony_ci ;; 64159b3361Sopenharmony_ci esac 65159b3361Sopenharmony_ci 66159b3361Sopenharmony_ci for _cd in "${_artist}"/* 67159b3361Sopenharmony_ci do 68159b3361Sopenharmony_ci _CD=$(basename "${_cd}") 69159b3361Sopenharmony_ci DST_CD=${DST_ARTIST}/${_CD} 70159b3361Sopenharmony_ci DS2_CD=${DS2_ARTIST}/${_CD} 71159b3361Sopenharmony_ci ID3_YR=`echo "${_CD}"|cut -b 1-4` 72159b3361Sopenharmony_ci ID3_CD=`echo "${_CD}"|cut -b 6-` 73159b3361Sopenharmony_ci if [ $SKIP_DONE_FOLDER_EXISTS = 1 ] 74159b3361Sopenharmony_ci then 75159b3361Sopenharmony_ci if test -e "${DS2_CD}" 76159b3361Sopenharmony_ci then 77159b3361Sopenharmony_ci continue 78159b3361Sopenharmony_ci fi 79159b3361Sopenharmony_ci fi 80159b3361Sopenharmony_ci if [ $SKIP_DEST_FOLDER_EXISTS = 1 ] 81159b3361Sopenharmony_ci then 82159b3361Sopenharmony_ci if test -e "${DST_CD}" 83159b3361Sopenharmony_ci then 84159b3361Sopenharmony_ci continue 85159b3361Sopenharmony_ci fi 86159b3361Sopenharmony_ci fi 87159b3361Sopenharmony_ci echo "${_ARTIST} / ${_CD}" 88159b3361Sopenharmony_ci 89159b3361Sopenharmony_ci ALBUM_GAIN="1.0" 90159b3361Sopenharmony_ci if test -e "${_cd}/album_gain_scale.txt" 91159b3361Sopenharmony_ci then 92159b3361Sopenharmony_ci ALBUM_GAIN=`cat "${_cd}/album_gain_scale.txt"` 93159b3361Sopenharmony_ci elif test -e "${DS2_CD}/album_gain_scale.txt" 94159b3361Sopenharmony_ci then 95159b3361Sopenharmony_ci ALBUM_GAIN=`cat "${DS2_CD}/album_gain_scale.txt"` 96159b3361Sopenharmony_ci elif test -e "${DST_CD}/album_gain_scale.txt" 97159b3361Sopenharmony_ci then 98159b3361Sopenharmony_ci ALBUM_GAIN=`cat "${DST_CD}/album_gain_scale.txt"` 99159b3361Sopenharmony_ci else 100159b3361Sopenharmony_ci unset ALBUM_GAIN 101159b3361Sopenharmony_ci fi 102159b3361Sopenharmony_ci if [ "${ALBUM_GAIN}" = "" ] 103159b3361Sopenharmony_ci then 104159b3361Sopenharmony_ci if test -e "${DST_ARTIST}" 105159b3361Sopenharmony_ci then 106159b3361Sopenharmony_ci : 107159b3361Sopenharmony_ci else 108159b3361Sopenharmony_ci mkdir "${DST_ARTIST}" 109159b3361Sopenharmony_ci fi 110159b3361Sopenharmony_ci if test -e "${DST_CD}" 111159b3361Sopenharmony_ci then 112159b3361Sopenharmony_ci : 113159b3361Sopenharmony_ci else 114159b3361Sopenharmony_ci mkdir "${DST_CD}" 115159b3361Sopenharmony_ci fi 116159b3361Sopenharmony_ci ALBUM_GAIN=`wavegain -x -a "${_cd}"/ 2>/dev/null` 117159b3361Sopenharmony_ci echo ${ALBUM_GAIN} > "${DST_CD}/album_gain_scale.txt" 118159b3361Sopenharmony_ci fi 119159b3361Sopenharmony_ci if [ $SCAN_ALBUM_GAIN_ONLY = 1 ] 120159b3361Sopenharmony_ci then 121159b3361Sopenharmony_ci continue 122159b3361Sopenharmony_ci fi 123159b3361Sopenharmony_ci 124159b3361Sopenharmony_ci for _song in "${_cd}"/*.wav 125159b3361Sopenharmony_ci do 126159b3361Sopenharmony_ci _SONG=$(basename "${_song}" .wav) 127159b3361Sopenharmony_ci DST_SONG=${DST_CD}/$(basename "${_song}" .wav).mp3 128159b3361Sopenharmony_ci if test -e "${DST_SONG}" 129159b3361Sopenharmony_ci then 130159b3361Sopenharmony_ci : 131159b3361Sopenharmony_ci else 132159b3361Sopenharmony_ci if test -e "${DST_ARTIST}" 133159b3361Sopenharmony_ci then 134159b3361Sopenharmony_ci : 135159b3361Sopenharmony_ci else 136159b3361Sopenharmony_ci mkdir "${DST_ARTIST}" 137159b3361Sopenharmony_ci fi 138159b3361Sopenharmony_ci if test -e "${DST_CD}" 139159b3361Sopenharmony_ci then 140159b3361Sopenharmony_ci : 141159b3361Sopenharmony_ci else 142159b3361Sopenharmony_ci mkdir "${DST_CD}" 143159b3361Sopenharmony_ci fi 144159b3361Sopenharmony_ci ID3_TRACK=`echo "${_SONG}"|cut -b 1-2` 145159b3361Sopenharmony_ci if [ $VARIOUS_ARTISTS_MODE = 0 ] 146159b3361Sopenharmony_ci then 147159b3361Sopenharmony_ci ID3_TITLE=`echo "${_SONG}"|cut -b 4-` 148159b3361Sopenharmony_ci ID3_TRACK_ARTIST=${_ARTIST} 149159b3361Sopenharmony_ci else 150159b3361Sopenharmony_ci ID3_TITLE=`echo "${_SONG% - *}"|cut -b 4-` 151159b3361Sopenharmony_ci ID3_TRACK_ARTIST=`echo "${_SONG#* - }"` 152159b3361Sopenharmony_ci fi 153159b3361Sopenharmony_ci ${LAME_EXE} ${LAME_OPT} \ 154159b3361Sopenharmony_ci --scale ${ALBUM_GAIN} \ 155159b3361Sopenharmony_ci --ta "${ID3_TRACK_ARTIST}" \ 156159b3361Sopenharmony_ci --tl "${ID3_CD}" \ 157159b3361Sopenharmony_ci --ty "${ID3_YR}" \ 158159b3361Sopenharmony_ci --tt "${ID3_TITLE}" \ 159159b3361Sopenharmony_ci --tn "${ID3_TRACK}" \ 160159b3361Sopenharmony_ci --tv "TXXX=ALBUM ARTIST=${ID3_ALBUM_ARTIST}" \ 161159b3361Sopenharmony_ci --tv "TXXX=LAME SCALE=${ALBUM_GAIN}" \ 162159b3361Sopenharmony_ci "${_song}" "${DST_SONG}" & 163159b3361Sopenharmony_ci fi 164159b3361Sopenharmony_ci done 165159b3361Sopenharmony_ci wait 166159b3361Sopenharmony_ci done 167159b3361Sopenharmony_ci done 168159b3361Sopenharmony_cielse 169159b3361Sopenharmony_ci echo Quellverzeichnis ${SRC_ROOT} existiert nicht. 170159b3361Sopenharmony_cifi 171