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.disgraced;
00024
00025 import com.meapsoft.STFT;
00026 import com.meapsoft.featextractors.FeatureExtractor;
00027
00038 public class TimeCentroid extends FeatureExtractor
00039 {
00040
00041 public double[] features(STFT stft, long startFrame, int length)
00042 {
00043 double[] curFrame;
00044 double[] TimeCentroid = new double[1];
00045 double num0 = 0;
00046 double num1 = 0;
00047 double den = 0;
00048
00049 for(int frame=0; frame<length; frame++)
00050 {
00051 curFrame = stft.getFrame(startFrame+frame);
00052 double timeCenter = stft.fr2Seconds(frame);
00053
00054 for(int band=0; band<stft.getRows(); band++)
00055 {
00056
00057
00058 double p = Math.pow(10,curFrame[band]/10);
00059
00060 num0 += timeCenter*p;
00061
00062 den += p;
00063 }
00064 }
00065
00066 TimeCentroid[0] = num0/den;
00067
00068
00069
00070 TimeCentroid[0] /= stft.fr2Seconds(length);
00071
00072 return TimeCentroid;
00073 }
00074
00075 public String description()
00076 {
00077
00078 return "Computes the center of mass of a chunk's power in time. Gives a simple indication of a chunk's stationarity.";
00079 }
00080 }