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
00033 public class SpectralStability extends FeatureExtractor
00034 {
00035 public double[] features(STFT stft, long startFrame, int length)
00036 {
00037 int numBands = stft.getRows();
00038 double[] currFrame;
00039 double[] prevFrame = null;
00040 double lastEnergy = 0.0;
00041 double[] deltaSum = {0.0};
00042
00043
00044
00045
00046
00047 for (int frame = 0; frame < length; frame++)
00048 {
00049 currFrame = stft.getFrame(startFrame+frame);
00050
00051 for (int bin = 0; bin < numBands; bin++)
00052 {
00053 double delta = 0.0;
00054
00055 if (prevFrame != null)
00056 delta = Math.abs(prevFrame[bin] - currFrame[bin]);
00057
00058
00059
00060
00061
00062 if (delta < 5.0)
00063 delta = 0.0;
00064
00065 deltaSum[0] += delta;
00066 }
00067
00068 prevFrame = currFrame;
00069 }
00070
00071
00072 deltaSum[0] /= length;
00073
00074 return deltaSum;
00075 }
00076
00077 public String description()
00078 {
00079 return "Tracks the stability of the spectral energy within each chunk of sound. "
00080 + "More spectrally stable chunks are more likely to be pitched material.";
00081 }
00082 }