ieee sample basic matlab

4
 Math in Music: Christmas Medley using MATLAB  Anton Mark Z. Casia 1 , Russel Miles Diaz Ng 2 , Franzel John Y. Lawas 3 , Jose Leander R. Velasquez 4  Department of Electrical and Electronics Engineering University of San Carlos Talamban, Cebu City, Philippines 1 [email protected], 2 [email protected], 3 [email protected], 4  [email protected] Abstract   MATLAB is a powerful language and interactive environment. It stands for MATrix LABoratory which basically means it is based on vectors and matrices as foundations of its operations. Little did people know especially beginners in this software that is also possible to create music from scratch using this software. This project aims to create music the MATLAB way. This paper focused on explaining how feasible it is to create music through codes by integrating them with established fix values of frequencies that corresponds to a specific note. Keywords   comp onent; f ormatting; s tyle; styling; inse rt (key words) I. I  NTRODUCTION Music has been a part of humanity ever since the beginning of time. Some already view music as a necessity to their day to day life. Many have wondered what the definition of sound is. What is sound? What is music? Sound is defined to be the vibration that travels through a medium, most commonly the air, produced by regular and continuous vibrations that can be heard by humans and animals alike. There are many importance of sound to human life. Sound is the main form of communication for humans and animals alike with the use of various speeches where both parties can both understand and comprehend. Sound also covers a very wide scope of subjects or areas in the field of science and technology. The study of sound is known to be acoustics. Acoustics a branch of physics that deals with the study of sound waves, its properties and the influence it brought in our daily lives. Many technological breakthrough s that have been proved beneficial to mankind are achieved in the field of acoustics. Depth measurement with the use of sound waves is presented by SONAR (Sound Navigation and Ranging) technology. Some important examples are chromatography, sterilization by the use of ultrasound, and enhancing cell growth by the process of sonication. Sound waves are discovered to be of varying frequency. Frequency is defined to be the number of occurrences of a repeating event per unit time. It is also said to be the reciprocal of the unit period which is the duration of time in one cycle or also known as the interval between beats. In short, frequency is the amount of repeating vibrations in an object. Since the voice of an individual person varies in frequency, it is classified into how high the pitch or a high frequency note. II. R EADING MUSIC SCORE SHEETS Transcribing a music score sheet is a difficult task even for an experienced musician. One must expend his whole creativity into pouring his passion into his work. A music score is a written or printed form of musical composition where different symbols of importance are placed in different parts of the staff. Different symbols in a music sheet represent certain  beats, timing, rhythm and many others. Important parts found in the music sheet are explained in the section below.  A. Staff The staff comprises of five lines and four spaces. Each of those lines and each of those spaces speak to an alternate letter, which speaks to a note. Those lines and spaces speak to notes named A-G, and the note succession moves one after another in order up the staff.  B.  Notes  Notes indicate what part of the staff that will be played and the duration for it to be played. C.  Key Signature Key marks are demonstrated by two images, the # sign and the lower case b. The # sign stands for sharp notes and the lower case b remains for level notes. The arrangement and the amount of images advise the entertainer which musical key to  perform.  D. Tempo Marks Tempo marks Tempo marks are truncations of Italian words that demonstrate how quick or moderate to play the music and what feeling to incorporate. For instance, mp implies mezzo-piano. This means tolerably delicate. Fig F1. A Sample Music Score Sheet

Upload: leander-r-velasquez

Post on 27-Feb-2018

230 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: IEEE Sample Basic MATLAB

7/25/2019 IEEE Sample Basic MATLAB

http://slidepdf.com/reader/full/ieee-sample-basic-matlab 1/4

 Math in Music: Christmas Medley using MATLAB 

Anton Mark Z. Casia1, Russel Miles Diaz Ng

2, Franzel John Y. Lawas

3, Jose Leander R. Velasquez

Department of Electrical and Electronics EngineeringUniversity of San Carlos

Talamban, Cebu City, [email protected]

[email protected]

[email protected]

[email protected]

Abstract  — MATLAB is a powerful language and interactive

environment. It stands for MATrix LABoratory which basically

means it is based on vectors and matrices as foundations of its

operations. Little did people know especially beginners in this

software that is also possible to create music from scratch using

this software. This project aims to create music the MATLAB

way. This paper focused on explaining how feasible it is to createmusic through codes by integrating them with established fix

values of frequencies that corresponds to a specific note.

Keywords  — component; f ormatting; style; styling; insert (key

words)

I.  I NTRODUCTION

Music has been a part of humanity ever since the beginningof time. Some already view music as a necessity to their day today life. Many have wondered what the definition of sound is.What is sound? What is music? Sound is defined to be thevibration that travels through a medium, most commonly theair, produced by regular and continuous vibrations that can be

heard by humans and animals alike. There are manyimportance of sound to human life. Sound is the main form ofcommunication for humans and animals alike with the use ofvarious speeches where both parties can both understand andcomprehend.

