Simulación en Matlab
Bajar los archivos (1.03K)
Simul.m
while i[audio,fs]=wavread('WavFile');	    % Lee el archivo WavFile.wav (8 bits PCM)

t=0:1/fs:(length(audio)-1)/fs;
f=5000;
audio=(audio-128)/128;

tono                      % genera el tono interferente
%s=sin(2*pi*f*t);

audio=.7*audio*0;
suma=audio+s';
suma=(suma/max(abs(suma))); 

sumasal=suma*128+128;
wavwrite(sumasal,fs,'suma')
sound(sumasal,fs) 

i=1;
delta=trunc(.01);       % trunca el resultado para que se aproxime al DSP
M=20;
D=1;

%load h.mat
h=zeros(size(1:M));

xviejo=zeros(size(1:M));
entrada=trunc(suma);
e=zeros(size(entrada));
y=zeros(size(entrada));
buffer=zeros(size(1:D+1));

while i<=length(entrada),
	x=entrada(i);
	buffer(1)=x;
	y(i)=h*xviejo';
	e(i)=trunc(x)-trunc(y(i));
	h=h+trunc(delta*trunc(e(i)*trunc(xviejo)));
	xviejo(2:M)=xviejo(1:M-1);
	xviejo(1)=buffer(D);
	buffer(2:D+1)=buffer(1:D);
	i=i+1;
end

sal = e/max(abs(e));
sal=sal*128+128;
wavwrite(sal,fs,'salida')
ysal = y/max(abs(y));
ysal=ysal*128+128;
wavwrite(ysal,fs,'ysalida')
y=y*ss;

clear figure
plot(s(1:400),'c')
hold
plot(y(1:400),'y')
figure(2)
plot(s(400:800),'c')
hold
plot(y(400:800),'y')
figure(3)
plot(s(800:1200),'c')
hold
plot(y(800:1200),'y')
figure(4)
plot(s(1:400)-y(1:400))
figure(5)
%freqz(h,1,500,'whole',fs)
freqz(h,1,500)

 

tono.m
%******************* Genera un vector con 4 tonos intercalados ***************

mask=1:length(t);
len=length(t);
m1=mask<len/4;
m2=mask>len/4 & mask<len/2;
m3=mask>len/2 & mask<3*len/4;
m4=mask>3*len/4 & mask<len;

f1=800;
f2=900;
f3=3000;
f4=3500;

s1=sin(2*pi*f1*t);
s2=sin(2*pi*f2*t);
s3=sin(2*pi*f3*t);
s4=sin(2*pi*f4*t);
%s = s1.*m1 + s2.*m2 + s3.*m3 + s4.*m4;

s = (s1+s3).*m1 + (s2).*m2 + (s3+s4).*m3 + (s4).*m4;

 

trunc.m
%*****************************************************************
%                    function y=trunc(v)
%*****************************************************************

function y=trunc(v)

N=23;

y=(fix(v*2^N))/2^N;

Volver a Proyecto de DSP