From b75676d61aabe5a29b092a638845dfaa23bfde04 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Wed, 12 Oct 2011 06:42:27 +0200 Subject: [PATCH] use a temp dir --- sound/weapons/tuba_loopnote_maker.sh | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/sound/weapons/tuba_loopnote_maker.sh b/sound/weapons/tuba_loopnote_maker.sh index 7c1d55a..2c4521a 100755 --- a/sound/weapons/tuba_loopnote_maker.sh +++ b/sound/weapons/tuba_loopnote_maker.sh @@ -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 -- 2.39.2