Analisis Del Espectro de Audio en Matlab

Embed Size (px)

Citation preview

  • 7/31/2019 Analisis Del Espectro de Audio en Matlab

    1/5

    1

    Analysis Frequency Spectra an Audio Signal

    Subject: Signals and Systems

    Students:Gerardo Hernandez code. 809027

    Luis Mendoza code.209045

    Orlando Delgado code.809018

    Teacher: Oscar Marino

    Universidad Nacional de Colombia, Manizales

    Abstract With the help computational tool,

    Matlab, we want apply some of the concepts dis-

    cussed in the signals and systems course.

    Well make a software at Matlab that permit usobtain a audio signal in a given format and process

    it at different ways for comparing their spectra. The

    audio signal can be taken from a sound file existing

    in the computer or upload trough direct recording

    using P.C microphone. Well implement the object-

    oriented programming in the GUIDE for achieve a

    nice graphical interface and easy manipulation for

    user, according their needs.

    Index Terms Fourier transform, signals, sound,

    discrete ,sampling, filter, spectrum, frequency.

    I. INTRODUCTION

    This text discloses a specific application on

    Fourier Transform, taking into account the filters

    (low pass filters and high pass filters), developed

    based on the collection of sounds from outside or

    exporting files WAV to then get the transformed

    and it filtrated in this manner, you can find the best

    way to listen to a recording for which you use the

    graphical interface Matlab (Guide), for facilitating

    user interaction with application development.

    II. GENERAL OBJECTIVE

    Develop a practical application of some of

    the concepts covered in the course of signals

    and systems

    III. SPECIFIC OBJECTIVES

    Apply the Fourier transform in audio signal

    processing using Matlab.

    Analyze audio signals from their spectra

    in the time domain and frequency, in thediscrete time.

    IV. THEORETICAL FRAMEWORK

    IV-A. File Wav

    Waveform Audio File Format (WAVE, or morecommonly known as WAV due to its filename

    extension),[3][6][7][8] (also, but rarely, named,

    Audio for Windows[9]) is a Microsoft and IBM

    audio file format standard for storing an audio

    bitstream on PCs. It is an application of the

    RIFF bitstream format method for storing data in

    chunks, and thus is also close to the 8SVX and

    the AIFF format used on Amiga and Macintosh

    computers, respectively. It is the main format

    used on Windows systems for raw and typically

    uncompressed audio. The usual bitstream encod-

    ing is the linear pulse-code modulation (LPCM)

    format.

    IV-B. Fourier Transform

    The Fourier transform is a mathematical

    operation that decomposes a signal into its

    constituent frequencies. Thus the Fourier

    transform of a musical chord is a mathematical

    representation of the amplitudes of the individual

    notes that make it up. The original signal depends

    on time, and therefore is called the time domainrepresentation of the signal, whereas the Fourier

    transform depends on frequency and is called the

    frequency domain representation of the signal.

    The term Fourier transform refers both to the

    frequency domain representation of the signal

    and the process that transforms the signal to its

    frequency domain representation.

    In mathematical terms, the Fourier transform

    transforms one complex-valued function of

    a real variable into another. In effect, theFourier transform decomposes a function into

  • 7/31/2019 Analisis Del Espectro de Audio en Matlab

    2/5

    2

    oscillatory functions. The Fourier transform and

    its generalizations are the subject of Fourier

    analysis. In this specific case, both the time

    and frequency domains are unbounded linear

    continua. It is possible to define the Fouriertransform of a function of several variables,

    which is important for instance in the physical

    study of wave motion and optics. It is also

    possible to generalize the Fourier transform on

    discrete structures such as finite groups. The

    efficient computation of such structures, by fast

    Fourier transform, is essential for high-speed

    computing.

    There are several common conventions for

    defining the Fourier transform of an integrablefunction f : R C. This report will use thedefinition:

    F() =

    f(x) e2ixdx

    For every real number .

    When the independent variable x representstime (with SI unit of seconds), the transform

    variable represents frequency (in hertz). Undersuitable conditions, f can be reconstructed fromf by the inverse transform:

    f(x) =

    F() e2ixd

    For every real number x.

    For other common conventions and notations,

    including using the angular frequency instead

    of the frequency , see Other conventions andOther notations below. The Fourier transform on

    Euclidean space is treated separately, in which

    the variable x often represents position and momentum.

    IV-C. Filters

    Filters are electronic circuits which perform

    signal processing functions, specifically to

    remove unwanted frequency components from

    the signal, to enhance one wanted it, or both.

    Filters can be:

    IV-C.1. Low Pass Filters: An ideal low-pass

    Filters transfer function is shown. The frequency

    between pass and stop bands is called the

    cut-off frequency (wc). All of the signals with

    frequencies be- low !c are transmitted and allother signals are stopped.

    In practical Filters, pass and stop bands are

    not clearly defined, |H(jw)| varies continuouslyfrom its maximum toward zero. The cut-off

    frequency is, therefore, defined as the frequency

    at which |H(jw)| is reduced to 1/2 = 0,7 ofits maximum value. This corresponds to signal

    power being reduced by 1/2 as P V2.

    IV-C.2. High Pass Filter: A high-pass filter,or HPF, is an LTI filter that passes high fre-

    quencies well but attenuates (i.e., reduces the

    amplitude of) frequencies lower than the filters

    cutoff frequency. The actual amount of attenuation

    for each frequency is a design parameter of the

    filter. It is sometimes called a low-cut filter or

    bass-cut filter.

    V. METHODOLOGY

    Program development is done as follows:

    The program basically allows us to represent an

    audio signal at the time domain and transform

    it to frequency domain, using Fast Fourier

    Transform (FFT) Analysis.

    Once represented in frequency terminus, becomes

    a high pass filter or low pass filter to desired

    frequencies for then compare the changes in the

    spectrum and sound reproduction.

    For obtain audio signal, we using some commands

    in Matlab, which can upload in memory a sound

    file with .WAV format (default), or record sincemicrophone an audio signal during a specific

    time, that will be able save with the format same,

    for after be used. The files have to be in the

    same folder where the program run.

    Once you enter the signal is possible to see

    their representation in the time domain, in this

    case graphically shows the evolution of the

    amplitude (of the magnitude that we measure:

    intensity and volume of sound) versus time.

    Later, will be able to observe and characterizethe spectrum of the analog audio signal, through

  • 7/31/2019 Analisis Del Espectro de Audio en Matlab

    3/5

    3

    Fourier transform, through Fourier transform,

    which not only contains information about the

    intensity to certain frequency, but also about

    phase, this information can be represented as a

    two-dimensional vector or as a complex number.Frequency representation capture the spectral

    characteristics of the audio signal, which the

    signal spectrum shows the energy distribution

    within the frequency range. Addition the

    fundamental frequency, there are many

    frequencies present in a waveform. A spectral

    representation shows the frequency content

    sound. The individual frequency components

    of the spectrum can be called harmonics or

    partial. Harmonic frequencies are simple integer

    of fundamental frequency.

    Fourier analysis will be able to represent

    any waveform through a set of harmonically

    related components of appropriate amplitude

    and phase. As FT is an intensive computational

    process, then use a technique called Fast Fourier

    Transform (FFT) analysis, available in Matlab,

    which provide conversion to the frequency

    domain of the auditory signal, allowing spectrum

    analysis. The FFT uses mathematical shortcuts

    to minimize processing time, but this puts atrisk the itself analysis. The resulting analysis

    file known as the FFT size, indicates the

    number of original signal samples used in the

    analysis and determines the number of discrete

    frequency bands. When using many frequency

    bands, the bands have less bandwidth, allowing

    more accurate frequency readings.

    FFT takes N consecutive samples of signal and

    performs a mathematical operation to produce N

    samples of the signal spectrum. The N samples

    are complex values with real and imaginary partwhich can calculate the absolute value, which is

    spectrum magnitude. Sampling and quantization

    of the analog signal will have a sampling rate of

    44100 Hz and will yield a corresponding digital

    signal.

    Finally, for achieve adequate sampled signal

    we use low pass filters or high pass, as needed.

    In the end, the program can compare each

    spectra of the input signal and used it according

    to convenience.

    VI. USE R MANUAL

    VI-A. Open the Program

    For run the program, you must have installed

    Matlab on your computer. Then go to the folder

    where is the application, select it and double click

    or intro and the program will run automatically.

    Once executed, the following window opens:

    Fig. 1. Main window program.

    Here you can see that program contains a space

    for the acquisition and audio signal processing

    and a graphical interface where it shows thebehavior of signal and their spectra, as explained

    in the following points.

    VI-B. Upload the Audio Signal to the Program

    When is required process an audio signal,

    whether the recording of an interview, a sound

    of some natural event, a music file, etc, often

    the user already has the file which it want to dothe respective analysis, but sometimes, occurrence

    of imminent events makes it necessary obtain an

    immediate recording and high quality. For this, the

    program has two ways to load the audio signal:

    VI-B.1. Direct Recording From Microphone:

    One way to process the audio signal may be

    recorded from outside the computer using the PC

    microphone or headset.

    For record the signal, connect a microphone to

    your computer (if this is not included) and then

    position yourself in the position for recording (inthe top left of the program) as shown in figure (2)

  • 7/31/2019 Analisis Del Espectro de Audio en Matlab

    4/5

    4

    Fig. 2. Recording area.

    Later, enter the time in seconds for which to

    record and press the record button as shown in

    the figure (3).

    Fig. 3. Recording made.

    Once signal is recorded, can process it im-mediately or save it for later use. To save the

    file, simply type the desired name in the place

    designated for this (see figure 4). The program

    is saved by default in the folder where is the

    executable with wav format.

    Fig. 4. Save recording.

    VI-B.2. Upload Sound File: Another way get

    the sound signal, is load an existing file on the

    computer, for this, the file must be contained

    in the same folder where is the executable ap-

    plication. The format of the file must be .wavextension. Once you save the file in the folder,

    should be addressed to upload a file.as shown in

    Figure (5).

    Fig. 5. Upload sound file.

    you must Enter the name of the file and sam-pling speed. After click the open button and the

    program will load it .

    VI-C. Play and Plot the Signal

    Play and plot the signal is very simple, once

    loaded the audio signal, you must press the play

    and graph button (see figure 5) and the program

    plays the file and show the spectrum of behavior

    of the audio signal in time in sound graphic(see

    example in Figure 6)

    Fig. 6. Graphic example sound in time.

    For look the spectrum of the loudness of the

    signal in terms of frequency, simply press the

    transform button that shown in Figure (5) and

    automatically appear in Spectrum of the audiosignal, see figure (7).

  • 7/31/2019 Analisis Del Espectro de Audio en Matlab

    5/5

    5

    Fig. 7. Sound spectrum for the example given.

    VI-D. Filtering Process

    Filter the signal, should be located in the Fil-

    tering options, then choose the type of filtering

    (high pass or low pass), then enter the frequencyvalue that you want to do the filtering, and press

    the filter button for observe the spectrum (see

    figure 8), the spectrum appear in the section

    spectrum of the audio signal filtered(see figure

    9). You can play the filtered signal to observe

    changes, as well as save them for later use, which

    you need to press the respective button, and name

    the file (see figure 8)

    Fig. 8. Filtering Options.

    Fig. 9. Signal with low pass filter of the example.

    VI-E. Note:

    For a closer view of the spectra, only pressed

    click on the desired graph as many times as

    needed for the program to make the respectivezooms.

    VII. CONCLUSIONS

    The Fourier transform facilitates the analysis

    of a function, since it is represented in

    terms of frequency and not time facilitating

    mathematical development in all the required

    operations.

    The Fourier transform as one of its main

    applications in engineering is the observing

    efficiency due to the harmonics produced in

    circuits applied.

    Guide is an important tool that facilitates

    interaction with the user applications, taking

    into account the delays the execution pro-

    cess.