function data2 = multi_reference_adaptive_filter(data, data_ref)
t = 1:min(2^16,length(data)) ;
%t = 1:length(data);

%plot(t,data(t,1))

% pick first 2^14 samples to get best wiener filter coeff
x = data(t);
noise = data_ref(t,:);
N = 150;

    % wiener filtering by multi-channels     
    [x2,w1,w2,w3] = optimum_noise_canceler_multi_ref(x, noise, N);
	% wiener filtering
	v_hat1 = filter(w1,1,data_ref(:,1));
	v_hat2 = filter(w2,1,data_ref(:,2));
	v_hat3 = filter(w3,1,data_ref(:,3));
	data2 = data - v_hat1 - v_hat2 - v_hat3;

  % wiener filtering by one-channel
%     [w,x2] = optimum_noise_canceler(x, noise(:,3), N);
% 	v_hat = filter(w,1,data_ref(:,1));
% 	data2 = data - v_hat;
