diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Code/Descriptors/Matlab/Common/AudioSpectralBandPower.m	Wed Feb 13 11:02:39 2013 +0000
@@ -0,0 +1,53 @@
+function [ASBP] = AudioSpectralBandPower(raw, fs, noOfFrames, frameLength)
+% this file normalises the frequency spectrum and calculates the spectral
+% power in frequency band 100 - 1000 Hz and in the top 
+x = buffer( raw, frameLength );
+myColor = 'rx';
+
+hiEdgeSamples = getMaxFreq; % the highest fundamental
+loEdgeSamples = getMinFreq; % the lowest fundamental
+
+hiFreqBin = ceil(((frameLength/2)/(fs/2))*hiEdgeSamples);
+loFreqBin = floor(((frameLength/2)/(fs/2))*loEdgeSamples);
+
+bandWidth = hiFreqBin - loFreqBin;
+
+for n = 1:noOfFrames
+    spectrum = abs( fft( x(:,n) ));
+    spectrum = spectrum( 1 : frameLength/2 );
+    % normalise
+%     spectrum = spectrum/max(spectrum);
+    % fundamental frequency band
+    lBand = ( loFreqBin : hiFreqBin );
+    hBand = ( frameLength/2 - ( bandWidth ) : frameLength/2 );
+    lBandPower = sum( spectrum( lBand ));
+    hBandPower = sum( spectrum( hBand ));
+%     gm(n) = nthroot( prod( spectrum ), frameLength );
+%     am(n) = sum( spectrum )/frameLength;
+    ASBP(n) = lBandPower/hBandPower;
+%     subplot(421); plot( x(:,n) );
+%     subplot(422); plot( spectrum ); hold on; 
+%     plot( loFreqBin : hiFreqBin, spectrum( lBand ), 'r' );
+%     plot( hBand, spectrum( hBand ), 'r' ); hold off
+%     
+% %     look at the frame with reference to the surrounding 10 frames
+%     if( n>5 )
+%         startPlot = (n-5)*frameLength+1;
+%         endPlot = (n+5)*frameLength;
+%     else
+%         startPlot = 1;
+%         endPlot = 10*frameLength;
+%     end
+%     subplot(412); plot( raw( startPlot : endPlot ) ); hold on; 
+%     plot( ((n-1)*frameLength+1) - startPlot : (n*frameLength) - startPlot, x(:,n), 'r' ); hold off;
+%     
+%     subplot(425); plot( n, lBandPower, myColor ); hold on;%plot( n, gm(n), myColor ); hold on;
+%     subplot(426); plot( n, hBandPower, myColor ); hold on;%plot( n, am(n), myColor ); hold on;
+%     subplot(414); plot( n, lBandPower / hBandPower, myColor ); hold on;%plot( n, ASF(n), myColor ); hold on;
+% end
+end
+
+
+
+
+