Mercurial > hg > emotion-detection-top-level
comparison Code/Descriptors/Matlab/Common/AudioSpectralBandPower.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 [ASBP] = AudioSpectralBandPower(raw, fs, noOfFrames, frameLength) | |
| 2 % this file normalises the frequency spectrum and calculates the spectral | |
| 3 % power in frequency band 100 - 1000 Hz and in the top | |
| 4 x = buffer( raw, frameLength ); | |
| 5 myColor = 'rx'; | |
| 6 | |
| 7 hiEdgeSamples = getMaxFreq; % the highest fundamental | |
| 8 loEdgeSamples = getMinFreq; % the lowest fundamental | |
| 9 | |
| 10 hiFreqBin = ceil(((frameLength/2)/(fs/2))*hiEdgeSamples); | |
| 11 loFreqBin = floor(((frameLength/2)/(fs/2))*loEdgeSamples); | |
| 12 | |
| 13 bandWidth = hiFreqBin - loFreqBin; | |
| 14 | |
| 15 for n = 1:noOfFrames | |
| 16 spectrum = abs( fft( x(:,n) )); | |
| 17 spectrum = spectrum( 1 : frameLength/2 ); | |
| 18 % normalise | |
| 19 % spectrum = spectrum/max(spectrum); | |
| 20 % fundamental frequency band | |
| 21 lBand = ( loFreqBin : hiFreqBin ); | |
| 22 hBand = ( frameLength/2 - ( bandWidth ) : frameLength/2 ); | |
| 23 lBandPower = sum( spectrum( lBand )); | |
| 24 hBandPower = sum( spectrum( hBand )); | |
| 25 % gm(n) = nthroot( prod( spectrum ), frameLength ); | |
| 26 % am(n) = sum( spectrum )/frameLength; | |
| 27 ASBP(n) = lBandPower/hBandPower; | |
| 28 % subplot(421); plot( x(:,n) ); | |
| 29 % subplot(422); plot( spectrum ); hold on; | |
| 30 % plot( loFreqBin : hiFreqBin, spectrum( lBand ), 'r' ); | |
| 31 % plot( hBand, spectrum( hBand ), 'r' ); hold off | |
| 32 % | |
| 33 % % look at the frame with reference to the surrounding 10 frames | |
| 34 % if( n>5 ) | |
| 35 % startPlot = (n-5)*frameLength+1; | |
| 36 % endPlot = (n+5)*frameLength; | |
| 37 % else | |
| 38 % startPlot = 1; | |
| 39 % endPlot = 10*frameLength; | |
| 40 % end | |
| 41 % subplot(412); plot( raw( startPlot : endPlot ) ); hold on; | |
| 42 % plot( ((n-1)*frameLength+1) - startPlot : (n*frameLength) - startPlot, x(:,n), 'r' ); hold off; | |
| 43 % | |
| 44 % subplot(425); plot( n, lBandPower, myColor ); hold on;%plot( n, gm(n), myColor ); hold on; | |
| 45 % subplot(426); plot( n, hBandPower, myColor ); hold on;%plot( n, am(n), myColor ); hold on; | |
| 46 % subplot(414); plot( n, lBandPower / hBandPower, myColor ); hold on;%plot( n, ASF(n), myColor ); hold on; | |
| 47 % end | |
| 48 end | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 |
