You are on page 1of 4

Casilao, Princess Lheakyrie R.

ECE-2102

Activity No. 4
(Lupang Hinirang)

Introduction

Theoretically, a normal vibration, such as amplitude and frequency, has two key properties
that influence a sound. Amplitude is the size of the noise, thus defining the loudness of the sound.
On the other hand, the frequency is the vibration rate that determines the sound's pitch. It is only
useful where there is a good standard waveform for musical sounds. Throughout high school, it was
discovered that a frequency of 1 Hz indicates one wave cycle per second in which a higher
frequency and cycles are much shorter and closer together. A sound's loudness refers to the wave's
amplitude. On the other hand, Lupang Hinirang is a national anthem composed by Julian Felipe and
a musical composition. Thus, the principles mentioned used to create through codes a sound of the
Philippine National Anthem, "Lupang Hinirang," in MATLAB.

MATLAB codes
% Casilao, Princess Lheakyrie
% ECE 2102
% MATLAB Activity 4
% Lupsng Hinirang
Fs = 44100;%Sampling rate
Ts = 1/Fs;%Sampling time interval
T = 0.3:Ts:(Fs*Ts); %time
T_1 = 0.6:Ts:(Fs*Ts); %time1
T_2 = 0.8:Ts:(Fs*Ts); %time2
t = 830.6094;%Frequency of sine wave
Do = 880;
Re = 493.8833;
Re_1 = 987.7;
Mi = 554.3653;
M_1 = 1109;
F_1 = 622.2540;
F_2 = 1175;
S = 659.2551;
L = 739.9888;
Rest= 0;
Half_Rest = 0.5;
Rest_1= sin(2*pi*Rest*T);
Rest_2= sin(2*pi*Rest*T_1);
Rest_3= sin(2*pi*Rest*T_2);
Sol = sin(2*pi*S*T);
Sol_A= sin(2*pi*S*T_1);
Sol_B= sin(2*pi*S*T_2);
Fa = sin(2*pi*F_1*T);
Fa_A=sin(2*pi*F_1*T_1);
Fa_B=sin(2*pi*F_1*T_2);
Fa_C=sin(2*pi*F_2*T);
Fa_D=sin(2*pi*F_2*T_1);
Fa_E=sin(2*pi*F_2*T_2);
La=sin(2*pi*L*T);
La_A=sin(2*pi*L*T_1);
La_B=sin(2*pi*L*T_2);
Re_A=sin(2*pi*Re*T_1);
Re_B=sin(2*pi*Re*T_2);
Re_C=sin(2*pi*Re_1*T);
Re_D=sin(2*pi*Re_1*T_1);
Re_E=sin(2*pi*Re_1*T_2);
Re_F=sin(2*pi*Re*T);
Ti=sin(2*pi*t*T);
Ti_A=sin(2*pi*t*T_1);
Ti_B=sin(2*pi*t*T_2);
Do_A=1760;
Do_B=sin(2*pi*Do*T);
Do_C=sin(2*pi*Do*T_1);
Do_D=sin(2*pi*Do*T_2);
Do_E=sin(2*pi*Do_A*T);
Do_F=sin(2*pi*Do_A*T_1);
Do_G=sin(2*pi*Do_A*T_2);
Mi_A=sin(2*pi*Mi*T);
Mi_B=sin(2*pi*Mi*T_1);
Mi_C=sin(2*pi*Mi*T_2);
Mi_D=sin(2*pi*M_1*T);
Mi_E=sin(2*pi*M_1*T_1);
Mi_F=sin(2*pi*M_1*T_2);

Line1 = [Sol Fa_A La_B Sol Re_F La_B Ti_B Do_D Ti_A La_B Ti Sol];
% Bayang Magiliw, Perlas ng Silanganan
% Lupang Hinirang, Duyan ka ng magiting
Line2 = [Sol Fa_A La_B Sol Re_F La_B Ti_B Do_D Ti_A La_B Sol];
% Alab ng puso, Sa dibdib mo'y buhay
% Sa manlulupig, Di ka pasisiil
Line3 = [Sol_B Fa_B Sol_B La_A La_B Re_A Re_B La_A La_B Re_A Re_B Ti_A
Do_D Re_D Mi_F Re_E];
% Sa dagat at bunodk sa simoy at sa langit mong bughaw
% Ang kislap ng watawat mo'y tagumpay na magniningning
Line4 = [Sol_B Fa_B Sol_B La_A La_B Re_A Re_B La_A La_B Re_A Re_B Ti_B
Do_D Ti_B La_B Ti_B La_B Sol_B];
% May dilag ang tula at awit sa paglayang minamahal
% Ang bituin at araw na kailan pa ma'y di magdidilim

Line5 = [Sol_B Fa_B Sol_B Do_B Do_B Re_C Re_C Mi_E Re_E Do_C Re_E Mi_E
Rest_2 Fa_E Mi_F Re_E Mi_D Do_B Re_C Do_C Ti_B Do_C ];
% Lupa ng araw ng l'walhati't pagsinta, Buhay ay langit sa piling mo

Line6 = [Sol_B Fa_B Sol_B Do_B Do_B Re_C Re_C Mi_E Re_E Do_C Re_E Mi_E
Rest_2 Fa_E Mi_F Re_E Mi_D Do_B Re_C Do_C Ti_B Do_C Do_C Do_C Do_C ];
%Aming ligaya na 'pag may mang-aapi, Ang mamatay ng dahil sa'yo

LupangHinirang = [Half_Rest Line1 Line2 Rest_1 Line1 Line2 Line3


Rest_2 Line4 Rest_2 Line3 Rest_2 Line4 Rest_2 Line5 Rest_1 Line6
Half_Rest];
soundsc (LupangHinirang, Fs)
The above codes in MATLAB were used to produce a sound of the Lupang Hinirang. The
first four lines in color green and started with percentage sign (%) are simply the title.

The next rows of codes are the variables used and initialized the corresponding values. Fs is
the 44100 sampling frequency. This also means 44.1 kHz that is used on compact disks for popular
audio processing. Ts is the time interval of sampling with the value of 1/Fs. This is also a common
time interval used in sine wave audio processing. The time, time 1 and time 2 variables T, T 1, and
T 2 are set respectively. Both times have been set to be used in the order of the notes. The t
parameter has also been set to 830.6094 as it is the test time vector considered in this operation.

In addition, the frequency codes for each note were set. It is known that the tonal scale notes
are the do, re, mi, fa, sol, la, and ti. This can be shown in numbers or frequency. The note frequency
map has been used as the guidelines in this practice.

The codes rendered a smooth tune of the Lupang Hinirang successfully. In addition, in this
activity it has been learned that "mathematics can be used in music." A sound was created by the
frequency and equation codes. The development and practice of using MATLAB is further pursued
by codes to produce more sounds.

References

National Historical Commission of the Philippines. (n.d.). Retrieved from


http://nhcp.gov.ph/resource/national-anthem/

Tontechnik-Rechner-sengpielaudio. (n.d.). Retrieved December 2019,


from http://www.sengpielaudio.com/calculator-notenames.htm

You might also like