Saturday, 2 May 2015

DSP PROJECT-FREQUENCY RECOGNITION OF PIANO




FREQUENCY
ANALYZER


 
ABSTRACT
Students are often more interested in learning technical material if they can see useful applications for it, and in digital signal processing (DSP) it is possible to develop homework assignments, projects, or lab exercises to show how the techniques can be used in realistic situations. The study of Fourier series from a musical perspective offers great in-sight into basic mathematical concepts and the physics of musical instruments. Tools available in Matlab allow students to easily analyze the wave forms and harmonics of recorded sounds. The FFT (Fast Fourier Transform) and filter design are two fundamental techniques in DSP. In most signal analysis methods, the most important task is the detection of frequencies present in the audio signal. The common approach undertaken to achieve this is by analysing the signal in the frequency domain. By performing a Fourier transformation on an audio signal, the frequency spectrum of that signal can be retrieved. The FFT of the recording of a musical instrument can be used to determine which note is being played and whether the instrument is in tune, sharp, or flat.This tuner is one of the basic application of FFT in the musical field.

                    

In this project ,we discuss the recognition of different notes of a musical instrument namely a keyboard.

                                                                 INTRODUCTION

The computer can capture live sound/music using a microphone that is connected to the sound card. Modern sound cards can capture digital signals. A digital signal is a set of quantized sound values that were taken in uniformly spaced times. The digital signal does not provide any information about frequencies that are present in the sound. To determine that, the data need to be analyzed.

We will use a Fast Fourier Transform (FFT) to generate the spectrogram of the signal of short periods of time. After the spectrogram is calculated, the fundamental frequency can be determined by finding the index of the maximum value of the magnitude squared. The improved algorithm finds several such places, candidate frequency bins, with the magnitude squared in the top of the maximum values, and further analyzes them to verify the candidate fundamental frequencies by using the signal data.
When a note is played on a musical instrument, the sound waves are generated by strings, air, or the speaker - an instrument generates a musical note. One of the characteristics of a musical note is a pitch (fundamental frequency). Traditionally musical alphabet frequencies are divided by octaves, and then by semitones. An octave has 12 named pitches: C (prime), C#, D, D#, E, F, F#, G, G#, A, A#, and B. Octaves also have names: great, small, one-lined, two-lined, etc. The "standard pitch" (A one-lined or A4) has a fundamental frequency of its sound waves equals to 440 Hz. The frequencies of two neighboring notes are different by 21/12, and frequencies of the notes with the same name in two neighboring octaves are different by 2.

The FFT of the recording of a musical instrument can be used to determine which note is being played and whether the instrument is in tune, sharp, or flat.

The note that an instrument played can be found by determining the fundamental frequency of the signal and comparing it to a table that lists the frequency associated with each note (see Table ). The FFT can also be used to compare the harmonic structure of different instruments. As we all know ,harmonics are the multiples of fundamental frequency.





The table below shows the frequencies associated with each keys of a keyboard ,which we will be using later on in this project.




Figure(2) below shows the expected result of the graphs.


In this project ,we first find FFT of different musical notes recorded and then compare this FFT with already existing table of frequencies ,finally giving us the information on the corresponding music note .This is basics of instrumental tuner and musical analyzer.





                                                                       ANALYSIS


The function analyze.m  uses the built-in Matlab functions wavread and fft to calculate the power spectrum of a Microsoft wave (.wav) sound file. The plots produced by analyze.m can be used to identify the pitch and volume of a sound sample. Figure 2 shows the results of low A, middle A, and high A played on a piano. The waveforms on the left are the pressure variations with time detected by the microphone. The amplitude of the wave is a measure of its pressure oscillations and corresponds to the volume of the sound. Volume is usually measured in decibels, the logarithm of pressure. One does not usually think of sound in terms of pressure, but feeling the pressure waves of sound at a concert or near loud equipment is a common experience.

The fundamental frequency f1 Doubles with each octave, and the harmonics are spaced in proportion to f1 as expected. The spectrum is nonzero between harmonics because the waves are not perfectly periodic.

Notice that the difference in frequency between any two consecutive harmonics is

the fundamental frequency. The human mind unconsciously uses this fact to identify a pitch even if the fundamental and lower harmonics are missing.

 Thus the frequencies of octaves form a geometric sequence. For example, the frequencies of As are 55,110,220,440,880,…


CODE


function analyze(file)
[y, Fs] = wavread(file);      % y is sound data, Fs is sample frequency.
t = (1:length(y))/Fs;         % time

ind = find(t>0.1 & t<0.12);   % set time duration for waveform plot
figure; subplot(1,2,1)
plot(t(ind),y(ind)) 
axis tight        
title(['Waveform of ' file])
N = 2^12;                     % number of points to analyze
c = fft(y(1:N))/N;            % compute fft of sound data
p = 2*abs( c(2:N/2));         % compute power at each frequency
f = (1:N/2-1)*Fs/N;           % frequency corresponding to p
soundsc(y,Fs)
subplot(1,2,2)
semilogy(f,p)
axis([0 1000 10^-4 1])               
title(['Power Spectrum of ' file])
analyze('piano_A0')
analyze('piano_A1')
analyze('piano_A2')




From the depiction above we can see that the value from the graph obtained is comparable with the frequencies from the table.



                                            INFERENCE;




The desired output was obtained. The result that was obtained was comparable with the expected one .



REFERENCE



1.     ENHANCE YOUR DSP COURSE WITH THESE INTERESTING PROJECTS
    Dr. Joseph P. Hoffbeck, University of Portland

Saturday, 25 April 2015

A LESSON IN CLEANLINESS




                                                  SOFTSKILLS PROJECT

By;

Aparna.P.T.A- S4ECE13106

Arsha.V.V --S4ECE13109


16/4/2015:Saturday:

Amritapuri ashram ,Kollam

Our project was based on Seva . We helped Anna , a foreigner who was cleaning the waste disposal area near Amritapuri ashram canteen . We have never thought who will clean this waste disposal area in the ashram ,but seeing her doing the job alone ,we decided to help her . Thus we helped her to clean and wash there . She provided us with aprons and gloves . Doing this project was a memorable experience . Doing a Seva is indeed considered as a godly activity .
As we used to do Seva in the ashram often in our first year , this was not a difficult job to do . And Anna was so friendly that we both were comfortable with her . Being a sunny day , this work made us so tired . But considering the work we have done , moreover a duty , we felt happy and satisfied with our work .Anna was also satisfied and she thanked us for this help . She asked us to inform our friends about the pending work in recycling section in ashram.
We are really grateful for giving us a project  and we sincerely think that we have done something good . This made us feel that even we are a contributor in this society .