How to demodulate a sound through MATLAB

23 views (last 30 days)
CHUL SHIN
CHUL SHIN on 22 Sep 2016
Answered: Zhao Wang on 27 Sep 2016
DSB-SC Demodulation in MATLAB
Hi.
I have to record a sound which was already modulated in a certain carrier frequency (from 4000Hz to 16000Hz), and demodulate the recorded sound with MATLAB so that I can play the demodulated sound, which is close to the original sound. And these procedures have to run in MATLAB.
So far, I made a code which can load the sound data and plot the data in fft(fast fourier transform). Here is my code. --------------------------------------------
N=length(data);
F1=0:fs/N:fs-fs/N;
FFT_data=fft(data);
figure;
plot(F1(1:N),abs(FFT_data(1:N)));
xlabel('Frequency')
ylabel('Amplitude')
axis([0 2000 0 1000])
grid on
--------------------------------------------
But I can't really develope it into the DSB-SC demodulation code.
Can anyone help me with this?
And this is the demodulation code which I've found in a website.
I hope this code to be helpful.
--------------------------------------------
% task 1
fc=154000;
% task 2
fm=fc/10;
fs=100*fc;
t=0:1/fs:4/fm;
xc=cos(2*pi*fc*t);
xm=cos(2*pi*fm*t);
figure(1)
subplot(2,1,1),plot(t,xc);
title('carrier signal of 154 khz');
xlabel('time (sec)');
ylabel('amplitude');
subplot(2,1,2),plot(t,xm);
title('message signal of 15.4 khz');
xlabel('time (sec)');
ylabel('amplitude');
% DSB-SC MODULATION
z1= xm.*xc;
figure(2)
% task 3.1
subplot(2,1,1),plot(t,z1);
title('DSB-SC MODULATION IN TIME DOMAIN');
xlabel('time (sec)');
ylabel('amplitude');
% task 3.2
l1=length(z1);
f=linspace(-fs/2,fs/2,l1);
Z1=fftshift(fft(z1,l1)/l1);
subplot(2,1,2),plot(f,abs(Z1));
title('DSB SC MODULATION IN FREQUENCY DOMAIN');
xlabel('frequency(hz)');
ylabel('amplitude');
axis([-200000 200000 0 0.3]);
% task 3.3 demodulation
s1=z1.*xc;
S1=fftshift(fft(s1,length(s1))/length(s1));
figure(3)
plot(f,abs(S1));
title(' demodulated signal IN FREQUENCY DOMAIN before filtering');
xlabel('frequency(hz)');
ylabel('amplitude');
axis([-200000 200000 0 0.3]);
hold on
Hlp=1./sqrt(1+(f./fc).^(2*100));
plot(f,Hlp,'g');
title(' frequency response of low pass filter');
xlabel('frequency(hz)');
ylabel('amplitude');
axis([-200000 200000 0 2]);
% task 3.4
E1=Hlp.*S1;
figure(4)
subplot(2,1,1),plot(f,E1);
title(' Recover signal IN FREQUENCY DOMAIN after filtring');
xlabel('frequency(hz)');
ylabel('amplitude');
axis([-200000 200000 0 0.3]);
e1=ifft(ifftshift(E1))*length(E1);
subplot(2,1,2),plot(t,(1/0.5)*e1);
title(' Recover signal IN Time DOMAIN after filtring');
xlabel('time(sec)');
ylabel('amplitude');
--------------------------------------------

Answers (1)

Zhao Wang
Zhao Wang on 27 Sep 2016
I understand that you want to build a DSBSC demodulator to demodulate a recorded sound file. You might refer to the following links from MATLAB File Exchange:
If you have any question regarding the file exchange submissions, contact the authors of the submissions directly.
There is also a "DSBSC AM Demodulator Passband" block in the Communications System Toolbox. You can use it to check the performance of the demodulator you construct. For more details about this demodulator block, refer to the following link:

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!