Help with Cepstral analysis and in particular finding maximum peak between two quefrency points.

5 views (last 30 days)
I have adapted some code from Univeristy College London's online Introduction to Computer Programming with MATLAB for calculating the cepstrum of a sound file. This is my code so far:
% Load sound file
fn = input('Enter WAV filename : ','s');
[x,fs] = wavread(fn);
ms20=(fs/1000)*16.7; % minimum speech Fx at 50Hz/20ms
ms3=(fs/1000)*4; % maximum speech Fx at 300Hz/3ms
%
% Do fourier transform of windowed signal
Y=fft(x.*hamming(length(x)));
%
% Cepstrum is DFT of log spectrum
C=fft(log(abs(Y)+eps));
% convert cepstral amplitude into cepstral magnitude (dB)
C=10*log10(C);
%
q=(ms3:ms20)/fs;
% Change orientation of 'q'
q = q.';
%
% Cepstral peak and index within array
[cpeak, i] = max(abs(C(ms3:ms20)));
% Linear Regression Line
% Calculate coefficients
p = polyfit(q,abs(C(ms3:ms20)),1);
% Calculate equation of the line (y)
y = polyval(p,q);
% Calculate the value(v) of regression line below cepstral peak
v = polyval(p,q(i));
% Calculate CPP (i.e. cepstral peak (cpeak) - value of regression line below cepstral peak (v)
cpeak-v
%
% Plot between 3ms and 20ms
plot(q,C(ms3:ms20),q,y);
legend('Cepstrum', 'Linear','Location','Best');
xlabel('Quefrency (s)');
ylabel('Magnitude (dB)');
There are some aspects of this code that I am unsure about, but my main question is about finding the value for 'cpeak'. I want to be able to find the highest value for C (the cepstrum) between two values of q (the quefrency) - say between 6ms and 8ms. How do I go about doing this? I then want to find the value of the linear regression line directly below this highest value for C, and that is what I have attempted to do in the above code. However, it isn't very good, as you can see and I have difficulty fixing it for my purposes.
I hope someone can help.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!