-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsq-remove-if-silent.sh
executable file
·61 lines (48 loc) · 1.83 KB
/
sq-remove-if-silent.sh
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
53
54
55
56
57
58
59
60
61
#!/bin/bash
#
# The multitrack recorder in the Allen & Heath SQ series does not allow you to select which tracks
# to record. So you'll have plenty of empty files.
#
# This script uses sox to analyze your files and delete those that supposedly only contain
# preamp noise.
#
# USE WITH CARE! NEVER USE WITHOUT BACKUP!
#
# sq-remove-if-silent.sh
# Copyright 2023-2025 Niels Ott https://www.niels-ott.de
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
if [ ! $(which sox) ] ; then
echo "error: sox not found."
exit 1
fi
IN="$1"
# damit greppen nicht floppt
export LANG="en"
# leiser als X: löschen
VOL_THRESHOLD=31000
# volume adjustment (= vorgeschlagener gain boost) rausholen
adjust=$(sox "$IN" -n stat 2>&1 | grep -i 'volume adjustment' | awk '{ print $3 }')
# wenn kein volume adjustment vorhanden, dann ist digitale Stille
if [ "$adjust" = "" ] ; then
rm "$IN" && echo "$IN gelöscht, digitale Stille" || echo "Fehler: Konnte "$IN" nicht löschen."
exit
fi
#nachkommastellen killen
adjust=$(echo "$adjust" | sed -e 's/\.[0-9]*$//')
# vermutlich nur grundrauschen!
if [ $adjust -gt $VOL_THRESHOLD ] ; then
rm "$IN" && echo "$IN gelöscht, vermutlich nur Grundrauschen" || echo "Fehler: Konnte "$IN" nicht löschen."
exit
fi
echo "$IN bleibt."