0

I am trying to make an acoustic modem with matlab. It records sound an stores it in an array, modulates it using 64-QAM and adds then demodulates it. But the demodulated sound and recorded sound are not the same. Here is the code:

clear;
clc;
M = 64;      % Modulation order (alphabet size or number of points in signal constellation)
k = log2(M);
Fs=44100;
Nbits=8;
nChannels=1;
SNR=250;

%audio recording
recObj=audiorecorder(Fs,Nbits,nChannels);
recDuration=3;
disp("Begin speaking.")s
recordblocking(recObj,recDuration);
disp("2 sec pause")
pause(2)
disp("End of recording")
y=getaudiodata(recObj);     
plot(y);                    
% playObj=audioplayer(y,Fs);  
% play(playObj);              
Ts=-(1/Fs)/2:1:(1/Fs)/2;
figure
subplot(1,2,1);
plottf(y,Ts,'t');           
subplot(1,2,2);
plottf(y,Ts,'f');           



%MODULATION QAM
y_int = abs(round(y*1000/16));     
constdiag = comm.ConstellationDiagram('XLimits',[-sqrt(M) sqrt(M)],'YLimits',[-sqrt(M) sqrt(M)]);
qamData = qammod(y_int,M);
constdiag(qamData)


%DEMODULATION QAM
demodData = qamdemod(noisySound,M);
demodData = demodData*16/1000;
isequal(y_int,demodData);   
playObjn=audioplayer(demodData,Fs);
play(playObjn);     

%LOWPASS FILTER
Fn = Fs/2;                                              % Nyquist Frequency (Hz)
Wp = 1000/Fn;                                           % Passband Frequency (Normalised)
Ws = 1010/Fn;                                           % Stopband Frequency (Normalised)
Rp =   1;                                               % Passband Ripple (dB)
Rs = 150;                                               % Stopband Ripple (dB)
[n,Ws] = cheb2ord(Wp,Ws,Rp,Rs);                         % Filter Order
[z,p,k] = cheby2(n,Rs,Ws,'low');                        % Filter Design
[soslp,glp] = zp2sos(z,p,k);                            % Convert To Second-Order-Section For Stability
figure(3)
freqz(soslp, 2^16, Fs)                                  % Filter Bode Plot
filtered_sound = filtfilt(soslp, glp, demodData);
%sound(filtered_sound, 44100)

where am i doing wrong?

I tried 16QAM and 32QAM but result is the same.

El_Canario
  • 41
  • 3
  • Where is ```noisySound``` defined? Also, there's at least a typo in the script: check the "s" floating in the breeze at the end of the ```disp("Begin speaking.")s``` line. – picchiolu Jan 04 '23 at 16:36

0 Answers0