Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- close all;
- clear all;
- clc;
- figure(1);
- [audio_file1, Fs] = audioread('iPhone_new.wav');
- L = size(audio_file1,1);
- Ts = 1/Fs; % Sampling Interval
- Fn = Fs/2; % Nyquist Frequency
- FT_af = fft(audio_file1)/L; % Fourier Transform
- Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
- Iv = 1:numel(Fv);
- plot(Fv, abs(FT_af(Iv,1))*2)
- hold on
- figure(2)
- [audio_file2, Fs] = audioread('nokia_recorded_10.wav');
- L = size(audio_file2,1);
- Ts = 1/Fs; % Sampling Interval
- Fn = Fs/2; % Nyquist Frequency
- FT_af = fft(audio_file2)/L; % Fourier Transform
- Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
- Iv = 1:numel(Fv);
- plot(Fv, abs(FT_af(Iv,1))*2)
- hold on
- figure(3)
- [audio_file3, Fs] = audioread('redmi_recorded_10.wav');
- L = size(audio_file3,1);
- Ts = 1/Fs; % Sampling Interval
- Fn = Fs/2; % Nyquist Frequency
- FT_af = fft(audio_file3)/L; % Fourier Transform
- Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
- Iv = 1:numel(Fv);
- plot(Fv, abs(FT_af(Iv,1))*2)
- hold on
- micro = audiorecorder;
- disp('Recording sample')
- recordblocking(micro, 10);
- disp('End of Recording');
- data = getaudiodata(micro,'uint8');
- audiowrite('template1.wav',data,8000);
- [audio_file, Fs] = audioread("template1.wav");
- L = size(audio_file,1);
- Ts = 1/Fs; % Sampling Interval
- Fn = Fs/2; % Nyquist Frequency
- FT_af = fft(audio_file)/L; % Fourier Transform
- Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
- Iv = 1:numel(Fv); % Index Vector
- [PksL,LocsL] = findpeaks(abs(FT_af(Iv,1))*2, 'MinPeakHeight',1E-2);
- figure
- plot(Fv, abs(FT_af(Iv,1))*2)
- hold on
- plot(Fv(LocsL), PksL, '^r', 'MarkerFaceColor','r')
- playerObj = audioplayer(audio_file,Fs);
- play(playerObj,length(audio_file));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement