comparison Code/Descriptors/Matlab/MPEG7/detect_AudioPower.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 [ audioPower ] = detect_AudioPower( sampleWavFileName, OVERWRITE )
2 % find the audio power
3
4 % open original power calculation
5 sampleFileName = sampleWavFileName( 1 : length( sampleWavFileName ) - 4 );
6 fileName = [ sampleFileName '_AP.txt'];
7 fileID = fopen( fileName );
8
9 if( (fileID <= 0) || (OVERWRITE) ) %does the file exist?
10 % no
11 disp('WARNING: MISSING AUDIO POWER FILE');
12 %calculate it
13 [x, fs, frameLength, noOfFrames] = openFile( [ sampleFileName '.wav' ] );
14
15 audioPower = calculate_audioPower(x, fs, frameLength, noOfFrames);
16 % frameIndex = 1:1:length(AP);
17 fileID = fopen( fileName, 'w');
18 for i = 1 : noOfFrames
19 fprintf( fileID, '%d %s \n' , i, num2str( audioPower(i,1)) );
20 end
21
22 fclose( fileID );
23 fileID = fopen( fileName );
24 end
25
26 audioPower = fscanf( fileID, '%f', inf );
27 audioPower = audioPower(2:2:end);
28 fclose( fileID );