Y(z) b0*z^2 + b1*z + b2H(z) = ---- = ------------------ (eq. 1) X(z) a0*z^2 + a1*z + a2
Y(z) b0 + b1*z^-1 + b2*z^-2---- = ----------------------X(z) a0 + a1*z^-1 + a2*z^-2Y(z) (b0/a0) + (b1/a0)*z^-1 + (b2/a0)*z^-2---- = -------------------------------------X(z) 1 + (a1/a0)*z^-1 + (a2/a0)*z^-2Y(z) * ( 1 + (a1/a0)*z^-1 + (a2/a0)*z^-2) = X(z) * ((b0/a0) + (b1/a0)*z^-1 + (b2/a0)*z^-2) (eq. 2)
y[n] + (a1/a0)*y[n-1] + (a2/a0)*y[n-2] = (b0/a0)x[n] + (b1/a0)*x[n-1] + (b2/a0)*x[n-2]y[n] = (b0/a0)x[n] + (b1/a0)*x[n-1] + (b2/a0)*x[n-2] - (a1/a0)*y[n-1] - (a2/a0)*y[n-2] (eq. 3)
x_coef = [11 22 33]y_coef = [88 99]signal = [1 2 3 4 5]output[1] = 0output[2] = 0output[3] = 11*3 + 22*2 + 33*1 - 0*88 - 0*99 = 110output[4] = 11*4 + 22*3 + 33*2 - 110*88 - 0*99 = -9504output[5] = 11*5 + 22*4 + 33*3 - (-9504*88) - 110*99 = 825704
//DSP Tutorial//IIR Filter//By: Regulus Berdinclear;function output = compute_iir(signal, x_coef, y_coef) N = length(signal); YN = length(y_coef); XN = length(x_coef); output = zeros(1:XN); for i = YN+1:N xframe = signal(i:-1:i-(XN-1)); yframe = output(i-1:-1:i-YN); x = xframe .* x_coef; y = yframe .* y_coef; output(i) = sum(x) - sum(y); endendfunction //--------x_coef = [11 22 33];y_coef = [88 99];signal = [1 2 3 4 5];output = compute_iir(signal, x_coef, y_coef);output
pag turn ko ng page 3, nagulat ako, biglang bumilis ang discussion.
me too... sa batch namin, kami ang pinaka unang nakatikim ng dsp na subject. kaya lahat nangangapa pati prof.
sa amin naman alam na ng prof yung DSP pero ang problema sa software naman
fo = 400fs = 44100S = 1A = 10^(9/20)w0 = 2 * 3.1416 * fo / fsalpha = sin(w0)/2 * sqrt( (A + 1/A)*(1/S - 1) + 2 )b0 = A*( (A+1) - (A-1)*cos(w0) + 2*sqrt(A)*alpha )b1 = 2*A*( (A-1) - (A+1)*cos(w0) )b2 = A*( (A+1) - (A-1)*cos(w0) - 2*sqrt(A)*alpha )a0 = (A+1) + (A-1)*cos(w0) + 2*sqrt(A)*alphaa1 = -2*( (A-1) + (A+1)*cos(w0) )a2 = (A+1) + (A-1)*cos(w0) - 2*sqrt(A)*alphax0 = b0/a0x1 = b1/a0x2 = b2/a0y0 = a1/a0y1 = a2/a0
//DSP Tutorial//IIR Filter//By: Regulus Berdinclear;function output = compute_iir(signal, x_coef, y_coef) N = length(signal); YN = length(y_coef); XN = length(x_coef); temp = zeros(1:XN); win1 = progressionbar("Working."); for i = YN+1:N xframe = signal(i:-1:i-(XN-1)); yframe = temp(i-1:-1:i-YN); temp(i) = sum(xframe * x_coef') - sum(yframe * y_coef'); end output = temp; winclose(win1) endfunction //--------x_coef = [+1.04457887924806 -1.94808417101059 +0.91244684520764];y_coef = [-1.95199211029050 +0.95311778517579];clip_start = 5;clip_end = 7;[signal,fs,bits] = wavread('c:/music.wav',[44100*clip_start, 44100*clip_end]);//scale so not to clipsignal = signal * 0.2;left_ch = compute_iir(signal(1,:), x_coef, y_coef);right_ch = compute_iir(signal(2,:), x_coef, y_coef);stereo_out = [left_ch; right_ch];demo = [signal stereo_out];printf("\nPlaying original and the processed sound clip....\n");playsnd(demo,fs);
Another way of looking at this same effect, without extrapolating a center and side signal from the left and right signals, is to simply add the left signal, slightly attenuated and phase inverted, into the right channel and vice-versa.
//prevent stack memory error:stacksize('max');//load the 10-second Billy Jean intro:[signal,fs,bits] = wavread('c:/music.wav');//separate the left and right channel:left_ch = signal(1,:);right_ch = signal(2,:);//define our attenuation factor://try:// atten = 0.50; atten = 0.30;//widen the left and right channel:wide_left_ch = left_ch - atten * right_ch;wide_right_ch = right_ch - atten * left_ch;//build the new stereo signal from the widened channelswide_stereo = [wide_left_ch; wide_right_ch];//let's hear it:playsnd(wide_stereo,fs);
//define a delay function//fs -- the sampling rate from wavread//tsec -- number of seconds of delay (30msec = 0.030sec)function output = delay(signal, fs, tsec) n = length(signal); timedelay = fs * tsec; //number of samples to skip at the beginning temp = zeros(1:n); for i = timedelay:n temp(i) = signal(i-timedelay+1); end output = temp;endfunction//prevent stack memory error:stacksize('max');//load the 10-second Billy Jean intro:[signal,fs,bits] = wavread('c:/music.wav');//separate the left and right channel:left_ch = signal(1,:);right_ch = signal(2,:);//define our attenuation factor://try:// atten = 0.50; atten = 0.30;//widen the left and right channel:wide_left_ch = left_ch - atten * right_ch;wide_right_ch = right_ch - atten * left_ch;//build the new stereo signal from the widened channels//but now we delay the right channel for 10msecwide_stereo = [wide_left_ch; delay(wide_right_ch, fs, 0.01)];//let's hear it:playsnd([signal wide_stereo],fs);
BTW the delay could just be:delay_samples = int(0.01 * fs);delayed_right_ch = [ zeros(1:delay_samples) right_ch(1:length(right_ch) - delay_samples) ];It is faster to slice the array than to make one by one.
normally, sa mga universities, matlab ang ginagamit... kaso mahal talga yan. eto nga scilab or octave pwede naman...