I'm trying to create the Sine Chorus effect in Matlab. This is my code :
function y=chorus(x, f_sine, delay, depth, mix, fs);
x=wavread(x);
BL=0.7;
FB=-0.7;
FF=1;
for n=1:length(x);
M(n)=delay+depth*(0.5+0.5*sin(2*pi*f_sine*n/fs));
xh=x(n)+FB*xh(n-M(n));
y(n)=FF*xh(n-M(n))+BL*xh(n);
end;
soundsc(y,fs);
It has some errors and i haven't figured out how to mix my original signal with the processed one. How can i make this work ?
A second try :
function y=sine_chorus(x, f_sine, delay, depth, mix, fs);
BL=0.7;
FB=-0.7;
FF=1;
x=wavread(x);
%sound(x,fs);
D=ceil(delay*fs);
xlen=length(x);
y=zeros(size(x));
%filter
for i=D+1:1:xlen
M(i)=delay+depth*(0.5+0.5*sin((2*pi*f_sine*i)/fs));
xh=x(i)+FB*xh(i-M(i));
y(i)=FF*xh(i-M(i))+BL*xh(i);
y(i)=x(i)+mix*x(i-M(i));
end
soundsc(y,16000);
Now the y array which is created should have my output signal, instead of this it's filled with zeros. What's going wrong with this ?