find_harm.m
上传用户:xxy784
上传日期:2015-01-28
资源大小:726k
文件大小:1k
源码类别:

压缩解压

开发平台:

Matlab

  1. %Find harmonics of the base frequency
  2. %Input:
  3. %        res(residual signal of the quantized LPC)
  4. %        p3(final pitch)
  5. %Output:
  6. %        mag(fourier spectrum magnitude)
  7. function mag=find_harm(res,p3)
  8. down=fix(256/p3);                %floor level of the base frequency
  9. M=fix(p3/4);                     %Get the number of the harmonics
  10. if M<10
  11.    for n=1:M
  12.       up=fix((n+0.5)*512/p3);
  13.       mag(n)=max(res(down:up));
  14.       down=up+1;
  15.    end
  16.    mag=mag*sqrt(M)/norm(mag);
  17.    mag(M+1:10)=1;  
  18. else
  19.    for n=1:10
  20.       up=fix((n+0.5)*512/p3);
  21.       mag(n)=max(res(down:up));
  22.       down=up+1;
  23.    end
  24.    mag=mag*sqrt(10)/norm(mag);
  25. end