Mercurial > hg > emotion-detection-top-level
comparison Code/Descriptors/Matlab/Common/SpectralCentroid.m @ 4:92ca03a8fa99 tip
Update to ICASSP 2013 benchmark
author | Dawn Black |
---|---|
date | Wed, 13 Feb 2013 11:02:39 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
3:e1cfa7765647 | 4:92ca03a8fa99 |
---|---|
1 function C = SpectralCentroid( signal, windowLength, step, fs) | |
2 | |
3 % function C = SpectralCentroid(signal,windowLength, step, fs) | |
4 % | |
5 % This function computes the spectral centroid feature of an audio signal | |
6 % ARGUMENTS: | |
7 % - signal: the audio samples | |
8 % - windowLength: the length of the window analysis (in number of samples) | |
9 % - step: the step of the window analysis (in number of samples) | |
10 % - fs: the sampling frequency | |
11 % | |
12 % RETURNS: | |
13 % - C: the sequence of the spectral centroid feature | |
14 % | |
15 | |
16 signal = signal / max(abs(signal)); | |
17 curPos = 1; | |
18 L = length(signal); | |
19 numOfFrames = floor((L-windowLength)/step) + 1; | |
20 H = hamming(windowLength); | |
21 m = ((fs/(2*windowLength))*[1:windowLength])'; | |
22 C = zeros(numOfFrames,1); | |
23 for (i=1:numOfFrames) | |
24 window = H.*(signal(curPos:curPos+windowLength-1))'; | |
25 FFT = (abs(fft(window,2*windowLength))); | |
26 FFT = FFT(1:windowLength); | |
27 FFT = FFT / max(FFT); | |
28 C(i) = sum(m.*FFT)/sum(FFT); | |
29 if (sum(window.^2)<0.010) | |
30 C(i) = 0.0; | |
31 end | |
32 curPos = curPos + step; | |
33 end | |
34 C = C / (fs/2); |