410287045 黃浩睿

# MUSIC

This is the frequency of every notes

# CODE

A=[130 146 164 174 196 112 120 103];

A=[260 293 328 348 392 224 240 206]

fs=8000;

pu=[3 3 4 4 3 2 3 3 3 4 4 3 2 3 3 3 4 5 1 7 1 2 1 2 3 4 3 2 1 6 6 5 5 4 3 4 8 8 5 4 3 2 3 6 6 2 2 3 3 4 8 2 3 4 3 2 1 3 3 4 4 3 2 3 3 3 4 4 3 2 3 3 3 4 5 1 7 1 2 1 2 3 4 3 2 1 6 6 5 5 4 3 4 8 8 5 4 3 2 3 6 6 2 2 3 3 4 8 2 3 4 3 2 1]; %the music

p=0.9;

last_time=[p/2 p/2 p/2 p/2 p/2 p/2 p p/2 p/2 p/2 p/2 p/2 p/2 p p/2 p/2 p/2 p/2 p/2 p/2 p/2 p/2 p/2 p/2 p/2 p/2 p/2 p/2 p p/2 p/2 p/2 p/2 p/2 p/2 p p/2 p/2 p/2 p/2 p/2 p/2 p p/2 p/2 p/2 p/2 p/2 p/2 p p/2 p/2 p/2 p/2 p/2 p/2 p p/2 p/2 p/2 p/2 p/2 p/2 p p/2 p/2 p/2 p/2 p/2 p/2 p p/2 p/2 p/2 p/2 p/2 p/2 p/2 p/2 p/2 p/2 p/2 p/2 p/2 p/2 p p/2 p/2 p/2 p/2 p/2 p/2 p p/2 p/2 p/2 p/2 p/2 p/2 p p/2 p/2 p/2 p/2 p/2 p/2 p p/2 p/2 p/2 p/2 p/2 1.5*p 1.5*p];

N=length(pu);% the quantity of music

f=zeros(1,N);

for i=1:N

f(i)=A(pu(i));

end

point=fs*last_time;

total_point=sum(point);

store=zeros(1,total_point);

m=1;

for num=1:N

t=1/fs:1/fs:point(num)/fs;

store(m:m+point(num)-1)=sin(2*pi*f(num)*t);

m=m+point(num);

end

sound(store,8000);

plot(store);