From: Rudolf Polzer Date: Wed, 12 Oct 2011 05:19:13 +0000 (+0200) Subject: more improvement for loopnote making from fluidsynth X-Git-Tag: xonotic-v0.6.0~15 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f0110faf3dc203ecfa0f634023840679c867ecde;p=xonotic%2Fmediasource.git more improvement for loopnote making from fluidsynth --- diff --git a/sound/weapons/loopfinder/findloop.c b/sound/weapons/loopfinder/findloop.c index 2207318..cbfc434 100644 --- a/sound/weapons/loopfinder/findloop.c +++ b/sound/weapons/loopfinder/findloop.c @@ -68,7 +68,7 @@ sf_count_t findMaximumSingle(double (*func) (sf_count_t), sf_count_t x0, sf_coun sf_count_t i; - for(i = x0 + step; i < x1; i += step) + for(i = x0; i < x1; i += step) { double cur = func(i); if(cur > best) @@ -88,21 +88,25 @@ sf_count_t findMaximum(double (*func) (sf_count_t), sf_count_t x0, sf_count_t xg xg0 = xg = MAX(x0, MIN(xg, x1)); xg20 = xg2 = MAX(x0, MIN(xg2, x1)); + fprintf(stderr, "min/max: %d %d\n", (int)xg, (int)xg2); + for(;;) { sf_count_t size = xg2 - xg; if(size == 0) break; - fprintf(stderr, "round:\n"); - sf_count_t bestguess = findMaximumSingle(func, xg, xg2, (xg2 - xg) / 16 + 1); - xg = MAX(x0, bestguess - size / 3); - xg2 = MIN(bestguess + size / 3, x1); + //fprintf(stderr, "round:\n"); + sf_count_t bestguess = findMaximumSingle(func, xg, xg2, size / 32 + 1); + xg = MAX(xg, bestguess - size / 3); + xg2 = MIN(bestguess + size / 3, xg2); } - if(xg - xg0 < (xg20 - xg0) / 16) + fprintf(stderr, "guessed: %d\n", (int)xg); + + if(xg - xg0 < (xg20 - xg0) / 64) fprintf(stderr, "warning: best match very close to left margin, maybe decrease the guess?\n"); - if(xg20 - xg < (xg20 - xg0) / 16) + if(xg20 - xg < (xg20 - xg0) / 64) fprintf(stderr, "warning: best match very close to right margin, maybe increase the guess?\n"); return xg; @@ -200,7 +204,7 @@ int main(int argc, char **argv) double sxy = vectorDot(data_end + ndata_lowpass, data_cur + ndata_lowpass, ndata_highpass - ndata_lowpass); double syy = vectorDot(data_cur + ndata_lowpass, data_cur + ndata_lowpass, ndata_highpass - ndata_lowpass); double v = syy ? ((sxy*sxy) / (sxx*syy)) : -1; - fprintf(stderr, "Evaluated at %.9f: %f\n", i / (double) infile_info.samplerate, v); + //fprintf(stderr, "Evaluated at %.9f: %f\n", i / (double) infile_info.samplerate, v); return v; } diff --git a/sound/weapons/tuba_loopnote_maker.sh b/sound/weapons/tuba_loopnote_maker.sh index 2c4521a..1565192 100755 --- a/sound/weapons/tuba_loopnote_maker.sh +++ b/sound/weapons/tuba_loopnote_maker.sh @@ -1,6 +1,6 @@ #!/bin/sh -set -ex +set -e ( cd loopfinder @@ -17,8 +17,8 @@ transpose=$1; shift tubaid=$1; shift delta=2 -fftsize=512 -loopmin=1.1 +fftsize=2048 +loopmin=0.5 loopmax=1.5 len=1.8 @@ -38,6 +38,7 @@ start=$delta step=$(($delta*2)) for note in -18 -12 -6 0 6 12 18 24; do sox "$t"/out.wav "$t"/n$note.wav \ + channels 1 \ trim $start $step \ silence 1 1s 0 @@ -45,7 +46,7 @@ for note in -18 -12 -6 0 6 12 18 24; do # now find loop point 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 + oggenc -Q -q9 -o "$fn" -c "LOOP_START=$SAMPLES" "$t"/t$note.wav done # next!