Sound also covers a very wide scope of subjects or areas inthe field of science and technology. The study of sound isknown to be acoustics. Acoustics a branch of physics that dealswith the study of sound waves, its properties and the influenceit brought in our daily lives. Many technological breakthroughsthat have been proved beneficial to mankind are achieved inthe field of acoustics. Depth measurement with the use ofsound waves is presented by SONAR (Sound Navigation and

Ranging) technology. Some important examples arechromatography, sterilization by the use of ultrasound, andenhancing cell growth by the process of sonication.

Sound waves are discovered to be of varying frequency.Frequency is defined to be the number of occurrences of arepeating event per unit time. It is also said to be the reciprocalof the unit period which is the duration of time in one cycle oralso known as the interval between beats. In short, frequency isthe amount of repeating vibrations in an object. Since the voiceof an individual person varies in frequency, it is classified intohow high the pitch or a high frequency note.

II.  R EADING MUSIC SCORE SHEETS 

Transcribing a music score sheet is a difficult task even foran experienced musician. One must expend his wholecreativity into pouring his passion into his work. A music scoreis a written or printed form of musical composition wheredifferent symbols of importance are placed in different parts of

the staff. Different symbols in a music sheet represent certain beats, timing, rhythm and many others. Important parts foundin the music sheet are explained in the section below.

 A.  Staff

The staff comprises of five lines and four spaces. Each ofthose lines and each of those spaces speak to an alternate letter,which speaks to a note. Those lines and spaces speak to notesnamed A-G, and the note succession moves one after anotherin order up the staff.

 B.  Notes

 Notes indicate what part of the staff that will be played andthe duration for it to be played.

C.  Key Signature

Key marks are demonstrated by two images, the # sign andthe lower case b. The # sign stands for sharp notes and thelower case b remains for level notes. The arrangement and theamount of images advise the entertainer which musical key to

 perform.

 D.  Tempo Marks

Tempo marks Tempo marks are truncations of Italianwords that demonstrate how quick or moderate to play themusic and what feeling to incorporate. For instance, mpimplies mezzo-piano. This means tolerably delicate.

Fig F1. A Sample Music Score Sheet

Page 2: IEEE Sample Basic MATLAB

7/25/2019 IEEE Sample Basic MATLAB

http://slidepdf.com/reader/full/ieee-sample-basic-matlab 2/4

III.  IMPLEMENTATION IN MATLAB 

MATLAB, with its broad and high-level programmingapplication, has the ability to produce sounds given the correctfrequency and duration. Because sound and frequency areextremely correlated in deep roots, the score sheet that waschosen and modified has to be converted from music notes andrests to frequency and duration. To be able to easily convert themusic notes without calculations, we used this Note Frequency

Table in table T1 .

Reminding again that rests represent 0 Hertz. After tallyingthe frequencies, the duration was also taken into consideration.Also, to be able to easily convert the music notes withoutcalculations, we used this Note Duration Table in table T2 .

A chord is not that complicated too, in a sense that when achord is played three notes are played altogether. But we onlytook the dominant note among the three notes. This dominantnote will be played oftentimes compared to the normal notethat changes after every beat.

Quarter

 Note

Half Note Whole Note

Duration (s) 0.25 0.5 1

Table T2. Note Duration Table

 A.  Playing the Notes

To be able to play the music as it should sound, weapproached it in a different method. A matrix was created withthe first row of values as frequency, and the second row ofvalues as the corresponding duration. This matrix was createdusing the built-in application notepad. This matrix also containsthe frequency and the duration of the notes.

The notepad file containing the matrix is then loaded untothe MATLAB application with constant values like tempo andfrequency included. After loading the note sounds, it is thenconverted into a .wav file format.

Fig F2. Code on Loading Note Text File to MATLAB

Same with the notes, a notepad file containing the matrix isalso loaded unto the MATLAB application with constantvalues like tempo and frequency included. This matrix containsthe notes imbued with the knowledge of chords. After loadingthe individual chord sounds, it is then converted into a .wavformat.

Fig F3. Code on Loading Chord Text File to MATLAB

Table T1. Note Frequency Table

Page 3: IEEE Sample Basic MATLAB

7/25/2019 IEEE Sample Basic MATLAB

http://slidepdf.com/reader/full/ieee-sample-basic-matlab 3/4

Time

           F        r        e        q        u        e        n        c        y

1 2 3 4 5 6 7 8 9 10200

250

300

350

400

450

500

550

600

 

the last and the tricky part: combining the two .wav files.This process needed the concept of modulation to avoid sounddistortion. Down below shows how the two waves arecombined and how the modulated and combined sounds wasachieved, and played.

 B.  Spectrogram

The sounds and music we hear are just waves and signalsoscillating and vibrating at different frequencies. Being onlyidentified by our sense of hearing, it can also be visuallyrepresented as a spectrum of varying frequencies over a periodof time. This representation is called a Spectrogram. A samplespectrogram is shown in Figure F5   where the frequencies ofnotes C4 to C5 are displayed over a period of 10 seconds. Thecolours of the vertical axis represent the frequency and themost prominent acoustic spike at a given time [R1 ].

