Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. close all;
  2. clear all;
  3. clc;
  4. figure(1);
  5. [audio_file1, Fs] = audioread('iPhone_new.wav');
  6. L = size(audio_file1,1);
  7. Ts = 1/Fs; % Sampling Interval
  8. Fn = Fs/2; % Nyquist Frequency
  9. FT_af = fft(audio_file1)/L; % Fourier Transform
  10. Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
  11. Iv = 1:numel(Fv);
  12. plot(Fv, abs(FT_af(Iv,1))*2)
  13. hold on
  14.  
  15.  
  16. figure(2)
  17. [audio_file2, Fs] = audioread('nokia_recorded_10.wav');
  18. L = size(audio_file2,1);
  19. Ts = 1/Fs; % Sampling Interval
  20. Fn = Fs/2; % Nyquist Frequency
  21. FT_af = fft(audio_file2)/L; % Fourier Transform
  22. Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
  23. Iv = 1:numel(Fv);
  24. plot(Fv, abs(FT_af(Iv,1))*2)
  25. hold on
  26.  
  27. figure(3)
  28. [audio_file3, Fs] = audioread('redmi_recorded_10.wav');
  29. L = size(audio_file3,1);
  30. Ts = 1/Fs; % Sampling Interval
  31. Fn = Fs/2; % Nyquist Frequency
  32. FT_af = fft(audio_file3)/L; % Fourier Transform
  33. Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
  34. Iv = 1:numel(Fv);
  35. plot(Fv, abs(FT_af(Iv,1))*2)
  36. hold on
  37.  
  38. micro = audiorecorder;
  39. disp('Recording sample')
  40. recordblocking(micro, 10);
  41. disp('End of Recording');
  42. data = getaudiodata(micro,'uint8');
  43. audiowrite('template1.wav',data,8000);
  44.  
  45.  
  46. [audio_file, Fs] = audioread("template1.wav");
  47. L = size(audio_file,1);
  48. Ts = 1/Fs; % Sampling Interval
  49. Fn = Fs/2; % Nyquist Frequency
  50. FT_af = fft(audio_file)/L; % Fourier Transform
  51. Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
  52. Iv = 1:numel(Fv); % Index Vector
  53. [PksL,LocsL] = findpeaks(abs(FT_af(Iv,1))*2, 'MinPeakHeight',1E-2);
  54. figure
  55. plot(Fv, abs(FT_af(Iv,1))*2)
  56. hold on
  57. plot(Fv(LocsL), PksL, '^r', 'MarkerFaceColor','r')
  58. playerObj = audioplayer(audio_file,Fs);
  59. play(playerObj,length(audio_file));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement