UXDE dot Net
Advertisement

Sound Modulation and Demodulation Matlab Code

By -

Introduction 

In Telecommunication Industry  and signal processing Modulation is used to carry information with the help of a carrier signal wave.Common example is FM (frequency modulation ) which is mostly used for broadcasting music and speeches on radio So in modulation analog information in converted into digital and then this information is transmitted and then when this information is received at the receiver it’s demodulated and in this way information is transmitted with an efficient use of bandwidth.Now in Demodulation the information is restored by reversing the mechanism which we used in modulation.

Example 

Computer modem is used for modulation and demodulation.Basic idea is that computer generates a sequence of 1′s and 0′s from the information which is to be modulated because computer just understand binary language so this information is modulated and converted into light waves and then transmitted over optic fiber and when its reaches destination light waves are demodulated by modem and information is passed to the destination.

  • First Record object and do Sound recording  for 5 seconds.
  • Save the recorded sound in .wav format using wavewrite.
  • Read the saved .wav sound using waveread command.
  • Now Construct a carrier using this Eq A*cos(2*pi*f*t)
  • Where A=Amplitude f=Sampling Frequency and t = time
  • Now use linspace command to generate time where t=linspace(a,b,n )generates t row vector of  n point linearly between a and b.
  • Now modulate by multiplying carrier with data and then play sound to listen modulated data.
  • Now Demodulate Data is the same way and play the sound to listen the sound
  • Now at last Graph is Plotted.

Matlab Implementation

clear
clc
close all

duration=2;
recObj = audiorecorder;
fprintf(‘Press any key to start %g seconds of recording… \n’, duration); pause
fprintf(‘\n Recording…’);
recordblocking(recObj, 2);
fprintf(‘\n Finished recording. \n’);
file=recObj;
myRecording = getaudiodata(recObj);
fprintf(‘\n Press any Key to listen to Recording %h.’, myRecording); pause
fprintf(‘\n Playing… \n’);
play(recObj); pause

waveFile=’Project.wav’;
fprintf(‘\n Press any key to save the sound data to %s…’, waveFile); pause
wavwrite(myRecording,‘project.wav’);
fprintf(‘\n Saved.. \n’);
[y, fs, nbits]=wavread(‘project.wav’); % find out sampling rate,
N=length(y);

Ac=2;
fc=15e5;
t=linspace(0,length(y)/fs,length(y));

Carrier=Ac*cos(2*pi*fc*t);
carrier=transpose(Carrier);
modulatedvoice=carrier.*y;
demodulatedvoice=carrier.*modulatedvoice;
disp(‘ Press any Key to Listen to Modulated Voice’); pause
sound(modulatedvoice);
disp(‘ Press any Key to Listen to Demodulated Voice’); pause
sound(demodulatedvoice);

fprintf(‘\n Press any Key to Display the Signals. \n’); pause
subplot(4,1,1)
plot(t,myRecording);
xlabel(‘Time’); ylabel(‘signal’);
title(‘Original’);

subplot(4,1,2)
plot(t,carrier)
xlabel(‘Time’); ylabel(‘signal’);
title(‘carrier’);

subplot(4,1,3)
plot(t,modulatedvoice)
xlabel(‘Time’); ylabel(‘ signal’);
title(‘modulated voice’);

subplot(4,1,4)
plot(t,demodulatedvoice)
xlabel(‘Time’); ylabel(‘signal’);
title(‘demodulated voice’);

Source Code

Like , share this post on Facebook , Twitter by using left moving Social Sharing block and follow us on Facebook Page , Twitter and do comment and enter your email. After you have done you will automatically get source code in your mail. Note : This will be auto generated mail you can’t get until you follow above method.

Related ProjectsOptimum Global Thresholding Using Otsu’s Method Matlab Source Code

Farheen Bibi

You can find Farheen on , and .

1 Comment to Sound Modulation and Demodulation Matlab Code

Leave a Reply