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