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
00035 public class TimeFreqCentroid extends FeatureExtractor
00036 {
00037
00038 public double[] features(STFT stft, long startFrame, int length)
00039 {
00040 double[] curFrame;
00041 double[] TimeFreqCentroid = new double[2];
00042 double num0 = 0;
00043 double num1 = 0;
00044 double den = 0;
00045
00046 for(int frame=0; frame<length; frame++)
00047 {
00048 curFrame = stft.getFrame(startFrame+frame);
00049 double timeCenter = stft.fr2Seconds(frame);
00050
00051 for(int band=0; band<stft.getRows(); band++)
00052 {
00053 double freqCenter = band*(stft.samplingRate/2)/(stft.getRows()-1);
00054
00055 double p = Math.pow(10,curFrame[band]/10);
00056
00057 num0 += timeCenter*p;
00058 num1 += freqCenter*p;
00059 den += p;
00060 }
00061 }
00062
00063 TimeFreqCentroid[0] = num0/den;
00064 TimeFreqCentroid[1] = num1/den;
00065
00066 return TimeFreqCentroid;
00067 }
00068
00069 public String description()
00070 {
00071 return "Computes the center of mass in the time/frequency plane of each chunk's spectrogram.";
00072 }
00073 }