double[] freq = new double[1];
double[] curFrame;
boolean recalculateSTFT = stft.getRows() != N;
RingMatrix newstft = null;
if (recalculateSTFT)
{
if (preEmphasis)
{
double[] origSamples = stft.getSamples(startFrame, startFrame + length);
double[] preEmphSamples = com.meapsoft.DSP.preEmphasis(origSamples);
newstft = STFT.getSTFT(preEmphSamples, (N - 1) * 2, stft.nhop);
length = newstft.getColumns();
}
else
{
// keep the same number of frames as in stft
newstft = STFT.getSTFT(stft.getSamples(startFrame, startFrame
+ length), (N - 1) * 2, stft.nhop);
length = newstft.getColumns();
}
}
// if there are no features we just bail.
if (length == 0)
return null;
//double wtdsum = 0;
// double sumwts = 0;
// collect average linear spectrum
Arrays.fill(linSpec, 0);
for (int frame = 0; frame < length; frame++)
{
if (!recalculateSTFT)
curFrame = stft.getFrame(startFrame + frame);
else
curFrame = newstft.getColumn(frame);
if (curFrame != null)
{
for (int band = 0; band < linSpec.length; band++)
linSpec[band] += Math.pow(10, curFrame[band] / 10) / length;