Program: 19819
Project: 19819
Buggy source:
/** 
 * Actually creates the Spectrogram image.
 */
private void computeSpectrogram(){
  try {
    AudioDataInputStream is=new AudioDataInputStream(audio);
    StreamDataSource audioSource=new StreamDataSource();
    audioSource.initialize("String_Node_Str",null,props,null);
    audioSource.setInputStream(is,"String_Node_Str");
    Collection names=FrontEndFactory.getNames(props);
    assert(names.size() == 1);
    String feName=(String)names.iterator().next();
    FrontEnd frontEnd=FrontEndFactory.getFrontEnd(feName,props);
    frontEnd.setDataSource(audioSource);
    ArrayList intensitiesList=new ArrayList();
    double maxIntensity=Double.MIN_VALUE;
    Data spectrum=frontEnd.getData();
    while (!(spectrum instanceof DataEndSignal)) {
      if (spectrum instanceof DoubleData) {
        double[] spectrumData=((DoubleData)spectrum).getValues();
        double[] intensities=new double[spectrumData.length];
        for (int i=0; i < intensities.length; i++) {
          intensities[i]=Math.max(Math.log(spectrumData[i]),0.0);
          if (intensities[i] > maxIntensity) {
            maxIntensity=intensities[i];
          }
        }
        intensitiesList.add(intensities);
      }
      spectrum=frontEnd.getData();
    }
    is.close();
    int width=intensitiesList.size();
    int height=((double[])intensitiesList.get(0)).length;
    int maxYIndex=height - 1;
    Dimension d=new Dimension(width,height);
    setMinimumSize(d);
    setMaximumSize(d);
    setPreferredSize(d);
    spectrogram=new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
    double scaleFactor=((0xff + offsetFactor) / maxIntensity);
    for (int i=0; i < width; i++) {
      double[] intensities=(double[])intensitiesList.get(i);
      for (int j=maxYIndex; j >= 0; j--) {
        int grey=(int)(intensities[j] * scaleFactor - offsetFactor);
        grey=Math.max(grey,0);
        grey=0xff - grey;
        int pixel=((grey << 16) & 0xff0000) | ((grey << 8) & 0xff00) | (grey & 0xff);
        spectrogram.setRGB(i,maxYIndex - j,pixel);
      }
    }
    repaint(new Rectangle(width,height));
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
/** 
 * Actually creates the Spectrogram image.
 */
private void computeSpectrogram(){
  try {
    AudioDataInputStream is=new AudioDataInputStream(audio);
    StreamDataSource audioSource=new StreamDataSource();
    audioSource.initialize("String_Node_Str",null,props,null);
    audioSource.setInputStream(is,"String_Node_Str");
    Collection names=FrontEndFactory.getNames(props);
    assert(names.size() == 1);
    String feName=(String)names.iterator().next();
    FrontEnd frontEnd=FrontEndFactory.getFrontEnd(props,feName);
    frontEnd.setDataSource(audioSource);
    ArrayList intensitiesList=new ArrayList();
    double maxIntensity=Double.MIN_VALUE;
    Data spectrum=frontEnd.getData();
    while (!(spectrum instanceof DataEndSignal)) {
      if (spectrum instanceof DoubleData) {
        double[] spectrumData=((DoubleData)spectrum).getValues();
        double[] intensities=new double[spectrumData.length];
        for (int i=0; i < intensities.length; i++) {
          intensities[i]=Math.max(Math.log(spectrumData[i]),0.0);
          if (intensities[i] > maxIntensity) {
            maxIntensity=intensities[i];
          }
        }
        intensitiesList.add(intensities);
      }
      spectrum=frontEnd.getData();
    }
    is.close();
    int width=intensitiesList.size();
    int height=((double[])intensitiesList.get(0)).length;
    int maxYIndex=height - 1;
    Dimension d=new Dimension(width,height);
    setMinimumSize(d);
    setMaximumSize(d);
    setPreferredSize(d);
    spectrogram=new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
    double scaleFactor=((0xff + offsetFactor) / maxIntensity);
    for (int i=0; i < width; i++) {
      double[] intensities=(double[])intensitiesList.get(i);
      for (int j=maxYIndex; j >= 0; j--) {
        int grey=(int)(intensities[j] * scaleFactor - offsetFactor);
        grey=Math.max(grey,0);
        grey=0xff - grey;
        int pixel=((grey << 16) & 0xff0000) | ((grey << 8) & 0xff00) | (grey & 0xff);
        spectrogram.setRGB(i,maxYIndex - j,pixel);
      }
    }
    repaint(new Rectangle(width,height));
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}