2013-08-28 2 views

답변

3

필요한 것은 시간 - 주파수 현지화 정보입니다. 이것은 Short-time Fourier transform을 사용하여 얻을 수 있습니다. 다른 많은 시간 - 주파수 분석 기술이 있습니다. STFT가 가장 간단하고 따라서 좋은 출발점입니다. 다음은 개념을 이해하는 데 도움이 간단한 코드입니다

% Parameters 
Fs = 44100; % Sample rate (44100 Hz) 
t = 0:1/Fs:5; % Time instances 
t1 = 5; % End time of signal, 5 secs 
f0 = 440; % frequency swiped from 440 Hz 
f1 = 880; % to 880 Hz 

% Signal generation 
audio = chirp(t,f0,t1,f1); 
% wavplay(audio,Fs) % to play the audio 


% Signal analysis 
window = 2050; % Should be minimum twice the maximum frequency we want to analyze 
noverlap = 1025; % 50% overlap 
nfft = 44100; 

[S,F,T,P] = spectrogram(audio,window,noverlap,nfft,Fs); % Spectrogram takes the STFT of the signal 
% P matrix contains the power spectral density of each segment of the STFT 

% Plotting results 
imagesc(real(S)) % frequency-time Plot of the signal 
ylim([0 1000]) 
xlabel('Time (secs)') 
ylabel('Frequency (Hz)') 
title('Time-Frequency plot of a Audio signal') 

샘플 번호를 얻으려면, 당신은 당신의 관심 주파수가 표시되는 시간 인스턴스를 찾아 샘플을 계산하기 위해 샘플링 주파수를 사용할 필요가 번호.

P는 파워 스펙트럼 밀도 매트릭스입니다. y 축은 주파수이고, x 축은 시간이며, 각 순간마다 각 주파수에 의해 기여되는 전력이이 행렬에 저장됩니다. 전체 행렬에서 가장 큰 값을 갖는 요소가 필요합니다. 아래 코드는 작동합니다 :

[maxElement, maxElementTimeIndex] = max(max(P, [], 1)); % max(P, [], 1) finds maximum power for each time instance, max(max(P,[],1)) finds maximum for the entire 2D matrix. 
maxPoweredSampleInAudioSignal = (maxElementTimeIndex-1) * Fs; % This calculation is made within the limitations of STFT, so approximately here the maximum power for any frequency is present 
+0

f0와 f1을 어떻게 결정합니까? '주파수를 스 ​​와이프'한다는 것은 무엇을 의미합니까? 어떤 물체가 가장 큰 힘을 가진 주파수를 저장합니까? 즉 관심의 주파수. 그리고 어떻게 그 객체로부터 "시간 인스턴스"를 얻을 수 있습니까? 줄거리를 가져 주셔서 감사하지만 실제 값을 원합니다. – Matt1993

+0

f0 및 f1은 챠프 신호에서 최저 및 최고 주파수입니다. 이것은 데모 용입니다. 사운드 파일을 처리 할 때. f0와 f1에 대해 걱정할 필요는 없지만 실험을 위해 녹음 한 사운드 (일반적으로 순수한 톤)가 도플러 효과를 경험하는 데 걸리는 주파수 범위를 알아야 할 수도 있습니다. [nfft 값] (http://www.mathworks.in/help/signal/ref/spectrogram.html)을 찾으려면이 범위가 필요합니다. – Prashanth

관련 문제