Hello, I am working on a simulation of reading an audio signal into a 4-PAM modulator and demodulating in on the other side. I have Matlab and the Signal Processing toolbox that has the PAM modulator in it. I am having issues trying to format the data into the correct context to get the modulation to work. My current script is shown below:
fileIn = 'dog_dare2.wav';
info = audioinfo(fileIn);
nyRate = info.SampleRate*2;
%extract the information
%set the sampling frequency to twice that of the file
%Extract the data and the sample rate
[origY,origFs] = audioread(fileIn);
%Play the sound back
%sound(origY,origFs)
figure
ax1 = subplot(2,1,1);
ax2 = subplot(2,1,2);
%Plot the input signal and the digitized version
t1=[1/origFs:1/origFs:length(origY)/origFs];
plot(ax1,t1,origY)
%upsample the original date to nyquist rate
upY = upsample(y,2);
t2=[1/nyRate:1/nyRate:length(upY)/nyRate];
%add a plot
plot(ax2,t2,upY)
So I am analyzing the input signal for the sampling rate and then switching to the nyquist rate to double the sampling rate of the original. This is where I would think I would be able to put the information into the modulator but the modulator only accepts values from [0,M-1 (or 3 in this case)]. So I need to translate or scale the information into an acceptable input for the PAM modulator to work. Please help me out when you get a chance.

댓글 수: 1

Greg Girard
Greg Girard 2015년 10월 13일
Additional help.
So I now have the PAM modulated envelope and I am trying to combine that with an AM carrier wave but I am having a hard time combining them because of the size and matrices.
if true
m = min(max(-2, floor(upY/0.5)),1)+2;
z = pammod(m,4);
subplot(2,3,4)
plot(t2,z)
title('PAM modulation envelope')
axis([0 2 -1 1])
%Am carrier frequency is between 535-1605kHz
carrier = 1605000;
cWave = cos(carrier*t2);
subplot(2,3,5)
plot(t2,cWave)
title('Carrier wave')
%axis([0 10*(1/1605000) -1 1])
subPam = z(1:1000,:);
subCarrier = cWave(:,1:1000);
t3=[1/nyRate:1/nyRate:length(upY)/nyRate];
modWave = subPam*subCarrier;
subplot(2,3,6)
plot(t2,modWave);
end
So I can't just mix them together because they're both 46584x1 matrices (so the result is too large). I tried to make a sub sample of the first 1000 samples to try to modulate some at a time but I can't get the time to match up and they must be the same length. The modWave length is 1000x1000. Little help....still not super great at matlab.

댓글을 달려면 로그인하십시오.

 채택된 답변

Walter Roberson
Walter Roberson 2015년 10월 11일

0 개 추천

You need to quantize the signal to get a result 0 to 3 and put that result through the modulator.

댓글 수: 4

Greg Girard
Greg Girard 2015년 10월 11일
So I attempted to do that on my own code that is shown below:
m = zeros(size(upY));
for idx = 1:size(upY)
if upY(idx) < -0.5
m(idx) = 0;
elseif upY(idx) >= -0.5 && upY(idx) < 0
m(idx) = 1;
elseif upY(idx) >= 0 && upY(idx) < 0.5
m(idx) = 2;
else
m(idx) = 3;
end
end
Is there a built in function to do this better or would this work? I wasn't sure where to put the boundaries to include 0 or not since the upsampled signal has all those 0's in it. When I did this and do pammod I do get a warning that says "Warning: Imaginary parts of complex X and/or Y arguments ignored." Is that normal or did I not use it correctly?
Walter Roberson
Walter Roberson 2015년 10월 11일
m = min(max(-2, floor(upY / 0.5)), 1) + 2;
Greg Girard
Greg Girard 2015년 10월 12일
Thank you for the help Walter. One more question for you (or anyone). So with these values, do I convert them to binary values first (dec2Bin) or do I just put these right into the pammod to get the correct output?
Walter Roberson
Walter Roberson 2015년 10월 12일
You pass them directly, like is documented for pammod
The message signal must consist of integers between 0 and M-1.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

태그

질문:

2015년 10월 11일

댓글:

2015년 10월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by