demo1.m 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. % Demonstration program of the C-FICA algorithm used with artificial
  2. % colored sources and real filters
  3. clear all; clc; close all;
  4. % Number of samples
  5. T=5e4;
  6. % Choose the sources type
  7. % 1: MA with uniforms innovation processes
  8. % 2: MA with Laplacian innovation processes
  9. % 3: AR with uniforms innovation processes
  10. % 4: AR with Laplacian innovation processes
  11. choice=2;
  12. switch choice
  13. case 1
  14. s(1,:)=filter(rand(1,10),1,rand(1,T)-.5);
  15. s(2,:)=filter(rand(1,10),1,rand(1,T)-.5);
  16. case 2
  17. s(1,:)=filter(rand(1,10),1,laplace(1,T));
  18. s(2,:)=filter(rand(1,10),1,laplace(1,T));
  19. case 3
  20. s(1,:)=filter(1,[1 -.9],rand(1,T)-.5);
  21. s(2,:)=filter(1,[1 -.9],rand(1,T)-.5);
  22. case 4
  23. s(1,:)=filter(1,[1 -.9],laplace(1,T));
  24. s(2,:)=filter(1,[1 -.9],laplace(1,T));
  25. end
  26. % Definition of the filters by using the following data base:
  27. % B. Gardner and K. Martin. Head Related Transfer Functions of a Dummy Head
  28. % http://sound.media.mit.edu/ica-bench/.
  29. A(:,1,:)=hrtf(30);
  30. A(:,2,:)=hrtf(-80);
  31. % Convolutive mixing process
  32. x=conv_mix(A,s);
  33. % C-FICA algorithm
  34. [Sc,sc,Isc]=cfica(x,1e-16,80,400,'v');
  35. % Computation of the true contributions
  36. xc=contributions(A,s);
  37. % Identification of the source permutations
  38. perm=permutations(xc,sc);
  39. sc=sc(:,perm,:);Isc=Isc(:,perm);
  40. % SIRs computation
  41. SIR1=sir(xc(Isc(1),1,:),sc(Isc(1),1,:))
  42. SIR2=sir(xc(Isc(2),2,:),sc(Isc(2),2,:))
  43. % Plotting of the true (blue) and estimated (red) contributions
  44. figure
  45. hold on
  46. plot(squeeze(xc(Isc(1),1,:)));
  47. plot(squeeze(sc(Isc(1),1,:)),'r');
  48. figure
  49. hold on
  50. plot(squeeze(xc(Isc(2),2,:)));
  51. plot(squeeze(sc(Isc(2),2,:)),'r');