Está en la página 1de 4

clear all;

clc;
% Modulacion MPSK %
% Entrada de audio, Mezcla estereo -- 1; Microfono -- 2

%Grabar audio

disp ('Grabando...')
audio_1 = audiorecorder(2000,16,1,1);
tr = 3; %tiempo total de grabacion
recordblocking(audio_1,tr);
disp('Fin de Grabacion');

t=linspace(0,tr,length( getaudiodata(audio_1)) );
repr = input ('Reproducir audio 1--sí, 0--no ');
if repr == 1
disp('Reproduciendo...')
play(audio_1);
disp('Fin')
end

muest_audio1 = getaudiodata(audio_1);
subplot(2,2,1)
plot(t,muest_audio1)
%%
muestr_audio = muest_audio1' ;

%%Conversion Analogica-Digital

n=5; %bits de cuantizacion


n_muestr = 20;%length(muestr_audio); %numero de muestras
cod = zeros(1,nn_muestr);
for z = 1n_muestr
Vmax = max(muestr_audio);
Vmin = min(muestr_audio);

mtr = muestr_audio(1,z); %muestra a cuantizar


j = 1+(z-1)n; %desde que posicion se colocan los bits
for i =1n

Vref = Vmax - (Vmax-Vmin)2;


if mtr = Vref
cod(1,j) = 1;
Vmin = Vref;
else
cod(1,j) = 0;
Vmax = Vref;
end
j=j+1;
end

end
% disp(mat2str(cod))
fs = 8000;
R=nfs; %velocidad de transferencia de bits
tb=1R; %tiempo de bit

%%
%Modulacion
el = 2; %agrupacion
L = 2^el; %numero de niveles
Ac = 100;
fc = 2R; %frec portadora
ts = eltb; %tiempo de simbolo
D = 1ts; %velocidad de transferencia de baudios
s_fase = 2piL; %salto de fase
amp = 3; %input('ingrese el valor max para la señal multivel ');
s_amp = amp(L-1); %salto de amplitudes multinivel
n_amp(1)=0;
for i=24
n_amp(i) = n_amp(i-1)+s_amp;
end

Dp = (pi2)s_amp;
for i=14
n_fase(i) = Dpn_amp(i);
end

tgr = 01(2000fs)tblength(cod); %tiempo para graficar


st = zeros(1,length(tgr)); %señal pasabanda MPSK
j=1;
vt=2;
while j= length(cod)-1

if [cod(1,j),cod(1,j+1)]== [0,0]
% disp(n_fase(1)180pi)
k = find(tgr = (j+1-vt)ts & tgr = (vt-1)ts);
st(k) = Accos(2pifc.tgr(k)+n_fase(1));

end

if [cod(1,j),cod(1,j+1)]== [0,1]
% disp(n_fase(2)180pi)
k = find(tgr = (j+1-vt)ts & tgr = (vt-1)ts);
st(k) = Accos(2pifctgr(k)+n_fase(2));

end

if [cod(1,j),cod(1,j+1)]== [1,1]
% disp(n_fase(3)180pi)
k = find(tgr = (j+1-vt)ts & tgr = (vt-1)ts);
st(k) = Accos(2pifctgr(k)+n_fase(3));

end

if [cod(1,j),cod(1,j+1)]== [1,0]
% disp(n_fase(4)180pi)
k = find(tgr = (j+1-vt)ts & tgr = (vt-1)ts);
st(k) = Accos(2pifctgr(k)+n_fase(4));

end
j = j+2;
vt=vt+1;
end
subplot(2,2,2)
plot(tgr,st)

%% MODULACION 4PI
o= zeros(1,length(cod));
n1=-3pi4;
n2=3pi4;
n3=pi4;
n4=-pi4;
tgr = 01(2000fs)tblength(cod); %tiempo para graficar
st1 = zeros(1,length(tgr)); %señal pasabanda MPSK
j=1;
vt=2;
while j= length(cod)-1

if [cod(1,j),cod(1,j+1)]== [0,0]
% disp(n_fase(1)180pi)
k = find(tgr = (j+1-vt)ts & tgr = (vt-1)ts);
stp(k) = Accos(2pifc.tgr(k)+n1+o(j));
o(j)=n1;

end

if [cod(1,j),cod(1,j+1)]== [0,1]
% disp(n_fase(2)180pi)
k = find(tgr = (j+1-vt)ts & tgr = (vt-1)ts);
stp(k) = Accos(2pifctgr(k)+n2+o(j));
o(j)=n2;

end

if [cod(1,j),cod(1,j+1)]== [1,1]
% disp(n_fase(3)180pi)
k = find(tgr = (j+1-vt)ts & tgr = (vt-1)ts);
stp(k) = Accos(2pifctgr(k)+n3+o(j));
o(j)=n3;
end

if [cod(1,j),cod(1,j+1)]== [1,0]
% disp(n_fase(4)180pi)
k = find(tgr = (j+1-vt)ts & tgr = (vt-1)ts);
stp(k) = Accos(2pifctgr(k)+n4+o(j));
o(j)=n4;
end
j = j+2;
vt=vt+1;
end
subplot(2,2,3)
plot(tgr,stp)

% j=0;
% for i=1floor(length(cod)el) %numero de bloques agrupados
% j=j+1;
% g=1;
% vdec=0;
% for j=jeli; %desde donde empiezo a agrupar
% v(1,g) = cod(1,j);
% vdec = vdec + v(1,g)2^(el-g);% conversion de bin a dec
% g=g+1;
% end
% for w=1L
% r = (vdec == y(w));
% if r == true
% %disp(gray(w,1el));
% %disp(n_fase(w)180pi);
% for u=1length(tgr)
% if tgr(u)=ts(i-1) && tgr(u)=tsi
% st(u) = cos(2pifctgr(u)+n_fase(w));
% end
% end
% end
%
%
%
% end
%
% end

También podría gustarte