Debian Codegraph @

sounds/make_pitch_variations.sh

raw symbols SCIP
1 #!/bin/bash
2 # Create a bunch of pitch-shifted variations of a sound file
3 # Requires SoX (http://sox.sourceforge.net/)
4 # Sounds vary between +/- 2 tones
5 # Usage: ./make_pitch_variations.sh <sound_file> <num_variations/2>
6 # Sound file should be named with a zero, e.g. foo0.ogg, so that the variations
7 # can be called foo1.ogg, foo2.ogg and so on (foo/0.ogg becomes foo/1.ogg etc.)
8 if [ "$#" -lt 2 ]; then
9 echo "Usage: ./make_pitch_variations.sh <sound_file> <num_variations/2>"
10 exit 1
11 fi
12 SHIFT_RANGE=200
13 if [ "$#" -eq 3 ]; then
14 SHIFT_RANGE=$3
15 fi
16 FILENAME_PREFIX=${1%%0.*}
17 EXTENSION=${1##*.}
18 for i in $(seq 1 "$2")
19 do
20 FILENAME="${FILENAME_PREFIX}$(((i - 1) * 2 + 1)).${EXTENSION}"
21 SHIFT=$((SHIFT_RANGE * i / $2))
22 sox -G "$1" "$FILENAME" pitch "$SHIFT"
23 FILENAME="${FILENAME_PREFIX}$((i * 2)).${EXTENSION}"
24 sox -G "$1" "$FILENAME" pitch "-$SHIFT"
25 done