]> git.rm.cloudns.org Git - xonotic/mediasource.git/commitdiff
use a temp dir
authorRudolf Polzer <divverent@xonotic.org>
Wed, 12 Oct 2011 04:42:27 +0000 (06:42 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Wed, 12 Oct 2011 04:42:27 +0000 (06:42 +0200)
sound/weapons/tuba_loopnote_maker.sh

index 7c1d55aa79c2f02991a86fb2625cf8a9b9111c68..2c4521a31125a05d1e14da6bd2d04318e0cf868d 100755 (executable)
@@ -7,6 +7,9 @@ set -ex
        gcc -o findloop findloop.c -lfftw3 -Wall -Wextra -ffast-math -lsndfile -O3
 )
 
+t=`mktemp -dt loopfinder.XXXXXX`
+trap 'rm -rf "$t"' EXIT
+
 synth=$1; shift
 program=$1; shift
 velocity=$1; shift
@@ -19,33 +22,34 @@ loopmin=1.1
 loopmax=1.5
 len=1.8
 
-perl tuba_loopnote_maker.mid.pl tuba_loopnote_maker.mid $delta $program $velocity $transpose -18 -12 -6 0 6 12 18 24
+perl tuba_loopnote_maker.mid.pl "$t"/tuba_loopnote_maker.mid $delta $program $velocity $transpose -18 -12 -6 0 6 12 18 24
 
 case "$synth" in
        timidity)
-               timidity -Ow "$@" -o out.wav tuba_loopnote_maker.mid
-               normalize out.wav
+               timidity -Ow "$@" -o "$t"/out.wav "$t"/tuba_loopnote_maker.mid
                ;;
        fluidsynth)
-               fluidsynth -v -n -i -l -T wav -F out.wav "$@" tuba_loopnote_maker.mid
-               normalize out.wav
+               fluidsynth -v -n -i -l -T wav -F "$t"/out.wav "$@" "$t"/tuba_loopnote_maker.mid
                ;;
 esac
+normalize "$t"/out.wav
 
 start=$delta
 step=$(($delta*2))
 for note in -18 -12 -6 0 6 12 18 24; do
-       sox out.wav n$note.wav \
+       sox "$t"/out.wav "$t"/n$note.wav \
                trim $start $step \
                silence 1 1s 0
 
        fn=tuba"$tubaid"_loopnote"$note".ogg 
 
        # now find loop point
-       loopfinder/findloop n$note.wav $fftsize $len $loopmin $loopmax t$note.wav | while read -r SAMPLES SECONDS; do
-               oggenc -q9 -o "$fn" -c "LOOP_START=$SAMPLES" t$note.wav
+       loopfinder/findloop "$t"/n$note.wav $fftsize $len $loopmin $loopmax "$t"/t$note.wav | while read -r SAMPLES SECONDS; do
+               oggenc -q9 -o "$fn" -c "LOOP_START=$SAMPLES" "$t"/t$note.wav
        done
 
        # next!
        start=$(($start+$step))
 done
+
+exit 0