function [y,p]=chvocod_ana(x, D, N)
%CHVOCOD_ANA	Analyzes speech waveform into pitch and band envelope signals
%		[y,p] = CHVOCOD_ANA(x, D, N)
%
%		x	vector containing speech signal to encode
%		D	decimation rate
%		N	number of bands
%
%		y	output matrix of band envelope signals
%			each column contains output of one band
%			each row contains output of one frame
%		p	output vector containing pitch signal with one
%			sample for each frame

% Make x a column vector just to be sure.
x = x(:);

Fs = 8000;			% sampling frequency
frlen = floor(0.030 * Fs);      % use 30ms frame length
nframes = ceil(length(x)/D);    % number of frames

% preallocate output for speed
pitch = zeros(nframes, 1);
% Preallocate output matrix "y" for efficiency.
y = zeros(nframes,N);

%-------------------- get "source parameters" (pitch detection)-------------

% First, lowpass filter the signal with 1 kHz cutoff frequency, 
% since we're interested in pitch, which is 80-320 Hz for adult voices.
% (Note that the lowpass filtered signal should be used as the input
% to the pitch detector, but not to the filter bank.) 

xlpf = 


% Here's the loop. Each iteration processes one frame of data.

for i = 1:nframes

   %  Get the next segment.  The indexing has been done for you.
   startseg = (i-1)*D+1;
   endseg = startseg+frlen-1;
   if endseg > length(xlpf)
     endseg = length(xlpf);
   end
   seg = xlpf(startseg:endseg);
   
   % Call your pitch detector . . .


end

% Remove spurious values from pitch signal with median filter . . .


%--------- get "filter" parameters (determine band envelope values)-----------

% Compute FIR coefficients for filter bank (use 65-point filters) . . .

bank = myownfilt_bank(N,65);

% In loop, process each band:
for i = 1:N
%	Apply filter for this band (bank(:,i)) to input x (not xlpf) . . .

% 	Take magnitude of signal and decimate.
% 	(The matlab function decimate includes lowpass filtering) . . .

end






