Hi all,
The code I have written I think is correct. I am comparing two sound sources and not getting the desired outcome, one of the sound sources has a higher frequency content when it should be lower! I think there is something wrong with my Fourier Transform?
I have attached the two files post audio read saved as Bolt and Squid.
My code is as follows, any help would be much appreciated:
read in the .wav file
[y,fs]= audioread('CD152DEP1_20170829_160000.wav');% y=samples
% fs=sampling frequency
Starttime=0;Endtime=30;time= Endtime-Starttime;Sample=time.*fs;Starty=Starttime.*fsEndy=Endtime.*fst=linspace(Starttime,Endtime,Sample); %linspace function that creates evenly spaced time vector
y2=y((Starty+1):Endy,:);figure;subplot(3,1,1)plot(t,y2);xlabel('Time (seconds)') ylabel('Amplitude')title('Day 1 Bolt 16.00') hold on %a is normalised into seconds for plot
%xlim([0 350])
%b= 45/350
%X = [b, b];
%Y = [0.8,0.5];
%a = annotation('textarrow',X,Y,'String','Lander crossing');
%%frequnecy analysis
Nfft=2048;f=linspace(0,fs,Nfft); %f is freq vector, 0 starting freq, fs is end freq, Nfft is length of
%vector
G=abs(fft(y2,Nfft));%G is the fft of y in the same number of points as the sample
%calculating the phase
phase = unwrap(angle(fft(y,Nfft)));%subplot of phase and freq
subplot(3,1,2),plot((f(1:Nfft/2)),(G(1:Nfft/2)))xlabel('Frequency(Hz)') ylabel('Amplitude')xlim([0 1000])hold on subplot(3,1,3), plot((f(1:Nfft/2)),(phase(1:Nfft/2)))xlabel('Frequency(Hz)') ylabel('Phase(radians)')xlim([0 1000])
Best Answer