Attachment 'umfbss.m'

Download

   1 % ========================================================================
   2 %
   3 % A simple offline implementation of
   4 %
   5 % Unconstrained Multivariate Frequency-Domain ICA for Convolutive Mixtures
   6 %
   7 % Herbert Buchner, Apr. 2011                           www.buchner-net.com
   8 %
   9 % ========================================================================
  10 
  11 %-------------------------------------------------------
  12 %-------------parameters for the algorithm--------------
  13 %-------------------------------------------------------
  14 cfg.nmic = 2;        % number of microphones
  15 cfg.nsrc = 2;        % number of sources
  16 %cfg.fs = 16000;      % sampling frequency of the microphone signals
  17 
  18 cfg.fftsize = [1024 512];  % frameSize, shift
  19 cfg.bins = cfg.fftsize(1)/2+1;
  20 
  21 cfg.loops = 250;     % number of iterations for ICA part
  22 cfg.eta = 0.01;      % stepsize
  23 cfg.delta = eps;     % regularization for multivariate score function
  24 
  25 %---------------------------------------------------------------------
  26 %----------------load microphone signals x----------------------------
  27 %---------------------------------------------------------------------
  28 fprintf('reading inputs...\n')
  29 for p=1:cfg.nmic
  30   [x(:,p), cfg.fs, tmp] = wavread(strcat('x', num2str(p), '.wav'));
  31 end
  32 
  33 %---------------------------------------------------------------------
  34 %------------calculate frequency-domain version of x------------------
  35 %---------------------------------------------------------------------
  36 fprintf('STFT:   frameSize = %d, shift = %d\n', cfg.fftsize(1), cfg.fftsize(2));
  37 hwindow = hanning(cfg.fftsize(1), 'periodic');
  38 
  39 for p=1:cfg.nmic
  40    tmp = sfft(x(:,p), hwindow, cfg.fftsize(2));
  41    X(p,:,:) = shiftdim( tmp(1:cfg.bins,:), 1 );   % X = zeros(cfg.nmic, nFrame, cfg.bins);
  42 end
  43 nFrame = size(X,2);  % number of frames
  44 
  45 % normalization of microphone signals
  46 for p = 1:cfg.nmic
  47    for f =1:cfg.bins
  48        X(p,:,f) = X(p,:,f)- mean(squeeze(X(p,:,f)));
  49    end
  50 end
  51 
  52 %---------------------------------------------------------------------
  53 %--------------------Compute demixing filter W------------------------
  54 %---------------------------------------------------------------------
  55 W = zeros(cfg.bins, cfg.nsrc, cfg.nmic);
  56 Y = zeros(cfg.nsrc, nFrame, cfg.bins);
  57 Yf = [];
  58 
  59 %---initialization---
  60 Wt = zeros(cfg.fftsize(1),cfg.nsrc,cfg.nmic);
  61 for p = 1:cfg.nmic
  62    Wt(1,p,p) = 1;
  63 end
  64 W = fft(Wt,[],1);
  65 
  66 
  67 %------------main loop----------------
  68 for i=1:cfg.loops
  69    fprintf('Estimation:    iteration %d of %d\nM', i, cfg.loops);
  70 
  71    for f=1:cfg.bins,
  72        Wf = squeeze(W(f,:,:));
  73        Xf = X(:,:,f);
  74        Yf = Wf * Xf;    % circular convolution to obtain output signals
  75        Y(:,:,f) = Yf;
  76    end
  77 
  78    % !!!!!!! norm necessary for MULTIvariate pdf !!!!!!! 
  79    phiYfvec = sqrt(sum((abs(Y).^2),3));
  80 
  81    for f=1:cfg.bins
  82        Wf = squeeze(W(f,:,:));
  83        Xf = X(:,:,f);
  84        Yf = Y(:,:,f);
  85 
  86        % !!!!!!! nonlinearity based on UNIvariate pdf !!!!!!! 
  87        phiYf = sqrt(cfg.bins)*Yf./(abs(Yf)+cfg.delta);
  88 
  89        % !!!!!!! nonlinearity based on MULTIvariate pdf !!!!!!! 
  90 %        phiYf = sqrt(cfg.bins)*Yf./(phiYfvec+cfg.delta);
  91 
  92        %-------------------------------------
  93        % natural gradient (holonomic version)
  94        %-------------------------------------
  95        Syy_norm = (phiYf * Yf') ./ nFrame;
  96        Wf = Wf + cfg.eta * ( eye(cfg.nsrc)-Syy_norm ) * Wf;
  97 
  98        %-------------------------------------------------
  99        % Minimal distortion principle (Matsuoka, ICA2001)
 100        %-------------------------------------------------
 101        Wfinv = pinv(Wf);
 102        W(f,:,:) = diag(diag(Wfinv)) * Wf;
 103    end
 104 end
 105 fprintf('\n');
 106 
 107 %---------------------------------------------------------------------
 108 %----------Compute FIR demixing filters from freq-domain W---------------------
 109 %---------------------------------------------------------------------
 110 Wt = real(ifft( [W(1:cfg.bins,:,:); conj(W(cfg.bins-1:-1:2,:,:))], cfg.fftsize(1)));
 111 Wt = circshift(Wt,[cfg.fftsize(1)/2,0,0]);  % put peaks in the middle of filter
 112 
 113 %---------------------------------------------------------------------
 114 %---------Compute output signals--------------------------------------
 115 %---------------------------------------------------------------------
 116 for p=1:cfg.nsrc,
 117  % make initial y(:,p) with the first microphone
 118  y(:,p) = fftfilt(Wt(:,p,1), x(:,1));
 119  % loop for the second or more.  Assume the lengths of x{q} are the same.
 120  for q=2:cfg.nmic,
 121    y(:,p) = y(:,p) + fftfilt(Wt(:,p,q), x(:,q));
 122  end
 123  % save output signals
 124  wavwrite(y(:,p)./(1.01*max(abs(y(:,p)))), cfg.fs, strcat('y', num2str(p), '.wav'))
 125 end

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2011-06-22 07:45:04, 2873.9 KB) [[attachment:bio_intro.pdf]]
  • [get | view] (2011-05-02 16:51:13, 1341.1 KB) [[attachment:buchner_chap2007.pdf]]
  • [get | view] (2011-04-19 12:05:37, 3719.0 KB) [[attachment:cca_lecture.pdf]]
  • [get | view] (2011-07-20 11:25:53, 1778.9 KB) [[attachment:chemo_lecture.pdf]]
  • [get | view] (2011-05-16 22:58:50, 723.1 KB) [[attachment:deep_lecture.pdf]]
  • [get | view] (2011-04-11 15:08:58, 95.6 KB) [[attachment:full_sheet01.pdf]]
  • [get | view] (2011-04-19 11:33:46, 130.0 KB) [[attachment:full_sheet02.pdf]]
  • [get | view] (2011-05-02 16:53:54, 123.4 KB) [[attachment:full_sheet03.pdf]]
  • [get | view] (2011-05-10 10:03:36, 112.2 KB) [[attachment:full_sheet04.pdf]]
  • [get | view] (2011-05-17 09:43:04, 34.8 KB) [[attachment:full_sheet05.pdf]]
  • [get | view] (2011-05-23 12:18:47, 95.7 KB) [[attachment:full_sheet06.pdf]]
  • [get | view] (2011-05-30 13:35:32, 98.3 KB) [[attachment:full_sheet07.pdf]]
  • [get | view] (2011-06-07 15:23:13, 125.3 KB) [[attachment:full_sheet08.pdf]]
  • [get | view] (2011-06-21 08:43:34, 164.4 KB) [[attachment:full_sheet09.pdf]]
  • [get | view] (2011-07-05 09:39:18, 100.4 KB) [[attachment:full_sheet10.pdf]]
  • [get | view] (2011-05-31 20:33:20, 2656.3 KB) [[attachment:ids_lect.pdf]]
  • [get | view] (2011-05-24 15:25:30, 2121.4 KB) [[attachment:kern_struct.pdf]]
  • [get | view] (2011-06-14 10:50:39, 1169.4 KB) [[attachment:mkl_intro.pdf]]
  • [get | view] (2011-05-04 09:54:42, 512.3 KB) [[attachment:ml2_bss.pdf]]
  • [get | view] (2011-05-17 09:43:15, 7656.4 KB) [[attachment:mnist.mat]]
  • [get | view] (2011-06-07 18:29:45, 192.5 KB) [[attachment:opt_intro.pdf]]
  • [get | view] (2011-05-17 09:43:21, 1.7 KB) [[attachment:rbm.m]]
  • [get | view] (2011-05-02 16:54:43, 0.7 KB) [[attachment:sfft.m]]
  • [get | view] (2011-05-30 13:37:07, 4.3 KB) [[attachment:sheet07.m]]
  • [get | view] (2011-06-21 08:43:43, 1.1 KB) [[attachment:sheet09.m]]
  • [get | view] (2011-05-17 09:43:25, 0.1 KB) [[attachment:sigmoid.m]]
  • [get | view] (2011-06-21 08:43:50, 129.6 KB) [[attachment:splice-test-data.txt]]
  • [get | view] (2011-06-21 08:43:55, 5.4 KB) [[attachment:splice-test-label.txt]]
  • [get | view] (2011-06-21 08:44:00, 59.6 KB) [[attachment:splice-train-data.txt]]
  • [get | view] (2011-06-21 08:44:05, 2.5 KB) [[attachment:splice-train-label.txt]]
  • [get | view] (2011-04-18 07:30:47, 1515.8 KB) [[attachment:ssa_data.mat]]
  • [get | view] (2011-04-18 07:28:13, 585.7 KB) [[attachment:ssa_lecture.pdf]]
  • [get | view] (2011-04-18 07:30:20, 7.4 KB) [[attachment:ssa_simple.m]]
  • [get | view] (2011-07-05 11:05:27, 1202.4 KB) [[attachment:structured_lecture.pdf]]
  • [get | view] (2011-05-30 13:36:38, 1217.5 KB) [[attachment:stud-data.mat.gz]]
  • [get | view] (2011-04-18 07:29:43, 1.0 KB) [[attachment:tkcca_example.m]]
  • [get | view] (2011-04-18 07:29:54, 4.1 KB) [[attachment:tkcca_simple.m]]
  • [get | view] (2011-04-18 07:30:07, 150.9 KB) [[attachment:tkcca_toy_data.mat]]
  • [get | view] (2011-05-02 16:51:28, 4.5 KB) [[attachment:umfbss.m]]
  • [get | view] (2011-05-02 16:03:05, 531.3 KB) [[attachment:x1.wav]]
  • [get | view] (2011-05-02 16:03:12, 531.3 KB) [[attachment:x2.wav]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.