%--
%-- specgram demo idea
%--
format compact
Fs = 8000
Fo = 660
T_total = 1.2;
tt = 0:(1/Fs):T_total;
%---
W = 1600; %-- Total Frequency Deviation
Fch = 990;
chch = dchirp(T_total,W, Fs/W).';
y1 = real( chch.*exp(2i*pi*Fch*tt(1:length(chch))) );
%--
figure(1), jkl = 801:1200;
subplot(1,1,1), strips(y1(1:2:length(chch)/4),0.06,Fs/2), xlabel('TIME (sec)')
title([num2str(W),' BW CHIRP CENTERED at ',num2str(Fch),' Hz'])
figure(2), sound(y1,Fs)
Fmax = Fs/2;
Nfft = 128; Nover = 32;
nn = 1:2:fix(length(chch));
[B,F,T] = specgram(y1(nn),Nfft,Fmax,[],Nover);
subplot(1,1,1), imagesc(T,F,db(B,40));
title([num2str(W),' BW CHIRP CENTERED at ',num2str(Fch),' Hz'])
axis xy, colormap(1-gray)
ylabel('FREQUENCY (Hz)'), xlabel('TIME (sec)')
drawnow, sound(y1,Fs)
B1 = B; F1 = F; T1 = T;
keyboard
%---
Fc = 1.3;
y2 = vco( sawtooth(2*pi*Fc*tt,0.5), [300 800], Fs );
%--
figure(3), sound(y2,Fs)
Fmax = Fs/4;
Nfft = 128; Nover = 100;
nn = 1:4:fix(length(y2));
[B,F,T] = specgram(y2(nn),Nfft,Fmax,[],Nover);
subplot(1,1,1), imagesc(T,F,db(B,40));
title(['UP-DOWN MODULATED CHIRP'])
axis xy, colormap(1-gray)
ylabel('FREQUENCY (Hz)'), xlabel('TIME (sec)')
drawnow, sound(y2,Fs)
B2 = B; F2 = F; T2 = T;
keyboard
%---
Fc = 4;
y3 = vco( sin(2*pi*Fc*tt), [400 700], Fs );
%--
figure(4), sound(y3,Fs)
Fmax = Fs/4;
Nfft = 128; Nover = 100;
nn = 1:4:fix(length(y3));
[B,F,T] = specgram(y3(nn),Nfft,Fmax,[],Nover);
subplot(1,1,1), imagesc(T,F,db(B,40));
title(['SINE WAVE MODULATED CHIRP'])
axis xy, colormap(1-gray)
ylabel('FREQUENCY (Hz)'), xlabel('TIME (sec)')
drawnow, sound(y3,Fs)
B3 = B; F3 = F; T3 = T;
keyboard
%---
load chirp %-- creates y and Fs
y4 = y'; clear y;
%--
figure(5), sound(y4,Fs)
Fmax = Fs;
Nfft = 256; Nover = 200;
Ly = round(0.75*Fs);
nn = 1:1:Ly;
[B,F,T] = specgram(y4(nn),Nfft,Fmax,[],Nover);
subplot(1,1,1), imagesc(T,F,db(B,40));
title(['BIRD CHIRP'])
axis xy, colormap(1-gray)
ylabel('FREQUENCY (Hz)'), xlabel('TIME (sec)')
drawnow, sound(y4,Fs)
B4 = B; F4 = F; T4 = T;
keyboard
%---
figure(6)
subplot(2,2,1), imagesc(T1,F1,db(B1,40));
axis xy, grid
title([num2str(W),' BW CHIRP CENTERED at ',num2str(Fch),' Hz'])
ylabel('FREQ (Hz)'), xlabel('TIME (sec)')
subplot(2,2,2), imagesc(T2,F2,db(B2,40));
axis xy, grid
title(['UP-DOWN MODULATED CHIRP'])
ylabel('FREQ (Hz)'), xlabel('TIME (sec)')
subplot(2,2,3), imagesc(T3,F3,db(B3,40));
axis xy, grid
title(['SINE WAVE MODULATED CHIRP'])
ylabel('FREQ (Hz)'), xlabel('TIME (sec)')
subplot(2,2,4), imagesc(T4,F4,db(B4,40));
axis xy, grid
title(['BIRD CHIRP'])
ylabel('FREQ (Hz)'), xlabel('TIME (sec)')
colormap(1-gray)
drawnow