Thanks for the post but I should add that I'm really new to Matlab and don't really know what I'm doing. Here's my note that I've synthesised:
close all; clear all;
rate=20000;
duration=4;
length=duration*rate;
t=linspace(0,duration,length);
A1=exp(-0.1*t)*1; A2=exp(-0.7*t)*0.907; A3=exp(-0.5*t)*0.366; A4=exp(-0.9*t)*0.159; A5=exp(-1.2*t)*0.194; A6=exp(-1.4*t)*0.169; A7=exp(-1.7*t)*0.176; A8=exp(-2*t)*0.101;
f1=261.2; f2=523.4; f3=785.0; f4=1047.7; f5=1312.45; f6=1577.1; f7=1843.85; f8=2111;
y=A1.*sin(2*pi*f1*t)+A2.*sin(2*pi*f2*t)+A3.*sin(2*pi*f3*t)+A4.*sin(2*pi*f4*t)+A5.*sin(2*pi*f5*t)+A6.*sin(2*pi*f6*t)+A7.*sin(2*pi*f7*t)+A8.*sin(2*pi*f8*t);
y=y/8;
sound(y,rate);
Now, I've found this ADSR envelope, but I don't understand how to apply it to my note.
function y = adsr(a, d, s, r, fs)
% ADSR An ADSR envelope generator.
% Y = ADSR(A,D,S,R,FS) generates a vector filled with envelope
% values as computed for the specified attack (A), decay (D),
% sustain (S), and release (R) times in seconds at the sample rate
% FS. The envelope attack reaches a value of 1 and then decays to a
% sustained value of 0.5, before decaying to 0.0
% Do attack portion
N = a * fs;
y = [0:N-1] / (N-1);
% Do decay portion
N = d * fs;
y = [y ([N-1:-1:0] / (2*N)) + 0.5];
% Do sustain portion
N = s * fs;
y = [y 0.5 * ones(1, N)];
% Do release portion
N = r * fs;
y = [y, 0.5 * [N-1:-1:0] / N];
Can anyone help me out?