pulse.m 669 B

12345678910111213141516171819202122232425262728293031323334353637
  1. % pulse.m
  2. % David Rowe August 2009
  3. %
  4. % Experiments with human pulse perception for sinusoidal codecs
  5. function pulse(samname)
  6. A = 1000;
  7. K = 16000;
  8. N = 80;
  9. frames = K/N;
  10. s = zeros(1,K);
  11. for f=1:frames
  12. % lets try placing np random pulses in every frame
  13. P = 20 + (160-20)*rand(1,1);
  14. Wo = 2*pi/P;
  15. L = floor(pi/Wo);
  16. sf = zeros(1,N);
  17. for m=1:L/2:L
  18. pos = floor(rand(1,1)*N)+1;
  19. %pos = 50;
  20. for l=m:m+L/2-1
  21. sf = sf + A*cos(l*Wo*((f-1)*N+1:f*N) - pos*l*Wo);
  22. endfor
  23. endfor
  24. s((f-1)*N+1:f*N) = sf;
  25. endfor
  26. plot(s(1:250));
  27. fs=fopen(samname,"wb");
  28. fwrite(fs,s,"short");
  29. fclose(fs);
  30. endfunction