-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwavNormalize.sh
More file actions
executable file
·44 lines (36 loc) · 1.3 KB
/
Copy pathwavNormalize.sh
File metadata and controls
executable file
·44 lines (36 loc) · 1.3 KB
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
#!/bin/bash
source @includes.sh
echo '###################################################'
echo '# Description: Normalizes a wav file'
echo '# Usage: $ ./wavNormalize.sh /path/to/audio.wav [-3]'
echo '# Param 1: Audio file'
echo '# Param 2 [Optional: db to normalize to (0 is max volume)'
echo '# Requires: SoX'
echo '###################################################'
echoNewline
################################################################################
################################################################################
# check parameters
if [[ $1 == "" ]] ; then
echoError "1st arg must be an audio file"
exit 1
fi
gain=0
if [[ $2 -eq 0 ]] ; then
echoInfo "[Optional]: Using default gain of $gain"
else
gain=$2
fi
################################################################################
################################################################################
# get filename
filename=$1
extension=$(extension $filename)
outputFile="$filename.normalized.$extension"
echoInfo "Normalizing audio: $filename"
# do conversion
sox $filename "$outputFile" norm $gain
################################################################################
################################################################################
# complete
echoSuccess "Normalized: $outputFile"