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 AvgSpecFlatness extends FeatureExtractor
00035 {
00036
00037 public double[] features(STFT stft, long startFrame, int length)
00038 {
00039 double[] curFrame;
00040 double[] avgSpecFlatness= new double[1];
00041 double num = 1;
00042 double den = Double.MIN_VALUE;
00043
00044 avgSpecFlatness[0] = 0;
00045
00046 for(int frame=0; frame<length; frame++)
00047 {
00048 num = 0; den = 0;
00049 int nband = stft.getRows();
00050 curFrame = stft.getFrame(startFrame+frame);
00051 for(int band = 0; band < nband; band++)
00052 {
00053
00054 double p = Math.pow(10,curFrame[band]/10);
00055
00056 num += Math.log(p)/nband;
00057 den += p/nband;
00058 }
00059 avgSpecFlatness[0] += Math.exp(num)/(den*length);
00060 }
00061
00062 return avgSpecFlatness;
00063 }
00064
00065 public String description()
00066 {
00067 return "Provides a measure of the peakiness of the chunks average spectrum.";
00068 }
00069 }