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
00035 public class AvgSpec extends FeatureExtractor
00036 {
00037
00038 public double[] features(STFT stft, long startFrame, int length)
00039 {
00040
00041 double[] avgSpec= new double[stft.getRows()];
00042 double[] curFrame;
00043 double sum = 0;
00044
00045 for(int band=0; band<avgSpec.length; band++)
00046 avgSpec[band] = 0;
00047
00048 for(int frame=0; frame<length; frame++)
00049 {
00050 curFrame = stft.getFrame(startFrame+frame);
00051 for(int band=0; band<avgSpec.length; band++)
00052 {
00053
00054 double tmp = Math.pow(10,curFrame[band]/10) / length;
00055 avgSpec[band] += tmp;
00056 sum += tmp;
00057 }
00058 }
00059
00060 double dBconst = 10/Math.log(10);
00061 for(int band=0; band<avgSpec.length; band++)
00062
00063 avgSpec[band] = dBconst*Math.log(avgSpec[band] / sum);
00064
00065 return avgSpec;
00066 }
00067
00068 public String description()
00069 {
00070 return "Computes the mean spectrum or each chunk.";
00071 }
00072 }