%Demo done during Session 19 demonstrating
%efficacy of differentiator by first upsampling
%followed by simple differencing
clf
set(0,'defaultaxesfontsize',20);
N=256;
hd=[1 -1];
hdfft=fftshift(fft(hd,N));
subplot(211)
hdmag=(abs(hdfft));
hdang=angle(hdfft);
freqomega=linspace(-pi,pi,N);
hdrmag=sign(freqomega).*hdmag;
plot(freqomega,hdrmag,'LineWidth',4);
axis([-pi pi -pi pi]);
title('Derivative Response'),...
xlabel('Omega'), ylabel('Magnitude'), grid
subplot(212)
plot(freqomega,hdang,'LineWidth',4);
axis([-pi pi -pi pi]);
title('Simple Differentiator Response')
pause
data=getspeech('enf1s1t0.wav');
Fs=12500;
clf
plot(data)
end1=input('end1?')
end2=input('end2?')
%del=end2-end1;
datar=data(end1:end2);
xup=resample(datar,8,1);
Fsnew=8*Fs; Ts=1/Fsnew;  fudge=10;
yh=fudge*conv(xup,hd);
e1=2125; e2=2300;
plot((e1:e2),yh(e1:e2),(e1:e2),xup(e1:e2),'LineWidth',4);
hold on
plot([e1 e2],[0 0],'k','Linewidth',2)
hold off
legend('Derivative','Speech')

