Main Page   Packages   Class Hierarchy   Compound List   File List   Compound Members  

GeometricAvgSpec.java

00001 /*
00002  *  Copyright 2006-2007 Columbia University.
00003  *
00004  *  This file is part of MEAPsoft.
00005  *
00006  *  MEAPsoft is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License version 2 as
00008  *  published by the Free Software Foundation.
00009  *
00010  *  MEAPsoft is distributed in the hope that it will be useful, but
00011  *  WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  *  General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with MEAPsoft; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
00018  *  02110-1301 USA
00019  *
00020  *  See the file "COPYING" for the text of the license.
00021  */
00022 
00023 package com.meapsoft.disgraced;
00024 
00025 import com.meapsoft.STFT;
00026 import com.meapsoft.featextractors.FeatureExtractor;
00027 
00036 public class GeometricAvgSpec extends FeatureExtractor 
00037 {
00038         
00039     public double[] features(STFT stft, long startFrame, int length) 
00040     {
00041 
00042         double[] avgSpec= new double[stft.getRows()];
00043         double[] curFrame;
00044         double sum = 0;
00045         
00046         for(int band=0; band<avgSpec.length; band++)
00047             avgSpec[band] = 0;
00048         
00049         for(int frame=0; frame<length; frame++) 
00050         {
00051             curFrame = stft.getFrame(startFrame+frame);
00052             for(int band=0; band<avgSpec.length; band++) 
00053             {
00054                 double tmp = curFrame[band] / length;
00055                 avgSpec[band] += tmp;
00056                 sum += tmp;
00057             }
00058         }
00059 
00060         for(int band=0; band<avgSpec.length; band++)
00061             avgSpec[band] = avgSpec[band] / sum;
00062         
00063         return avgSpec;
00064     }
00065 
00066         public String description()
00067         {
00068                 return "I am a generic FeatureExtractor";
00069         }
00070 }

Generated on Tue Feb 6 19:02:26 2007 for MEAPsoft by doxygen1.2.18