pitch_test.m 549 B

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