modulation using Weaver method in Real time
4 次查看(过去 30 天)
显示 更早的评论
I am attempting to modulate my voice in real time using the Weaver method. When I plot the output however, the graph does not appear to line up with the sound I make. I am unclear what the error in my code is.
micReader=audioDeviceReader;
speakerWriter=audioDeviceWriter;
fileWriter=dsp.AudioFileWriter;
spectAnalyzer=dsp.SpectrumAnalyzer;
fileReader=dsp.AudioFileReader;
tic;
while (toc<2)
audio=micReader();
speakerWriter(audio)
fileWriter(audio)
step(audio,Fs)
%Initial variables settings
Fs_min = 300;%minimum frequency
Fs_max =5000; %maximum frequency
channelCarrierFreq = 20000;%carrier frequency
magCarriers = 2; %magnitude of the carrier
%sampleFreq=100000; %sample frequency
messageFrequency=audio;
%messageFrequency=1000;
tt=numel(audio);
%sampleFreq=10*(channelCarrierFreq+messageFrequency);
sampleFreq=44100;
samplePerPeriod=sampleFreq/messageFrequency;
%length=[0:samplePerPeriod-1]/sampleFreq;
%samplePerPeriod=sampleFreq/messageFrequency;
%Signal=0.5*messageFrequency*cos(2*pi*messageFrequency*length)
Signal=0.5*messageFrequency.*cos(2*pi*messageFrequency*tt)
%messageFrequency = repmat(Signal',100,1);
%Sequence=messageFrequency;
Sequence=Signal;
%[num,den] = ellip(7,1,60,2*Fs_max/sampleFreq);
%Filtered_Sequence = filter (num,den,Sequence);
Filtered_Sequence=Sequence;
upper=1;
lower=-1;
t=[1:numel(Sequence)]./sampleFreq; % Time vector
fstCarrierFreq=(Fs_min +Fs_max)/2;
envelope = Filtered_Sequence; % Improper designation here but easy for future plot
% if get(handles.MatlabModulestoggle,'Value') == 0
% num =firFilter(-fstCarrierFreq,fstCarrierFreq,30,sampleFreq,'Blackman',handles);
% den = 1;
% else
%end
%MODULATION%MODULATION%MODULATION%MODULATION%MODULATION%MODULATION%MODULATION%MODULATION
%qq=fstCarrierFreq./sampleFreq
qq=0.0126;
[num,den] = ellip(7,1,60,2*qq);
par2=(magCarriers*cos(2*pi*fstCarrierFreq.*t'))
Env_I = filter (num,den,Filtered_Sequence.*par2 ); % Complex envelope chanel I
Env_Q = filter (num,den,Filtered_Sequence.* (magCarriers*sin(2*pi*fstCarrierFreq.*t'))); % complex envelope chanel Q
Iupper = Env_I .* (magCarriers*cos(2*pi*(channelCarrierFreq + upper*fstCarrierFreq).*t'));
Qupper = Env_Q .* (magCarriers*sin(2*pi*(channelCarrierFreq + upper*fstCarrierFreq).*t'));
modltCarrier = -(Iupper + Qupper); % SSB-USB
Ilower = Env_I .* (magCarriers*cos(2*pi*(channelCarrierFreq + lower*fstCarrierFreq).*t'));
Qlower = Env_Q .* (magCarriers*sin(2*pi*(channelCarrierFreq + lower*fstCarrierFreq).*t'));
LowermodltCarrier = Ilower - Qlower; % SSB-LSB
%DEMODULATION%DEMODULATION%DEMODULATION%DEMODULATION%DEMODULATION%DEMODULATION%DEMODULATION
subplot(3,1,1)
plot(t,audio);
subplot(3,1,2)
plot(t,LowermodltCarrier);
subplot(3,1,3)
plot(t,modltCarrier);
end
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Measurements and Spatial Audio 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!