00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 package com.meapsoft.featextractors;
00024
00025 import com.meapsoft.STFT;
00026
00034 public class AvgSpecCentroid extends FeatureExtractor
00035 {
00036
00037 public double[] features(STFT stft, long startFrame, int length)
00038 {
00039 double[] curFrame;
00040 double[] avgSpecCentroid = new double[1];
00041 double num = 0;
00042 double den = 0;
00043
00044 for(int frame=0; frame<length; frame++)
00045 {
00046 num = 0; den = 0;
00047 curFrame = stft.getFrame(startFrame+frame);
00048 for(int band=0; band<stft.getRows(); band++)
00049 {
00050 double freqCenter = band*(stft.samplingRate/2)/(stft.getRows()-1);
00051
00052 double p = Math.pow(10,curFrame[band]/10);
00053
00054 num += freqCenter*p;
00055 den += p;
00056 }
00057 avgSpecCentroid[0] += num/(length*den);
00058 }
00059
00060 return avgSpecCentroid;
00061 }
00062
00063 public String description()
00064 {
00065 return "Computes the average spectral center of mass of a chunk's frames.";
00066 }
00067 }