Professional Documents
Culture Documents
Student ID
S271457
Assessment Title
Lecturer/Tutor
FRISO DE BOER
Date Submitted
27/03/15
Date Received
Office use only
KEEP A COPY
Please be sure to make a copy of your work. If you have submitted assessment work electronically make sure
you have a backup copy.
PLAGIARISM
Plagiarism is the presentation of the work of another without acknowledgement. Students may use a limited
amount of information and ideas expressed by others but this use must be identified by appropriate referencing.
CONSEQUENCES OF PLAGIARISM
Plagiarism is misconduct as defined under the Student Conduct By-Laws. The penalties associated with
plagiarism are designed to impose sanctions on offenders that reflect the seriousness of the Universitys
commitment to academic integrity.
I declare that all material in this assessment is my own work except where there is a clear
acknowledgement and reference to the work of others. I have read the Universitys
Academic and Scientific Misconduct Policy and understand its implications.*
http://www.cdu.edu.au/governance/policies/pol-001.pdf
SignedNIKUNJ PATEL..Date27/03/15..
* By submitting this assignment and cover sheet electronically, in whatever form you are deemed to have made the declaration set out
above.
Higher Education
This lab report includes synthesis of music using sinusoids and creates a link
between different musical note and their frequencies. We will be generating music
by programming in mat lab. We will assign specific frequencies to every note. By
converting digital signals to analog electrical waveforms, we can hear them
through speakers.
This lab report focuses on the piano notes and piano notes need a particular
frequency. If we know the frequency of one key, we can calculate another new
frequency by:
f(new) = f(old)*2^((change in keyno.)/12)
Part 2.2:
a) The output result is one musical note of piano instrument.
fs=8000;
t=[0:1/fs:2];
xo=2*pi*1100;
yo=0;
A=100;
x1=A*cos(xo*t+yo);
sound(x1,fs)
b) We also know that the higher frequency results into higher pitch sound. Let us put
both signals together in a new vector such that:
xx = [x1 zeros(1,2000) x2];
When we heard the resultant sound xx, there is a gap between the first and
second signal. This space in time is related to the sampling frequency.
A=100;
fs=8000;
t=[0:1/fs:2];
yo=0;
xo=2*pi*1100;
x1=A*cos(xo*t+yo);
%sound(x1,fs)
w1=2*pi*1650;
phi1=pi/3;
x2=A*cos(w1*t+phi1);
%sound(x2,fs)
xx=[x1 zeros(1,2000) x2];
sound(xx,fs)
c) When we double the sampling rate up to (i.e. 16000 samples/seconds), the pitch
as well as the duration of the signal is changed suddenly. Thus, from the result,
doubling the sampling rate decreses the time duration of the signal and increased
its pitch.
A=100;
fs=8000;
t=[0:1/fs:2];
yo=0;
xo=2*pi*1100;
x1=A*cos(xo*t+yo);
%sound(x1, fs)
w1=2*pi*1650;
phi1=pi/3;
x2=A*cos(w1*t+phi1);
%sound(x2, fs)
xx=[x1 zeros(1,2000) x2];
sound(xx,16000)
Part 2.3:
a) fs=8000;
keynum = 56;
t=[0:1/fs:2];
f=440*2^((keynum-49)/12);
w0=2*pi*f;
phi=0;
x=cos(w0*t+phi);
sound(x,8000)
b) function tone = note(keynum,dur)
%
%
%
%
%
%
%
%
51 0 44 48 51 52 0 44 56 55 ...
52 51 49 0 51 52 54 56 47 57 56 ...
56 68 0 0 55 56 0 0 55 56 55 ...
48 51 52 0 44 56 55 56 55 56 51 54 52
b=[0 0 25 32 37 0 0 20 32 36 0 0 25 32 39 0 0 ...
0 25 32 37 0 0 20 32 36 0 0 25 32 37 0 28 35 40 0 0 ...
23 35 39 0 0 25 32 37 0 0 20 32 44 0 44 56 0 0 55 56 0 0 55 56 0 0 ...
0 25 32 37 0 0 20 32 36 0 0 25 32 37 0 0 0 ...
25 32 37 0 0 20 32 36 0 0 25 32 37 0];
bdur=[1 3 .5 .5 .5 .5 1 .5 .5 .5 .5 1 .5 .5 .5 .5 1 ...
3 .5 .5 .5 .5 1 .5 .5 .5 .5 1 .5 .5 .5 1.5 .5 .5 .5 .5 1 ...
.5 .5 .5 .5 1 .5 .5 .5 .5 1 .5 .5 .5 1 .5 .5 .5 .5 .5 .5 .5 .5 .5 .5 .5 1 ...
3 .5 .5 .5 .5 1 .5 .5 .5 .5 1 .5 .5 .5 .5 1 3 ...
.5 .5 .5 .5 1 .5 .5 .5 .5 1 .5 .5 .5 .5];
fs = 11025;
yy = zeros(1,sum(bdur)*fs+1);
n1 = 1;
for kk= 1:length(b)
keynum = b(kk);
tone = note (keynum,bdur(kk));
n2 = n1+length(tone)-1;
yy(n1:n2) = yy(n1:n2) + tone;
n1 = n2;
end
sound(yy,fs)
tdur = tdur*0.5;
bdur = bdur*0.5;
%keys = [40 42 44 45 47 49 51 52];
%
C D E F G A B C
% key #40 is middle-c
%dur = 0.25 * ones(1,length(keys));
fs = 11025; %-- use 11025 Hz on PC/Mac, 8000 on UNIX
xx = zeros(1,sum(tdur)*fs+1);
n1 = 1;
for kk = 1:length(t)
keynum = t(kk);
tone = note(keynum,tdur(kk)); %<=== FILL IN THIS LINE
n2 = n1 + length(tone) - 1;
xx(n1:n2) = xx(n1:n2) + tone;
n1 = n2;
end
%sound(xx,fs)
yy = xx;
fs = 11025;
xx = zeros(1,sum(tdur)*fs+1);
n1 = 1;
for kk= 1:length(b)
keynum = b(kk);
tone = note (keynum,bdur(kk));
n2 = n1+length(tone)-1;
xx(n1:n2) = xx(n1:n2) + tone;
n1 = n2;
end
xx =xx+yy;
sound(xx,fs);
Conclusion:
From the above observation, it can be concluded that it is quite easy to synthesis
music using matlab. Synthesising music using sinusoids will generate music of
better quality.