Spectrogram is implemented in Matlab in the form of the“specgram” function. This function works by doing a Short-Time Fourier Transform on a given signal and the frequencymagnitude is shown in the vertical axis. It is called by runningthe command: specgram(y,overlapSamp,Fs); where y is thesignal vector, overlapSamp is the number of samples that eachsegment overlaps, and Fs is the sampling frequency. A samplespectrogram of our song is shown in Figure F6  where it is alsooverlaid with the notes that it represents.

Fig. F5. Spectrogram of notes C4 –  C5

IV.  VOICE TYPE ALLOCATION IN MATLAB 

Creating the combined .wav file is not the end of it all.There was also a need to vary the frequency in the notepad textfiles because of the different voice types that the music should

 be in sync with.

Each voice type has different voice ranges meaningdifferent frequency ranges. But in this project, four voice typeswill only be used and that is the soprano and alto for women,and tenor and bass for men.

Soprano Alto Tenor Bass Note Range C4 –  C6 F3 –  F5 C3 –  C5 E2 –  E4

Frequency

Range

261.6 -

1047

174.6 -

698.5

130.8 -

523.3

82.41 -

329.6

Table T3. Note and Frequency Range Table for Different Voice Types

With this table, if the initial notes used in the music sheetdo not qualify within the range, the unqualified notes should bechanged in a way that the note will transcend to a higher octaveor the note will descend in a lower octave. But the initial musicsheet that we had was already qualified for voice type’s altoand tenor. So to solve the problem concerning the bass note fileand chord file. The unqualified notes were decreased by adecrement of one octave. With this process, all the notes arenow qualified within the bass range. Lastly, concerning thesoprano, all the unqualified notes were increased with anincrement of one octave. Then four .wav files were created: thesoprano .wav file, the alto .wav file, the tenor .wav file, and thealto .wav file.

Fig. F6. Sample Spectrogram of song

Fig F4. Code on Playing Combined .wav Files in MATLAB

Page 4: IEEE Sample Basic MATLAB

7/25/2019 IEEE Sample Basic MATLAB

http://slidepdf.com/reader/full/ieee-sample-basic-matlab 4/4

V.  R ECORDING AND PLAYING VOICES IN MATLAB 

With the polyphonic notes as the accompaniment for theChristmas carol, the voice that it accompanies is alsorecorded in Matlab. This is possible with the “audiorecorder”command which creates an audio recorder object bringingalong with it the audiorecorder Methods. These methods

include the basic audio recording functions namely therecord, pause, resume, stop and play.

The part of the script used for the recording of our carolis shown in Figure F7 . The first line creates theaudiorecorder o bject having the variable name “voice”, asampling rate of 16000 Hz, 16 bits per sample, and havingonly a single channel. Line 2 is then executed where therecording is started in the voice object. At this time, wespeak through the microphone and after singing; therecording is stopped by executing line 3. The audio data isthen taken from the voice object and saved to the audiovariable in line 4. This is then written was a “.wav” file at line 5 having a sampling frequency of 16000 Hz and with a

“voice” filename. The recorded audio is then played and can be heard by executing line 6.

Fig. F7. Script used for recording audio

Fig. F7. Script used for Recording Audio

CONCLUSION 

To wrap this all up, MATLAB can really be used as agreat accompaniment in music but way harder to manipulatethan the usual musical instruments. Accomplishing this

 project will not only require programming skills, but alsosinging skills and skills concerning the technicalities ofmusic. We were able to successfully read notes from ourchosen music score sheet and convert the notes to theircorresponding frequencies. All these data are placed on aMatlab data file and we created the code to read and combine

it to create the music accompaniment. Our voices were alsorecorded using Matlab and was combined with theaccompaniment to finish up our medley. A music video wasthen made in relation to the song therefore completing theChristmas carol to the tunes of Jingle Bells and Feliz

 Navidad respectively. The entire project was veryeducational yet challenging. It has put the students’

 potentials to the test and had their brains and knowledgetested on a whole new different academic and technical level.Therefore, it is safe to conclude that this project has broughtthe students substantial amount of experience and knowledge

when dealing with MatLab and its core functions andfeatures.

ACKNOWLEDGMENT 

The authors would like to thank God for the wisdom,knowledge He has given us and for the opportunity to learn

more. We would like to thank our colleague’s family forletting us stay for a night or two as we accomplish this project. We would like to thank this learning institution for providing us the opportunity to showcase our skills andtalents in this field. Lastly, we would like to thank our

 parents for supporting us in this project.

R EFERENCES 

[1]http://www.cslu.ogi.edu/tutordemos/SpectrogramReading/spectrogram.html

[2]http://www.thestudysite.com/importance-of -sound 

[3] http://donrathjr.com/frequency-table/

/