PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. % Talkie library
  2. % Copyright 2011 Peter Knight
  3. % This code is released under GPLv2 license.
  4. %
  5. % Synthesise model parameters
  6. function samples=lpcSynth(pitch,energy,coefficients,length,poles,sampleRate)
  7. samples = zeros(1,length);
  8. u = zeros(1,poles+1);
  9. x = zeros(1,poles+1);
  10. % Generate excitation
  11. if pitch>0
  12. % Voiced
  13. excite = zeros(1,length);
  14. for a=1:(sampleRate/pitch):length
  15. excite(floor(a)) = 1;
  16. end
  17. %excite = mod((1:length)*pitch/sampleRate,1)-0.5;
  18. else
  19. % Unvoiced
  20. excite = rand(1,length)-0.5;
  21. end
  22. excite = excite * energy;
  23. % Run through filter
  24. for s=1:length
  25. u(poles+1) = excite(s);
  26. for t=poles:-1:1
  27. u(t) = u(t+1) - coefficients(t+1)*x(t);
  28. end
  29. for v=poles-1:-1:1
  30. x(v+1) = x(v) + coefficients(v+1)*u(v);
  31. end
  32. if x(1) > 1
  33. x(1) = 1;
  34. end
  35. if x(1) < -1
  36. x(1) = -1;
  37. end
  38. x(1) = u(1);
  39. samples(s) = u(1);
  40. end
  41. samples = samples';