-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapply_replaygain
executable file
·52 lines (41 loc) · 1.33 KB
/
apply_replaygain
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
# Applies replaygain info to all compatible files in the specified directory
if [[ $# -lt 1 ]]; then
echo "Usage: $0 [directory]"
exit
fi
cd "$1"
find . -type f | sort | while read f; do
# Convert filename to lowercase to match extension
filenameLower="${f,,}"
case "$filenameLower" in
*.flac)
metaflac --list "$f" | grep -q REPLAYGAIN
# No replaygain data found
if [[ $? -eq 1 ]]; then
echo "-> Applying replaygain to FLAC file $f"
metaflac --add-replay-gain "$f"
if [[ $? -eq 1 ]]; then
echo "Failed, trying to resample FLAC file $f"
/home/tails/bin/resample_flac "$f"
fi
fi
;;
*.ogg)
vorbiscomment -l "$f"| grep -q REPLAYGAIN_TRACK
# No replaygain data found
if [[ $? -eq 1 ]]; then
echo "-> Applying replaygain to OGG file $f"
vorbisgain "$f"
fi
;;
*.mp3 | *.m4a )
aacgain -s c "$f" | grep -q "Recommended"
# No replaygain data found
if [[ $? -eq 1 ]]; then
echo "-> Applying replaygain to MP3/M4A file $f"
aacgain -k "$f"
fi
;;
esac
done