⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cepst.m

📁 cepstral analisys for pitch and F0 detection
💻 M
字号:
function fx = cepst (x,fs)
    x = x';
    ms2=floor(fs*0.002);
    ms10=floor(fs*.01);
    ms20=floor(fs*0.02);
    ms30=floor(fs*0.03);
    % plot waveform
    t=(0:length(x)-1)/fs;
    subplot(2,1,1);
    plot(t,x);
    legend('Waveform');
    xlabel('Time (s)');
    ylabel('Amplitude');
    % get window
    w=hamming(ms30);
    pos=1; fx=[];
    while (pos+ms30) <= length(x)
        y=x(pos:pos+ms30-1);
        % do fourier transform of windowed signal
        Y=fft(y.*w);
        % cepstrum is DFT of log spectrum
        C=ifft(log(abs(Y)+eps));
        % search for maximum  between 2ms (=500Hz) and 20ms (=50Hz)
        [c,fxval]=max(abs(C(ms2:ms20)));
        fx=[fx fs/(ms2+fxval-1)];
        pos=pos+ms10;
    end
    % plot FX trace
    t=(0:length(fx)-1)*0.01;
    subplot(2,1,2);
    plot(t,fx);
    legend('FX Trace');
    xlabel('Time (s)');
    ylabel('Frequency (Hz)');
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -