A picture of the Music Player Project

The Music Player

                                    A device that plays tunes of music based on an array of frequencies.

About the Project

This is one of the activities I was tasked to do in the course “Computer Organization (ENCM 369)” at University of Calgary. I used the language C to code the songs. I initialized interrupts and an array with values to produce a sine wave. I then defined notes of the song in a header file “music.h” corresponding to the frequency of the notes. There is only a single sine wave defined and I needed to manipulate the frequency of the sine wave to produce the notes. There are 256 values that define one period of the sine wave, and I am incrementing the sine values by 4 so 256/4 = 64 total steps to complete one period of the sine wave. To manipulate the sine wave to produce the specific note, I needed to call an interrupt function that stops every set number of microseconds. For example, the middle note C has a frequency of 262Hz, so a period of 1/264Hz = 3.78ms. I need 3.78ms / 64 steps = 60microseconds to pass in the interrupt function per value of the sine wave to produce the correct frequency to play the middle note C. The output of these frequencies are connected to the noninverting input of the op-amp, and the speaker plays the frequency, thus producing the music.

Check out these videos below for the project demonstration!

Twinkle Twinkle Little Star

O'Canada