Professional Documents
Culture Documents
MST 18bec1060
MST 18bec1060
Theme/Interests definition:
Audioread() function :
Audio is read into MATLAB using the function “audioread()’’ whose basic functionality
is as follows:
audioread(filename);
Where filename in this case is a MATLAB variable containing a string (array of chars)
defining the entire name of the audio file to be read including any file extensions (e.g.
mp3, wav, etc.).
A typical example of a call to audioread would be:
[y Fs] = audioread('exampleAudio.wav');
where y is the array or matrix of sampled audio data and Fs is the sampling frequency
of the input audio.
To illustrate how to reverse an audio file the following code inputs an example audio
sound (with in the built-in .mat file handel.mat) and reverses the array of audio values
using flipud. flipud is just a generic Matlab function that reverses an array of
numbers(flips them up and down in this case).
y1 = flipud(y);
Program code:
[y Fs] = audioread('7061-6-0-0.wav');
%sound(y,Fs ); % sampling the signal at the rate of Fs
% Down Sampling
Output:
Figure: 1
Figure: 2 - For Reversing the signal
Open MATLAB in our PC by double clicking the MATLAB icon.· When we start
MATLAB, a special window called the MATLAB desktop appears.
The desktop is a window that contains other windows. The major tools within the
desktop are:
The Command Window; The Command History; The Workspace; The Current
Directory; The Help Browser; The Start button· Type your operations in the
Command window below and press ENTER to see the result.· We can code in
the Workspace (Editor) and then press F5 to execute our code.· Follow the
syntax of the loop statements as above and type the code in the editor.· Run and
observe the result in the Command window below.
Observations/Discussions:
1. audioread():
[ y , Fs ] = audioread( filename ) reads data from the file named filename , and returns
sampled data, y , and a sample rate for that data, Fs.
2. audiowrite() :
3. flipud() :
B = flipud( A ) returns A with its rows flipped in the up-down direction (that is, about a
horizontal axis).
4. downsample():
y = downsample( x , n ) decreases the sample rate of x by keeping the first sample and
then every n th sample after the first.
Learning outcomes:
3. Student Engagement in 5
Simulation/Demonstration/Performance
and
Controls/Pre-Lab Questions.
Signature of Faculty (with Date): Total Marks 20
Obtained: