Program: 20078
Project: 20078
Buggy source:
/** 
 * Build a mel filterbank with the parameters given. Each filter will be shaped as a triangle. The triangles overlap so that they cover the whole frequency range requested. The edges of a given triangle will be by default at the center of the  neighboring triangles.
 * @param numberDftPoints number of points in the power spectrum
 * @param numberFilters number of filters in the filterbank
 * @param minFreq lowest frequency in the range of interest
 * @param maxFreq highest frequency in the range of interest
 * @throw IllegalArgumentException
 */
private void buildFilterbank(int numberDftPoints,int numberFilters,double minFreq,double maxFreq) throws IllegalArgumentException {
  double minFreqMel;
  double maxFreqMel;
  double deltaFreqMel;
  double[] leftEdge=new double[numberFilters];
  double[] centerFreq=new double[numberFilters];
  double[] rightEdge=new double[numberFilters];
  double nextEdgeMel;
  double nextEdge;
  double initialFreqBin;
  double deltaFreq;
  this.filter=new MelFilter[numberFilters];
  if (numberDftPoints == 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  deltaFreq=(double)sampleRate / numberDftPoints;
  if (numberFilters < 1) {
    throw new IllegalArgumentException("String_Node_Str" + numberFilters);
  }
  minFreqMel=linToMelFreq(minFreq);
  maxFreqMel=linToMelFreq(maxFreq);
  deltaFreqMel=(maxFreqMel - minFreqMel) / (numberFilters + 1);
  leftEdge[0]=setToNearestFrequencyBin(minFreq,deltaFreq);
  nextEdgeMel=minFreqMel;
  for (int i=0; i < numberFilters; i++) {
    nextEdgeMel+=deltaFreqMel;
    nextEdge=melToLinFreq(nextEdgeMel);
    centerFreq[i]=setToNearestFrequencyBin(nextEdge,deltaFreq);
    if (i > 0) {
      rightEdge[i - 1]=centerFreq[i];
    }
    if (i < numberFilters - 1) {
      leftEdge[i + 1]=centerFreq[i];
    }
  }
  nextEdgeMel=nextEdgeMel + deltaFreqMel;
  nextEdge=melToLinFreq(nextEdgeMel);
  rightEdge[numberFilters - 1]=setToNearestFrequencyBin(nextEdge,deltaFreq);
  for (int i=0; i < numberFilters; i++) {
    initialFreqBin=setToNearestFrequencyBin(leftEdge[i],deltaFreq);
    if (initialFreqBin < leftEdge[i]) {
      initialFreqBin+=deltaFreq;
    }
    this.filter[i]=new MelFilter(leftEdge[i],centerFreq[i],rightEdge[i],initialFreqBin,deltaFreq);
  }
}

Fixed version (ground truth):
/** 
 * Build a mel filterbank with the parameters given. Each filter will be shaped as a triangle. The triangles overlap so that they cover the whole frequency range requested. The edges of a given triangle will be by default at the center of the  neighboring triangles.
 * @param numberDftPoints number of points in the power spectrum
 * @param numberFilters number of filters in the filterbank
 * @param minFreq lowest frequency in the range of interest
 * @param maxFreq highest frequency in the range of interest
 * @throws IllegalArgumentException
 */
private void buildFilterbank(int numberDftPoints,int numberFilters,double minFreq,double maxFreq) throws IllegalArgumentException {
  double minFreqMel;
  double maxFreqMel;
  double deltaFreqMel;
  double[] leftEdge=new double[numberFilters];
  double[] centerFreq=new double[numberFilters];
  double[] rightEdge=new double[numberFilters];
  double nextEdgeMel;
  double nextEdge;
  double initialFreqBin;
  double deltaFreq;
  this.filter=new MelFilter[numberFilters];
  if (numberDftPoints == 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  deltaFreq=(double)sampleRate / numberDftPoints;
  if (numberFilters < 1) {
    throw new IllegalArgumentException("String_Node_Str" + numberFilters);
  }
  minFreqMel=linToMelFreq(minFreq);
  maxFreqMel=linToMelFreq(maxFreq);
  deltaFreqMel=(maxFreqMel - minFreqMel) / (numberFilters + 1);
  leftEdge[0]=setToNearestFrequencyBin(minFreq,deltaFreq);
  nextEdgeMel=minFreqMel;
  for (int i=0; i < numberFilters; i++) {
    nextEdgeMel+=deltaFreqMel;
    nextEdge=melToLinFreq(nextEdgeMel);
    centerFreq[i]=setToNearestFrequencyBin(nextEdge,deltaFreq);
    if (i > 0) {
      rightEdge[i - 1]=centerFreq[i];
    }
    if (i < numberFilters - 1) {
      leftEdge[i + 1]=centerFreq[i];
    }
  }
  nextEdgeMel=nextEdgeMel + deltaFreqMel;
  nextEdge=melToLinFreq(nextEdgeMel);
  rightEdge[numberFilters - 1]=setToNearestFrequencyBin(nextEdge,deltaFreq);
  for (int i=0; i < numberFilters; i++) {
    initialFreqBin=setToNearestFrequencyBin(leftEdge[i],deltaFreq);
    if (initialFreqBin < leftEdge[i]) {
      initialFreqBin+=deltaFreq;
    }
    this.filter[i]=new MelFilter(leftEdge[i],centerFreq[i],rightEdge[i],initialFreqBin,deltaFreq);
  }
}