1% pitch_test.m 2% David Rowe Sep 2009 3% Constructs a sequence to test the pitch estimator 4 5function pitch_test(samname) 6 M=320; 7 F=200; 8 9 fs=fopen(samname,"wb"); 10 11 f0 = 100; 12 for f=1:200 13 Wo=2*pi*f0/8000; 14 P=2*pi/Wo; 15 L = floor(pi/Wo); 16 A = 10000/L; 17 phi = zeros(1,L); 18 s = zeros(1,M); 19 20 for m=1:L 21 s = s + A*cos(m*Wo*(0:(M-1)) + phi(m)); 22 endfor 23 24 figure(1); 25 clf; 26 plot(s); 27 28 fwrite(fs,s,"short"); 29 30 f0 = f0 + 5; 31 if (f0 > 400) 32 f0 = 100; 33 endif 34 endfor 35 36 fclose(fs); 37 38endfunction 39 40