%Initiering
Ts = 1/11025;    % Samplingstid
fn = 1/(2*Ts);   % Nyquist-frekvensen
t=-.5:Ts:2.5;    % Tidsvektor
freq = linspace(-fn,fn,length(t)); % Frekvensvektor

% Skapa toner
a1=sin(440*t*2*pi);            
ciss2=sin(550*t*2*pi);  
e2=sin(660*t*2*pi);
a2=sin(880*t*2*pi);

% Skapa ackord
A=.15*a1+.15*ciss2+.15*e2+.15*a2;

% Skapa envelop
env=(40*t.*exp(-20*t)+.5*exp(-(t-.2).^2)).*(t>=0);
AA=A.*env;

% Spela upp
sound(A,1/Ts)
sound(AA,1/Ts)

% Fouriertransformera
FA=fftshift(fft(A));
FAA=fftshift(fft(AA));
hold off
plot(freq,abs(FA))
hold on
plot(freq,abs(FAA),'r')
hold off
