Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Detetcting time difference between peaks in 3D-Spectrogramm

조회 수: 1 (최근 30일)
Denny Muttathil
Denny Muttathil 2017년 1월 31일
마감: MATLAB Answer Bot 2021년 8월 20일
I did a STFT on my audio signal. Then i noticed, i have very high amlitudes in a range between 1-1000hz. So i defined 3 frequency bands. Afterwards, i made waterfall-diagram by using the function "waterfall". I don't want to explain too much, since it would take so long. I recommend you, to try this code yourself. Just take any small wav-file, you can find and let it run on the computer. If you have questions concerning, my code please ask me in the comments. My wav-file has a duration from 16 seconds. At the beginning, i have very high peaks (amplitudes, i believe so). Is it possible to measure the time distance between those peaks and how can I write or do that?
%%MATLAB
%_________________________________________
[y,fs]=audioread('Undertale - Megalovania.wav');
% audioread = Read WAV-file
% y = Vector, which contains audio signal
% fs = Sample Rate
% 'dontstopmenow' = WAV-file
%_________________________________________
%PARAMETER FOR STFT
%_________________________________________
t_seg=0.09; % Length of segment in ms
fftlen = 4096; %FFT-Points
%Defining the length of my frequency bands
f_LOW= 1:200; % contain lower frequencies
f_MEDIUM= 201:600; % contain medium frequencies
f_HIGH= 601:1000; % contain higher frequencies
%_______________________________________________________
segl =floor(t_seg*fs);
% Length of segment, on which we use the fft
% "floor" rounds off the result
windowshift=round(segl/2);
% size of window which goes to the next segment
window=hann(segl);
%hann function
window=window.';
% From a row vector to a column vector
si=1;
%Start index
ei=segl;
%End index
N=floor( length(y)/windowshift - 1);
% Number of time segements in audio signal
f1=figure;
% New window
f=0:1:fftlen-1;
f=f/fftlen*fs;
% frequency vector
Ya=zeros(1,fftlen);
Yb = NaN(N, fftlen/2);
%Plotting time segments!
for m= 1:1:N
y_a = y(si:ei);
y_a= y_a.*window;
Ya=fft(y_a, fftlen);
Ya=abs(Ya(1:end/2));
%One-sided-spectrum
Yb(m,:) = Ya;
drawnow; %Updates graphical objects
%figure(f1);
%%L,M,H - Bands
y_low = Ya(f_LOW);
y_medium = Ya(f_MEDIUM);
y_high = Ya(f_HIGH);
si=si+windowshift;
% start index updated
ei=ei+windowshift;
% end index updated
figure(f1);
waterfall(f(f_LOW), (1:N)*windowshift/fs, Yb(:,f_LOW));
xlabel('Frequency (Hz)');
ylabel('Time (s)');
set(gca,'YLim',[0 16])
set(gca,'YTick',0:2:16)
end

답변 (0개)

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by