Advertisement
richardqa

Ejem1_Algoritmo_Fiesta_Cocktel

May 15th, 2019
925
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 1.49 KB | None | 0 0
  1. % Definición del Modelo
  2. f1 = 1100;              % Frecuencia del tono generador 1 en Hertz
  3. f2 = 2900;              % Frecuencia del tono generador 2 en Hertz
  4. Ts = 1/(40*max(f1,f2)); % Periodo de muestreo en Segundos
  5. dMic = 1;               % Distancias entre micrófonos centrados en el origen, en metros
  6. dSrc = 10;              % Distancias entre generadores de tonos centrados en el origen, en metros
  7. c = 340.29;             % Velocidad del sonido en m/s
  8.  
  9. % Gemerador de Tonos
  10. figure(1);
  11. t = [0:Ts:0.025];
  12. tone1 = sin(2*pi*f1*t);
  13. tone2 = sin(2*pi*f2*t);
  14. plot(t,tone1);
  15. hold on;
  16. plot(t,tone2,'r'); xlabel('time'); ylabel('amplitude'); axis([0 0.005 -1 1]); legend('tone 1', 'tone 2');
  17. hold off;
  18.  
  19. % Mezclar tonos en microfonos
  20. % Asumir atenuación cuadrado inversa de intensidad de sonido
  21. figure(2);
  22. dNear = (dSrc - dMic)/2;
  23. dFar = (dSrc + dMic)/2;
  24. mic1 = 1/dNear*sin(2*pi*f1*(t-dNear/c)) + \
  25.        1/dFar*sin(2*pi*f2*(t-dFar/c));
  26. mic2 = 1/dNear*sin(2*pi*f2*(t-dNear/c)) + \
  27.        1/dFar*sin(2*pi*f1*(t-dFar/c));
  28. plot(t,mic1);
  29. hold on;
  30. plot(t,mic2,'r'); xlabel('time'); ylabel('amplitude'); axis([0 0.005 -1 1]); legend('mic 1', 'mic 2');
  31. hold off;
  32.  
  33. % Uso de SVD para aislar las fuentes de sonido
  34. figure(3);
  35. x = [mic1' mic2'];
  36. [W,s,v]=svd((repmat(sum(x.*x,1),size(x,1),1).*x)*x');
  37. plot(t,v(:,1));
  38. hold on;
  39. maxAmp = max(v(:,1));
  40. plot(t,v(:,2),'r'); xlabel('time'); ylabel('amplitude'); axis([0 0.005 -maxAmp maxAmp]); legend('isolated tone 1', 'isolated tone 2');
  41. hold off;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement