]> git.xonotic.org Git - xonotic/mediasource.git/commitdiff
more improvement for loopnote making from fluidsynth
authorRudolf Polzer <divverent@xonotic.org>
Wed, 12 Oct 2011 05:19:13 +0000 (07:19 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Wed, 12 Oct 2011 05:19:13 +0000 (07:19 +0200)
sound/weapons/loopfinder/findloop.c
sound/weapons/tuba_loopnote_maker.sh

index 22073187ceab3a9f4eed2d50f0a8951e7ecef997..cbfc43409b94fd7012701ae838371911987dc984 100644 (file)
@@ -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;
        }
 
index 2c4521a31125a05d1e14da6bd2d04318e0cf868d..1565192f58e6d7f8b4b6272da160305541d038fb 100755 (executable)
@@ -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!