How to Upload a Sound File Onto Matlab

Audio Processing with MatLab

An Introduction

By:Rachel Hager

This lab is an introduction to audio processing with MatLab.This lab volition help to familiarize you with some of the principal functions to read in and play music files in MatLab.

The following functions that volition be used in this lab are:

wavread()�������� audio() soundsc()�������� flipud() wavwrite()

To empathize how each of these functions is used in MatLab, type help followed by i of the above commands into the control prompt.Note that in order to use the wavread() function you must use a .wav file.It is possible to convert .wma and .mp3 files into .wav files.You lot can Google search to find programs to practise this.If you tin�t observe one that works, transport me an email and I can forward y'all some links.

This lab consists of the following sections:

Section ane:Read and Shop an Audio File in MatLab

Section 2:Play the Audio File

Department 3:Audio Scaling

Department 4:Playing a Runway Backwards

Section 5:Practice What You�ve Learned

Section 6:Create Music with MatLab

Let�south get started!!!

Department 1:Read and Store an Audio File in MatLab

To read and shop an audio file, you can employ one of two different control lines.The following stores the file into variable y.

y = wavread(�filename');

Recollect to include the unabridged filename including the directory.

����������� Example: C:\My Documents\EE186Labs\Audio.wav

The command line below stores the audio file into variable y and the sampling frequency in variable Fs.

[y,Fs] = wavread(�filename');

Section 2:Play the Audio File

To play an audio file in MatLab yous use the sound() function.The following part plays the sound.If the Fs variable is not divers or included in the command, information technology will assume the default sample rate of 8192 Hz.

sound(y,Fs);

Section 3:Audio Scaling

To scale an audio file the soundsc() control is used.This allows for the modification of an audio signal�due south amplitude or frequency.

soundsc(y,Fs);

To increment the volume of the audio track you can multiple the variable information technology is stored in by a scalar.To wearisome down or speed up the rail played yous can arrange the sampling charge per unit.Comment on your observations using dissimilar values.

Now experiment with different chip values (1,ii,..,16) in the following command:

soundsc(y,Fs,$.25);

Comment on your observations.

Section 4:Playing a Track Backwards

The control to reverse the guild of the samples in a matrix is flipud().Experiment with this command.

Section v:Practice What Yous�ve Learned

Now for this office of the lab accept fun with MatLab.Take your favorite music files and convert them to .wav files if they are non already converted.I�g sure you all have sound files from some source or some other!!! If you�re not sure how to convert the files, Google search it.

Once y'all have a couple of your favorite audio files, yous may need to crop the file.Virtually audio files are fairly large which can cause MatLab to lock up.

Read and store the cropped sound file.Now use some of the above commands to alter the audio point.Play your favorite vocal backwards or brand your favorite singer sound similar a chipmunk.Note that the above commands are merely a basic look at MatLab�due south sound processing capabilities.

Comment on your findings!!!

For your aid here is a file forward and backward that has been done with the aforementioned process

Section 6:Create Music with MatLab

This section of the lab volition teach you lot how to create songs using unlike tones created in MatLab.First we are going to lawmaking a sine wave of aamplitude A = 1, with at an audio frequency of 523.25 Hz (corresponds to C).

cnote = sin(2*pi*523.25*(0:0.000125:0.5));

This vector cnote now contains simples of the sine wave from t = 0s to t = 0.5s, in samples that are spaced 0.000125s apart (this is the sampling interval Ts).Note that this sampling interval corresponds to a sampling frequency of 8 kHz (ane/Ts = fs).This is standard for vocalisation grade audio channels.

Now to write this sound to a wave file nosotros have the following command.

wavwrite(cnote, �c.wav�);

Now to play the audio, same as before use the audio() function.That is the single note that you just created.Now that you�ve got one down� just several more to go!!

I�ve done some of the easy work here for you.The following webpage gives the frequencies of different notes which are besides shown on the table below. http://www.dolmetsch.com/musictheory27.htm

Using this information create a few different notes in MatLab.

Note that at that place are different octaves equally y'all get through the different keys on a piano.To go y'all started here are a few:

f = sin(2*pi*174.61*(0:0.000125:0.five));

g = sin(ii*pi*195.99*(0:0.000125:0.5));

a = sin(2*pi*220*(0:0.000125:0.v));

b = sin(2*pi*246.94*(0:0.000125:0.5));

Now to create a line of music use the following command:

line1 = [a,b,c,d,e,f];

line2 = [a,b,c,d,eastward,f];

The letters should stand for the notes that you lot have created in MatLab.Put the notes in the order you want them to play.

To create your song apply:

song = [line1, line2];

Add as many lines equally yous like.At present write your song, read and store it into a new variable, and listen to information technology.Comment on your musical abilities.If you�re musically challenged, check out Google for some songs that y'all can create.Experience free to create your ain song or endeavour to copy some Beethoven.Bask!!!

If you need some more help with this lab, check out the following link:

http://users.rowan.edu/~shreek/networks1/music.html

For another example, at the finish of this lab I take attached the song that I created which is a few lines of �Heart and Soul�.Get creative with this assignment and annotate on the problems y'all run in to.

mcclainthatiand.blogspot.com

Source: http://class.ece.iastate.edu/mmina/ee186/labs/Audio.htm

0 Response to "How to Upload a Sound File Onto Matlab"

Postar um comentário

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel