Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

MST- 1

Student Name: KAPALLI LAKSHMI UID: 18BEC1060


SRINIVASA RAJU
Branch: 7ECE-2 Section: 7ECE-2/CS-1/A
Semester: 7th Date of Performance:4/10/21
Subject Name: Audio and Video Subject Code: ECB- 402
Processing lab

Aim/Overview of the practical: To learn how to:

1.1 Read an audio in MATLAB

1.2 Reverse Audio in MATLAB

1.3 Down sample an Audio in MATLAB

Software: MATLAB online


Algorithm/Flowchart: No Algorithm/Flowchart required for this experiment

Theme/Interests definition:

MATLAB is a high-performance language for technical computing. It integrates


computation, visualization, and programming environment. This experiment gives us
an introduction to the basic capabilities of MATLAB for audio processing it also gives a
list of core MATLAB functions and commands that are applicable to audio processing
for those starting to use the language.

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.

Reverse audio in MATLAB:

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);

Down sample audio in MATLAB:


Downsampling is the process of reducing the sampling rate of a signal. Downsample
reduces the sampling rate of the input AOs by an integer factor by picking up one out of N
samples
y = downsample(x,n) decreases the sample rate of x by keeping the first sample and then
every nth sample after the first. If x is a matrix, the function treats each column as a
separate sequence.

Program code:

clc; % to clear command window


clear all; % to clear workspace
close all; % to close all opened windows

% Reading an audio file

[y Fs] = audioread('7061-6-0-0.wav');
%sound(y,Fs ); % sampling the signal at the rate of Fs

% Reversing the signal

y1 = flipud(y); % to reverse the audio signal


%sound(y1,Fs );
subplot(2,1,1);plot(y);xlabel(' y - Before Reversing the signal ')%
displaying the signal
subplot(2,1,2);plot(y1);xlabel(' y1 - After Reversing the signal')

% Down Sampling

% sound(y,Fs); %% sampling the signal at the rate of Fs


y2= downsample(y,2); % down sampling
% sound(y2,Fs);
figure
subplot(2,1,2);plot(y);xlabel(' y - Original signal ')% displaying
subplot(2,1,1);plot(y2);xlabel(' y1 - After down sampling the signal')
linkaxes; % synchronizes the axis limits of two graphs ( equate the
limits of y with limits of y1)

Output:

Figure: 1
Figure: 2 - For Reversing the signal

Figure: 3 - For Down sampling the signal


Figure: 3
Steps for experiment/practical:

 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:

 We observed how to read and write the audio files in MATLAB.

 It helps in processing audio files very easily.

 We have used the aurioread() and audiowrite() functions in MATLAB.

 We implemented the reversing and sampling of an audio file.

Calculations/ Chemical Reactions / Theorems /Formulas used etc:

No Calculations/ Chemical Reactions / Theorems /Formulas used in this experiment.


Functions used the experiment.

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() :

audiowrite( filename , y , Fs ) writes a matrix of audio data, y , with sample rate Fs to a


file called filename . The filename input also specifies the output file format.

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:

1. Learnt about various audio processing functions and operations in MATLAB.

2. How to implement these audio function statements in our programs.

3. Need of these statements.

4. Performed and run programs using inbuilt functions and statements.


Evaluation Grid (To be filled by the faculty):

Sr. Parameters Marks Obtained Maximum


No. Marks
1. Worksheet completion including writing 10
learning objectives/Outcomes.(To be
submitted at the end of the day)
2. Post Lab task submission. 5

3. Student Engagement in 5
Simulation/Demonstration/Performance
and
Controls/Pre-Lab Questions.
Signature of Faculty (with Date): Total Marks 20
Obtained:

You might also like