| for (i=0;i<(*length)-512;i++) { data = x_in_f+i-1; correl(data,data,512,ans); maxlag = SR/MAXF0; max = 0; for (j=top;j<=bot;j++) { if (ans[j] > max) { maxlag = j; max = ans[j]; } } f0[i+512] = SR/maxlag; /* i+512 to offset lag introduced by windowing */ if (f0[i+512] >= MAXF0) f0[i+512]=0; } |
| Exercise 5.1. If you change the first line of this loop to “for (i=0;i<(*length)-512;i+=80) ”, the autocorrelation will only be calculated every 80 samples, making the program run much faster. If you do this, use a smaller array for f0, and instead of writing f0 to a signal file, write out the values of f0 as text output. (See the end of cepstral_f0.c for an example.) |
| max = 0; for (j=top;j<=bot;j++) { if (ans[j] > max) { maxlag = j; max = ans[j]; } } |
gcc -c autocorr_f0.cNext: Linear Prediction
gcc -c nrutil.c
gcc -c correl.c
gcc -o autocorr_f0.exe nrutil.o correl.o autocorr_f0.o