Doing a fft on a audio file

85 ビュー (過去 30 日間)
Jack Walker
Jack Walker 2016 年 10 月 7 日
回答済み: Mallikarjun Yadawad 2023 年 12 月 5 日
Hello, dear community! Really would appreciate a solution to my problem. i want to do a fft on a audio file, which duration last about 10 seconds. My goal is to make a fft on each seconds (1-10) and make it visible in a frequency- and time domain. So i can see, what happened in the last seconds and see the changes. Concerning the audio file, I used the program audacity, in which i took a song and cut out 10 seconds. Btw i am more or less a newbie on matlab programming, because i still lack the experiences. (i am only 16)
Here my code
Pretty sure, i need to do more, but i don't know how to go on. The code provided here, is only my structure, which i want to extend.
%Matlab-Programming
[y,fs]=wavread('UnchainMyHeart');
%wavread = reads WAV-file
%y = samples
%fs = sampling frequency
%'UnchainMyHeart' = WAV-file
t=linspace(0,length(y)/fs,length(y));
%linspace = creating time vector
%0= start time
%length(y)/fs = end time
%length(y) = number of samples in y
plot(t,y)
Nfft=1024;
%Nfft = length of fft
f=linspace(0,fs,Nfft);
%f =creating frequency vector
%0 = start time
%fs = End time
%Nfft = Length of the frequency vector
X=abs(fft(y,Nfft));
%G = the fft of the samples y in 1024 points
figure ; plot(f(1:Nfft/2),X(1:Nfft/2))

回答 (2 件)

Bert
Bert 2016 年 10 月 7 日
Hi,
you should have a look at the function "spectrogram" ( https://nl.mathworks.com/help/signal/ref/spectrogram.html ), which does exactly what you're trying to implement.
good luck!

Mallikarjun Yadawad
Mallikarjun Yadawad 2023 年 12 月 5 日
%Matlab-Programming
[y,fs]=wavread('UnchainMyHeart');
%wavread = reads WAV-file
%y = samples
%fs = sampling frequency
%'UnchainMyHeart' = WAV-file
t=linspace(0,length(y)/fs,length(y));
%linspace = creating time vector
%0= start time
%length(y)/fs = end time
%length(y) = number of samples in y
plot(t,y)
Nfft=1024;
%Nfft = length of fft
f=linspace(0,fs,Nfft);
%f =creating frequency vector
%0 = start time
%fs = End time
%Nfft = Length of the frequency vector
X=abs(fft(y,Nfft));
%G = the fft of the samples y in 1024 points
figure ; plot(f(1:Nfft/2),X(1:Nfft/2))

カテゴリ

Help Center および File ExchangeFourier Analysis and Filtering についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by