%%%%%%%%%%%%% Make up a Signal %%%%%%%%%%%%%%%%
%           Sinusoid
fs= 22050;
duration= 1;
t= 1/fs*[1:duration*fs].';
x= sin(2*pi*500*t); % 500Hz as long as we play it with the intended fs 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %     Sinusoidal pulses 
fs= 22050;
duration= 0.5;
t= 1/fs*[1:duration*fs].';
x0= zeros(duration*fs,1);
x1= sin(2*pi*1000*t);
x2= sin(2*pi*2000*t);
x3= sin(2*pi*3000*t);
x4= sin(2*pi*6000*t);

x=[x0;x1;x0;x2;x0;x3;x0;x4;x0];
% x=[x0;x4;x0;x3;x0;x2;x0;x1;x0];

figure(1), plot(x), 
figure(2), specgram(x,[],fs), colorbar, title('Spectrogram [dB]')

N= length(x); X=(abs(fft(x))); fscale= fs/N*(1:N/2); 
figure(3), plot(fscale,X(1:N/2))

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%     Chirp
fs= 22050;
duration= 1;
t= 1/fs*[1:duration*fs].';
x= chirp(t,100,duration,6000);
% x= chirp(t,6000,2,500);

figure(1), plot(t,x)
figure(2), specgram(x,256,fs), colorbar, title('Spectrogram [dB]')

N= length(x); X=(abs(fft(x))); fscale= fs/N*(1:N/2); 
figure(3), plot(fscale,X(1:N/2)), xlabel('f [Hz]')

% compromise time/freq resolution: duration= 0.010; nfft= 32; 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Mix of sinusoids

fs= 22050;
duration= 0.2;
t= 1/fs*[1:duration*fs].';
x= sin(2*pi*700*t) + sin(2*pi*3000*t)+ sin(2*pi*5000*t); 

figure(1), plot(t,x)
figure(2), specgram(x,256,fs), colorbar, title('Spectrogram [dB]')

N= length(x); X=(abs(fft(x))); fscale= fs/N*(1:N/2); 
figure(3), plot(fscale,X(1:N/2)), xlabel('f [Hz]')



