nus-yam/ex-repair huggingface dataset:
Program: 81310
Project: 81310
Buggy source:
private Chart getChart(String[] notes,Spectrum<Complex[]>... fs){
  double[] xData=new double[fs[0].getState().length];
  double[][] yData=new double[fs.length][fs[0].getState().length];
  final float timelapseInTheCepstrum=fs[0].getState().length * 1.0f / fs[0].getSampleRate();
  for (int i=10; i < 1000; i++) {
    xData[i]=1.0 / (i * 1.0 / fs[0].getState().length * timelapseInTheCepstrum);
  }
  for (int j=0; j < fs.length; j++) {
    for (int i=10; i < 1000; i++) {
      yData[j][i]=(i > 10 && i < fs[j].getState().length - 10 ? fs[j].getState()[i].abs() : 0);
    }
  }
  return QuickChart.getChart("String_Node_Str","String_Node_Str","String_Node_Str",notes,xData,yData);
}

Fixed version (ground truth):
private Chart getChart(String[] notes,Spectrum<Complex[]>... fs){
  double[] xData=new double[fs[0].getState().length];
  double[][] yData=new double[fs.length][fs[0].getState().length];
  final float timelapseInTheCepstrum=fs[0].getState().length * 1.0f / fs[0].getSampleRate();
  for (int i=10; i < 1000; i++) {
    xData[i]=1.0 / (i * 1.0 / fs[0].getState().length * timelapseInTheCepstrum);
  }
  for (int j=0; j < fs.length; j++) {
    for (int i=10; i < 1000; i++) {
      yData[j][i]=(i > 10 && i < fs[j].getState().length - 10 ? fs[j].getState()[i].abs() : 0);
    }
  }
  Chart chart=QuickChart.getChart("String_Node_Str","String_Node_Str","String_Node_Str",notes,xData,yData);
  chart.setBackgroundColor(Color.BLACK);
  chart.setLegendBackgroundColor(Color.BLACK);
  chart.setForegroundColor(Color.BLACK);
  chart.setGridLinesColor(Color.LIGHT_GRAY);
  chart.setFontColor(Color.WHITE);
  return chart;
}
Program: 81311
Project: 81311
Buggy source:
@SuppressWarnings("String_Node_Str") @Test public void canAskToDoALotOfThingsToTheFluentClientOperationAndNothingShouldBeDone() throws SoundTransformException {
  FluentClientOperation.prepare().withAnObserver().andAfterStart().withAPack(null,new ByteArrayInputStream(new byte[0])).withAPack(null,"String_Node_Str").withAPack(null,null,null,0).withAudioInputStream(null).importToSound().append(null).apply(null).changeFormat(null).cutSubSound(0,0).playIt().changeFormat(null).exportToClasspathResource(null).playIt().importToStream().playIt().importToSound().exportToClasspathResourceWithSiblingResource(null,null).convertIntoSound().exportToFile(null).convertIntoSound().exportToStream().importToSound().findLoudestFrequencies().compress(0).filterRange(0,0).insertPart(null,0).octaveDown().octaveUp().replacePart(null,0).shapeIntoSound(null,null,null).loop(0).mixWith(null).splitIntoSpectrums().playIt().extractSound().andAfterStart().inParallel(null,0,new File("String_Node_Str")).mixAllInOneSound().andAfterStart().inParallel(null,0,Arrays.asList(new float[0])).andAfterStart().inParallel(null,0,new ByteArrayInputStream(new byte[0])).andAfterStart().inParallel(null,0,new Sound[0]).andAfterStart().inParallel(null,0,"String_Node_Str").andAfterStart().inParallel(null,0,FluentClient.start()).build();
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Test public void canAskToDoALotOfThingsToTheFluentClientOperationAndNothingShouldBeDone() throws SoundTransformException {
  FluentClientOperation.prepare().withAnObserver().andAfterStart().withAPack(null,new ByteArrayInputStream(new byte[0])).withAPack(null,"String_Node_Str").withAPack(null,null,null,0).withAudioInputStream(null).importToSound().append(null).apply(null).changeFormat(null).cutSubSound(0,0).playIt().changeFormat(null).exportToClasspathResource(null).playIt().importToStream().playIt().importToSound().exportToClasspathResourceWithSiblingResource(null,null).convertIntoSound().exportToFile(null).convertIntoSound().exportToStream().importToSound().findLoudestFrequencies().compress(0).filterRange(0,0).insertPart(null,0).octaveDown().octaveUp().replacePart(null,0).shapeIntoSound(null,null,null).loop(0).mixWith(null).splitIntoSpectrums().playIt().extractSound().andAfterStart().inParallel(null,0,new File("String_Node_Str")).mixAllInOneSound().andAfterStart().inParallel(null,0,new LinkedList<float[]>()).andAfterStart().inParallel(null,0,new ByteArrayInputStream(new byte[0])).andAfterStart().inParallel(null,0,new Sound[0]).andAfterStart().inParallel(null,0,"String_Node_Str").andAfterStart().inParallel(null,0,FluentClient.start()).build();
}
Program: 81312
Project: 81312
Buggy source:
/** 
 * Stops the client pipeline and get all the values inside each nested client
 * @param resultClass You have to specify what type of result you expect. the value can be one of this list : (Sound.class, InputStream.class, File.class, String.class, float [].class)
 * @return an array of results
 */
@Override @SuppressWarnings("String_Node_Str") public <T>T[] stopWithResults(final Class<T> resultClass){
  final T[] results=(T[])Array.newInstance(resultClass,this.parallelizedClients.length);
  int i=0;
  for (  final FluentClientCommon fcc : this.parallelizedClients) {
    if (resultClass == float[].class) {
      results[i++]=(T)((FluentClient)fcc).stopWithFreqs();
    }
 else     if (resultClass == Sound.class) {
      results[i++]=(T)((FluentClient)fcc).stopWithSound();
    }
 else     if (resultClass == InputStream.class) {
      results[i++]=(T)((FluentClient)fcc).stopWithInputStream();
    }
 else     if (resultClass == File.class) {
      results[i++]=(T)((FluentClient)fcc).stopWithFile();
    }
  }
  return results;
}

Fixed version (ground truth):
/** 
 * Stops the client pipeline and get all the values inside each nested client
 * @param resultClass You have to specify what type of result you expect. the value can be one of this list : (Sound.class, InputStream.class, File.class, String.class, float [].class)
 * @return an array of results
 */
@Override @SuppressWarnings("String_Node_Str") public <T>T[] stopWithResults(final Class<T> resultClass){
  final T[] results=(T[])Array.newInstance(resultClass,this.parallelizedClients.length);
  int i=0;
  for (  final FluentClientCommon fcc : this.parallelizedClients) {
    if (resultClass == List.class) {
      results[i++]=(T)((FluentClient)fcc).stopWithFreqs();
    }
 else     if (resultClass == Sound.class) {
      results[i++]=(T)((FluentClient)fcc).stopWithSound();
    }
 else     if (resultClass == InputStream.class) {
      results[i++]=(T)((FluentClient)fcc).stopWithInputStream();
    }
 else     if (resultClass == File.class) {
      results[i++]=(T)((FluentClient)fcc).stopWithFile();
    }
  }
  return results;
}
Program: 81313
Project: 81313
Buggy source:
@Override public String fsToString(final Spectrum<Complex[]> fs,final int low,final int high,final int compression,final int height){
  final StringBuilder sb=new StringBuilder();
  final float lastFrequency=fs.getState().length < high ? fs.getState().length : (float)high;
  final int length=(int)lastFrequency / compression;
  final int maxIndex=this.spectrumHelper.getMaxIndex(fs,low,high);
  final double maxValue=(double)fs.getState()[maxIndex].abs();
  final double maxMagn=(GraphSpectrumToStringHelper.DECIBELS_FORMULA_COEFFICIENT * Math.log10(maxValue));
  final int step=(int)lastFrequency / length;
  final int[] valuesOnPlot=this.prepareValuesOnPlot(fs,step,maxMagn,length,low,height);
  for (int j=height; j >= 0; j--) {
    this.diplayRow(sb,j,valuesOnPlot,this.getMaxValueOrMaxMagn(maxValue,maxMagn),length,height);
  }
  this.diplayFooter(sb,length,this.spectrumHelper,compression,lastFrequency);
  this.displayLoudestFrequency(sb,length,this.spectrumHelper,maxIndex,compression,lastFrequency);
  return sb.toString();
}

Fixed version (ground truth):
@Override public String fsToString(final Spectrum<Complex[]> fs,final int low,final int high,final int compression,final int height){
  final StringBuilder sb=new StringBuilder();
  final float lastFrequency=fs.getState().length < high ? fs.getState().length : (float)high;
  final int length=(int)lastFrequency / compression;
  final int maxIndex=this.spectrumHelper.getMaxIndex(fs,low,high);
  final double maxValue=(double)fs.getState()[maxIndex].abs();
  final double maxMagn=(GraphSpectrumToStringHelper.DECIBELS_FORMULA_COEFFICIENT * Math.log10(maxValue));
  final int step=(int)lastFrequency / length;
  final int[] valuesOnPlot=this.prepareValuesOnPlot(fs,step,this.getMaxValueOrMaxMagn(maxValue,maxMagn),length,low,height);
  for (int j=height; j >= 0; j--) {
    this.diplayRow(sb,j,valuesOnPlot,this.getMaxValueOrMaxMagn(maxValue,maxMagn),length,height);
  }
  this.diplayFooter(sb,length,this.spectrumHelper,compression,lastFrequency);
  this.displayLoudestFrequency(sb,length,this.spectrumHelper,maxIndex,compression,lastFrequency);
  return sb.toString();
}
Program: 81314
Project: 81314
Buggy source:
@Test public void testCepstrum() throws SoundTransformException {
  CepstrumSoundTransformation<Serializable> cepstrum=new CepstrumSoundTransformation<Serializable>(100);
  FluentClient.start().withAnObserver(new Slf4jObserver(LogLevel.WARN)).withFile(new File(this.classLoader.getResource("String_Node_Str").getFile())).convertIntoSound().apply(cepstrum).exportToFile(this.output);
  new Slf4jObserver(LogLevel.INFO).notify(cepstrum.getCepstrums().get(0).toString());
}

Fixed version (ground truth):
@Test public void testCepstrum() throws SoundTransformException {
  CepstrumSoundTransformation<Serializable> cepstrum=new CepstrumSoundTransformation<Serializable>(100);
  FluentClient.start().withAnObserver(new Slf4jObserver(LogLevel.WARN)).withFile(new File(this.classLoader.getResource("String_Node_Str").getFile())).convertIntoSound().apply(cepstrum).exportToFile(this.output);
  new Slf4jObserver(LogLevel.INFO).notify("String_Node_Str" + cepstrum.getCepstrums().get(0).toString());
}
Program: 81315
Project: 81315
Buggy source:
@Override public FluentClientOperation extractSound() throws SoundTransformException {
  return this;
}

Fixed version (ground truth):
@Override public FluentClientOperation extractSound() throws SoundTransformException {
  this.steps.add(new Step(){
    @Override public void run(    final FluentClientInterface client) throws SoundTransformException {
      client.extractSound();
    }
  }
);
  return this;
}
Program: 81316
Project: 81316
Buggy source:
@Override @SuppressWarnings("String_Node_Str") public <T>List<T> stopWithResults(Class<T> resultClass){
  List<T> results=new LinkedList<T>();
  for (  FluentClientCommon fcc : this.parallelizedClients) {
    if (resultClass == float[].class) {
      results.add((T)((FluentClient)fcc).stopWithFreqs());
    }
 else     if (resultClass == Sound[].class) {
      results.add((T)((FluentClient)fcc).stopWithSounds());
    }
 else     if (resultClass == InputStream.class) {
      results.add((T)((FluentClient)fcc).stopWithInputStream());
    }
 else     if (resultClass == File.class) {
      results.add((T)((FluentClient)fcc).stopWithFile());
    }
  }
  return results;
}

Fixed version (ground truth):
@Override @SuppressWarnings("String_Node_Str") public <T>T[] stopWithResults(Class<T> resultClass){
  final T[] results=(T[])Array.newInstance(resultClass,this.parallelizedClients.length);
  int i=0;
  for (  FluentClientCommon fcc : this.parallelizedClients) {
    if (resultClass == float[].class) {
      results[i++]=(T)((FluentClient)fcc).stopWithFreqs();
    }
 else     if (resultClass == Sound[].class) {
      results[i++]=(T)((FluentClient)fcc).stopWithSounds();
    }
 else     if (resultClass == InputStream.class) {
      results[i++]=(T)((FluentClient)fcc).stopWithInputStream();
    }
 else     if (resultClass == File.class) {
      results[i++]=(T)((FluentClient)fcc).stopWithFile();
    }
  }
  return (T[])results;
}
Program: 81317
Project: 81317
Buggy source:
public abstract <T>List<T> stopWithResults(Class<T> resultClass);

Fixed version (ground truth):
public abstract <T>T[] stopWithResults(Class<T> resultClass);
Program: 81318
Project: 81318
Buggy source:
@Override public <T>List<T> stopWithResults(Class<T> resultClass){
  throw new SoundTransformRuntimeException(FluentClientOperationErrorCode.NOT_POSSIBLE_IN_AN_OPERATION,new UnsupportedOperationException());
}

Fixed version (ground truth):
@Override public <T>T[] stopWithResults(Class<T> resultClass){
  throw new SoundTransformRuntimeException(FluentClientOperationErrorCode.NOT_POSSIBLE_IN_AN_OPERATION,new UnsupportedOperationException());
}
Program: 81319
Project: 81319
Buggy source:
<T>List<T> stopWithResults(Class<T> resultClass);

Fixed version (ground truth):
<T>T[] stopWithResults(Class<T> resultClass);
Program: 81320
Project: 81320
Buggy source:
@Override public Sound transform(final Sound input){
  final Sound[] onlyOneChannelSounds=new Sound[this.otherSounds.size()];
  int i=0;
  for (  final Sound[] sounds : this.otherSounds) {
    if (sounds.length > input.getChannelNum()) {
      onlyOneChannelSounds[i++]=sounds[input.getChannelNum()];
    }
  }
  return this.mix(input,onlyOneChannelSounds);
}

Fixed version (ground truth):
@Override public Sound transform(final Sound input){
  final Sound[] onlyOneChannelFromSounds=new Sound[this.otherSounds.size()];
  int i=0;
  for (  final Sound[] sounds : this.otherSounds) {
    if (sounds.length > input.getChannelNum()) {
      onlyOneChannelFromSounds[i++]=sounds[input.getChannelNum()];
    }
  }
  return this.mix(input,onlyOneChannelFromSounds);
}
Program: 81321
Project: 81321
Buggy source:
@Override public Sound transform(final Sound sound) throws SoundTransformException {
  if (this.pack == null) {
    throw new SoundTransformException(ShapeSoundTransformationErrorCode.NO_PACK_IN_PARAMETER,new NullPointerException());
  }
  final int step=100;
  int channelNum=1;
  int soundLength=0;
  this.log(new LogEvent(ShapeSoundTransformationEventCode.FINDING_LOUDEST_FREQUENCIES));
  if (this.freqs == null) {
    this.formatInfo=sound.getFormatInfo();
    soundLength=sound.getSamplesLength();
    this.freqs=this.getLoudestFreqs(sound,step);
    channelNum=sound.getChannelNum();
  }
  if (soundLength == 0) {
    soundLength=step * this.freqs.length;
  }
  return this.transform(step,channelNum,soundLength);
}

Fixed version (ground truth):
@Override public Sound transform(final Sound sound) throws SoundTransformException {
  if (this.pack == null) {
    throw new SoundTransformException(ShapeSoundTransformationErrorCode.NO_PACK_IN_PARAMETER,new NullPointerException());
  }
  final int step=100;
  int channelNum=0;
  int soundLength=0;
  this.log(new LogEvent(ShapeSoundTransformationEventCode.FINDING_LOUDEST_FREQUENCIES));
  if (this.freqs == null) {
    this.formatInfo=sound.getFormatInfo();
    soundLength=sound.getSamplesLength();
    this.freqs=this.getLoudestFreqs(sound,step);
    channelNum=sound.getChannelNum();
  }
  if (soundLength == 0) {
    soundLength=step * this.freqs.length;
  }
  return this.transform(step,channelNum,soundLength);
}
Program: 81322
Project: 81322
Buggy source:
private void writeSound(final InputStream ais,final StreamInfo isInfo,final Sound[] result) throws SoundTransformException {
  final long neutral=this.getNeutral(isInfo.getSampleSize());
  for (int position=0; position < (int)isInfo.getFrameLength(); position++) {
    final byte[] frame=new byte[isInfo.getSampleSize() * isInfo.getChannels()];
    try {
      final int frameSize=ais.read(frame);
      this.log(new LogEvent(FrameProcessorEventCode.READ_FRAME_SIZE,frameSize));
    }
 catch (    final IOException e) {
      throw new SoundTransformException(FrameProcessorErrorCode.COULD_NOT_READ_STREAM,e);
    }
    final int currentPercent=this.getPercent(position,isInfo.getFrameLength());
    final int lastPercent=this.getPercent(position - 1,isInfo.getFrameLength());
    if (currentPercent % ByteArrayFrameProcessor.EACH_X_PERCENT == 0 && lastPercent % ByteArrayFrameProcessor.EACH_X_PERCENT == ByteArrayFrameProcessor.EACH_X_PERCENT_MINUS_ONE) {
      this.log(new LogEvent(FrameProcessorEventCode.BYTEARRAY_TO_FRAME_CONVERSION,position,isInfo.getFrameLength(),currentPercent));
    }
    this.byteArrayToFrame(frame,result,position,isInfo.isBigEndian(),isInfo.isPcmSigned(),neutral);
  }
}

Fixed version (ground truth):
private void writeSound(final InputStream ais,final StreamInfo isInfo,final Sound[] result) throws SoundTransformException {
  final long neutral=this.getNeutral(isInfo.getSampleSize());
  final int frameLength=this.findFrameLength(ais,isInfo);
  for (int position=0; position < frameLength; position++) {
    final byte[] frame=new byte[isInfo.getSampleSize() * isInfo.getChannels()];
    try {
      final int frameSize=ais.read(frame);
      this.log(new LogEvent(FrameProcessorEventCode.READ_FRAME_SIZE,frameSize));
    }
 catch (    final IOException e) {
      throw new SoundTransformException(FrameProcessorErrorCode.COULD_NOT_READ_STREAM,e);
    }
    final int currentPercent=this.getPercent(position,isInfo.getFrameLength());
    final int lastPercent=this.getPercent(position - 1,isInfo.getFrameLength());
    if (currentPercent % ByteArrayFrameProcessor.EACH_X_PERCENT == 0 && lastPercent % ByteArrayFrameProcessor.EACH_X_PERCENT == ByteArrayFrameProcessor.EACH_X_PERCENT_MINUS_ONE) {
      this.log(new LogEvent(FrameProcessorEventCode.BYTEARRAY_TO_FRAME_CONVERSION,position,isInfo.getFrameLength(),currentPercent));
    }
    this.byteArrayToFrame(frame,result,position,isInfo.isBigEndian(),isInfo.isPcmSigned(),neutral);
  }
}
Program: 81323
Project: 81323
Buggy source:
private int findFrameLength(final InputStream ais,final StreamInfo isInfo) throws SoundTransformException {
  try {
    return isInfo.getFrameLength() > 0 ? (int)isInfo.getFrameLength() : ais.available();
  }
 catch (  final IOException e) {
    throw new SoundTransformException(FrameProcessorErrorCode.COULD_NOT_FIND_LENGTH,e);
  }
}

Fixed version (ground truth):
private int findFrameLength(final InputStream ais,final StreamInfo isInfo) throws SoundTransformException {
  try {
    return isInfo.getFrameLength() > 0 ? (int)isInfo.getFrameLength() : ais.available() / isInfo.getSampleSize();
  }
 catch (  final IOException e) {
    throw new SoundTransformException(FrameProcessorErrorCode.COULD_NOT_FIND_LENGTH,e);
  }
}
Program: 81325
Project: 81325
Buggy source:
private void writeAudioDataToFile() throws IOException {
  final short[] sData=new short[AndroidRecorderThread.ARBITRARY_BUFFER];
  while (this.recording) {
    if (this.audioRecord.getRecordingState() != AudioRecord.STATE_UNINITIALIZED) {
      final int read=this.audioRecord.read(sData,0,sData.length);
      if (read > 0) {
        this.baos.write(this.short2byte(sData),0,read);
      }
 else       if (read == 0) {
        this.recording=false;
      }
    }
  }
}

Fixed version (ground truth):
private void writeAudioDataToFile() throws IOException {
  final short[] sData=new short[AndroidRecorderThread.ARBITRARY_BUFFER];
  while (this.recording) {
    if (this.audioRecord.getRecordingState() != AudioRecord.STATE_UNINITIALIZED) {
      final int read=this.audioRecord.read(sData,0,sData.length);
      if (read > 0) {
        this.baos.write(this.short2byte(sData),0,read * AndroidRecorderThread.TWO);
      }
 else       if (read == 0) {
        this.recording=false;
      }
    }
  }
}
Program: 81326
Project: 81326
Buggy source:
@Test public void recordTwoSeconds() throws SoundTransformException {
  Sound[] sounds=FluentClient.start().withLimitedTimeRecordedInputStream(new StreamInfo(2,100000,2,48000,false,true,null)).importToSound().stopWithSounds();
  sounds.hashCode();
}

Fixed version (ground truth):
@Test public void recordTwoSeconds() throws SoundTransformException {
  FluentClient.start().withLimitedTimeRecordedInputStream(new StreamInfo(2,100000,2,48000,false,true,null)).writeToClasspathResourceWithSiblingResource("String_Node_Str","String_Node_Str");
}
Program: 81327
Project: 81327
Buggy source:
private void startRecording(AudioFormat audioFormat) throws SoundTransformException {
  final TargetDataLine line;
  DataLine.Info info=new DataLine.Info(TargetDataLine.class,audioFormat);
  this.baos=new ByteArrayOutputStream();
  if (!AudioSystem.isLineSupported(info)) {
    throw new SoundTransformException(TargetDataLineRecordSoundProcessorErrorCode.AUDIO_FORMAT_NOT_SUPPORTED,new UnsupportedOperationException(),audioFormat);
  }
  try {
    line=(TargetDataLine)AudioSystem.getLine(info);
    line.open(audioFormat);
  }
 catch (  LineUnavailableException ex) {
    throw new SoundTransformException(TargetDataLineRecordSoundProcessorErrorCode.TARGET_LINE_UNAVAILABLE,ex);
  }
  this.isRecording=true;
  line.start();
  new Thread(){
    public void run(){
      byte[] data=new byte[line.getBufferSize() / 5];
      while (TargetDataLineRecordSoundProcessor.this.isRecording) {
        final int numBytesRead=line.read(data,0,data.length);
        TargetDataLineRecordSoundProcessor.this.baos.write(data,0,numBytesRead);
      }
    }
  }
.start();
  line.close();
}

Fixed version (ground truth):
private void startRecording(AudioFormat audioFormat) throws SoundTransformException {
  DataLine.Info info=new DataLine.Info(TargetDataLine.class,audioFormat);
  this.baos=new ByteArrayOutputStream();
  if (!AudioSystem.isLineSupported(info)) {
    throw new SoundTransformException(TargetDataLineRecordSoundProcessorErrorCode.AUDIO_FORMAT_NOT_SUPPORTED,new UnsupportedOperationException(),audioFormat);
  }
  try {
    this.line=(TargetDataLine)AudioSystem.getLine(info);
    this.line.open(audioFormat);
  }
 catch (  LineUnavailableException ex) {
    throw new SoundTransformException(TargetDataLineRecordSoundProcessorErrorCode.TARGET_LINE_UNAVAILABLE,ex);
  }
  this.isRecording=true;
  this.line.start();
  new Thread(){
    public void run(){
      byte[] data=new byte[line.getBufferSize() / 5];
      while (TargetDataLineRecordSoundProcessor.this.isRecording) {
        final int numBytesRead=line.read(data,0,data.length);
        TargetDataLineRecordSoundProcessor.this.baos.write(data,0,numBytesRead);
      }
    }
  }
.start();
}
Program: 81328
Project: 81328
Buggy source:
private void stopRecording(){
  this.isRecording=false;
}

Fixed version (ground truth):
private void stopRecording(){
  this.isRecording=false;
  this.line.stop();
  this.line.close();
}
Program: 81329
Project: 81329
Buggy source:
private Clip prepareClip(InputStream ais) throws PlaySoundException {
  if (!(ais instanceof AudioInputStream)) {
    throw new PlaySoundException(new IllegalArgumentException("String_Node_Str" + ais));
  }
  try {
    final Line.Info linfo=new Line.Info(Clip.class);
    final Line line=AudioSystem.getLine(linfo);
    final Clip clip=(Clip)line;
    clip.addLineListener(new LineListener(){
      @Override public void update(      final LineEvent event){
        final LineEvent.Type type=event.getType();
        if (type == LineEvent.Type.STOP) {
synchronized (clip) {
            clip.stop();
            clip.close();
            clip.notify();
          }
        }
      }
    }
);
    clip.open((AudioInputStream)ais);
    return clip;
  }
 catch (  final LineUnavailableException lineUnavailableException) {
    throw new PlaySoundException(lineUnavailableException);
  }
catch (  final IOException e) {
    throw new PlaySoundException(e);
  }
}

Fixed version (ground truth):
private Clip prepareClip(InputStream ais) throws PlaySoundException {
  if (!(ais instanceof AudioInputStream)) {
    throw new PlaySoundException(new IllegalArgumentException("String_Node_Str" + ais));
  }
  try {
    final Line.Info linfo=new Line.Info(Clip.class);
    final Line line=AudioSystem.getLine(linfo);
    final Clip clip=(Clip)line;
    this.addLineListener(clip);
    clip.open((AudioInputStream)ais);
    return clip;
  }
 catch (  final LineUnavailableException lineUnavailableException) {
    throw new PlaySoundException(lineUnavailableException);
  }
catch (  final IOException e) {
    throw new PlaySoundException(e);
  }
catch (  final IllegalArgumentException e) {
    throw new PlaySoundException(e);
  }
}
Program: 81330
Project: 81330
Buggy source:
@Test public void playIt() throws SoundTransformException {
  FluentClient.start().withAnObserver(new Slf4jObserver(LogLevel.WARN)).withClasspathResource("String_Node_Str").playIt().convertIntoSound().playIt().exportToStream().playIt();
}

Fixed version (ground truth):
@Test public void playIt() throws SoundTransformException {
  try {
    FluentClient.start().withAnObserver(new Slf4jObserver(LogLevel.WARN)).withClasspathResource("String_Node_Str").playIt().convertIntoSound().playIt().exportToStream().playIt();
  }
 catch (  PlaySoundException pse) {
    new Slf4jObserver().notify("String_Node_Str" + pse);
  }
}
Program: 81331
Project: 81331
Buggy source:
@Test public void playBeforeWav() throws SoundTransformException {
  final PlaySoundProcessor ps=$.select(PlaySoundProcessor.class);
  final ConvertAudioFileService convertAudioFileService=$.create(ConvertAudioFileService.class);
  final InputStream ais=convertAudioFileService.callConverter(this.input);
  try {
    ps.play(ais);
  }
 catch (  final java.lang.IllegalArgumentException iae) {
    if (!"String_Node_Str".equals(iae.getMessage())) {
      throw iae;
    }
  }
catch (  final PlaySoundException e) {
    if (!javax.sound.sampled.LineUnavailableException.class.equals(e.getCause().getClass())) {
      throw e;
    }
  }
catch (  final RuntimeException e) {
    if (!"String_Node_Str".equals(e.getMessage())) {
      throw e;
    }
  }
}

Fixed version (ground truth):
@Test public void playBeforeWav() throws SoundTransformException {
  final PlaySoundProcessor ps=$.select(PlaySoundProcessor.class);
  final ConvertAudioFileService convertAudioFileService=$.create(ConvertAudioFileService.class);
  final InputStream ais=convertAudioFileService.callConverter(this.input);
  try {
    ps.play(ais);
  }
 catch (  final java.lang.IllegalArgumentException iae) {
    if (!"String_Node_Str".equals(iae.getMessage())) {
      throw iae;
    }
  }
catch (  final PlaySoundException e) {
  }
catch (  final RuntimeException e) {
    if (!"String_Node_Str".equals(e.getMessage())) {
      throw e;
    }
  }
}
Program: 81332
Project: 81332
Buggy source:
@Test public void playBeforeWav() throws SoundTransformException {
  final PlaySoundProcessor ps=$.select(PlaySoundProcessor.class);
  final ConvertAudioFileService convertAudioFileService=$.create(ConvertAudioFileService.class);
  final InputStream ais=convertAudioFileService.callConverter(this.input);
  try {
    ps.play(ais);
  }
 catch (  final java.lang.IllegalArgumentException iae) {
    if (!"String_Node_Str".equals(iae.getMessage())) {
      throw iae;
    }
  }
catch (  final PlaySoundException e) {
  }
catch (  final RuntimeException e) {
    if (!"String_Node_Str".equals(e.getMessage())) {
      throw e;
    }
  }
}

Fixed version (ground truth):
@Test public void playBeforeWav() throws SoundTransformException {
  final PlaySoundProcessor ps=$.select(PlaySoundProcessor.class);
  final ConvertAudioFileService convertAudioFileService=$.create(ConvertAudioFileService.class);
  final InputStream ais=convertAudioFileService.callConverter(this.input);
  try {
    ps.play(ais);
  }
 catch (  final java.lang.IllegalArgumentException iae) {
    if (!"String_Node_Str".equals(iae.getMessage())) {
      throw iae;
    }
  }
catch (  final PlaySoundException e) {
    if (!javax.sound.sampled.LineUnavailableException.class.equals(e.getCause().getClass()) && !java.lang.IllegalArgumentException.class.equals(e.getCause().getClass())) {
      throw e;
    }
  }
catch (  final RuntimeException e) {
    if (!"String_Node_Str".equals(e.getMessage())) {
      throw e;
    }
  }
}
Program: 81333
Project: 81333
Buggy source:
private void writeSound(final InputStream ais,final InputStreamInfo isInfo,final Sound[] result) throws SoundTransformException {
  final long neutral=isInfo.isPcmSigned() ? this.getNeutral(isInfo.getSampleSize()) : 0;
  for (int position=0; position < (int)isInfo.getFrameLength(); position++) {
    final byte[] frame=new byte[isInfo.getSampleSize() * isInfo.getChannels()];
    try {
      int frameSize=ais.read(frame);
      this.log(new LogEvent(FrameProcessorEventCode.READ_FRAME_SIZE,frameSize));
    }
 catch (    final IOException e) {
      throw new SoundTransformException(TransformInputStreamServiceErrorCode.COULD_NOT_READ_STREAM,e);
    }
    if (this.getPercent(position,isInfo.getFrameLength()) != this.getPercent(position - 1,isInfo.getFrameLength())) {
      this.log(new LogEvent(FrameProcessorEventCode.BYTEARRAY_TO_FRAME_CONVERSION,position,isInfo.getFrameLength(),this.getPercent(position,isInfo.getFrameLength())));
    }
    this.byteArrayToFrame(frame,result,position,isInfo.isBigEndian(),isInfo.isPcmSigned(),neutral);
  }
}

Fixed version (ground truth):
private void writeSound(final InputStream ais,final InputStreamInfo isInfo,final Sound[] result) throws SoundTransformException {
  final long neutral=this.getNeutral(isInfo.getSampleSize());
  for (int position=0; position < (int)isInfo.getFrameLength(); position++) {
    final byte[] frame=new byte[isInfo.getSampleSize() * isInfo.getChannels()];
    try {
      int frameSize=ais.read(frame);
      this.log(new LogEvent(FrameProcessorEventCode.READ_FRAME_SIZE,frameSize));
    }
 catch (    final IOException e) {
      throw new SoundTransformException(TransformInputStreamServiceErrorCode.COULD_NOT_READ_STREAM,e);
    }
    if (this.getPercent(position,isInfo.getFrameLength()) != this.getPercent(position - 1,isInfo.getFrameLength())) {
      this.log(new LogEvent(FrameProcessorEventCode.BYTEARRAY_TO_FRAME_CONVERSION,position,isInfo.getFrameLength(),this.getPercent(position,isInfo.getFrameLength())));
    }
    this.byteArrayToFrame(frame,result,position,isInfo.isBigEndian(),isInfo.isPcmSigned(),neutral);
  }
}
Program: 81334
Project: 81334
Buggy source:
public void playIt() throws SoundTransformException {
  FluentClient.start().withAnObserver(new Slf4jObserver(LogLevel.WARN)).withClasspathResource("String_Node_Str").playIt().convertIntoSound().playIt().exportToStream().playIt();
}

Fixed version (ground truth):
@Test public void playIt() throws SoundTransformException {
  FluentClient.start().withAnObserver(new Slf4jObserver(LogLevel.WARN)).withClasspathResource("String_Node_Str").playIt().convertIntoSound().playIt().exportToStream().playIt();
}
Program: 81335
Project: 81335
Buggy source:
@Override public Sound transform(final Sound input){
  return this.mix(input,this.otherSounds);
}

Fixed version (ground truth):
@Override public Sound transform(final Sound input){
  Sound[] onlyOneChannelSounds=new Sound[this.otherSounds.size()];
  int i=0;
  for (  Sound[] sounds : this.otherSounds) {
    if (sounds.length > input.getChannelNum()) {
      onlyOneChannelSounds[i++]=sounds[input.getChannelNum()];
    }
  }
  return this.mix(input,onlyOneChannelSounds);
}
Program: 81336
Project: 81336
Buggy source:
private Sound mix(final Sound firstSound,final Sound... sounds){
  int maxlength=0;
  final Sound[] ajustedSounds=new Sound[sounds.length + 1];
  ajustedSounds[0]=sounds[0];
  for (int i=1; i < sounds.length; i++) {
    ajustedSounds[i]=this.soundAppender.changeNbBytesPerSample(this.soundAppender.resizeToSampleRate(sounds[i - 1],firstSound.getSampleRate()),firstSound.getNbBytesPerSample());
  }
  for (  final Sound sound : ajustedSounds) {
    maxlength=Math.max(maxlength,sound.getSamples().length);
  }
  final long[] newdata=new long[maxlength];
  double max=0;
  for (int i=0; i < maxlength; i++) {
    long element=0;
    for (    final Sound sound : ajustedSounds) {
      if (sound.getSamples().length > i) {
        element+=Math.abs(sound.getSamples()[i]);
        newdata[i]=sound.getSamples()[i];
      }
    }
    max=Math.max(element,max);
  }
  final double maxValue=Math.pow(256,sounds[0].getNbBytesPerSample()) - 1;
  final double ratio=maxValue / max;
  for (int i=0; i < maxlength; i++) {
    newdata[i]*=ratio;
  }
  return new Sound(newdata,firstSound.getNbBytesPerSample(),firstSound.getSampleRate(),firstSound.getChannelNum());
}

Fixed version (ground truth):
private Sound mix(final Sound firstSound,final Sound... sounds){
  int maxlength=0;
  final Sound[] ajustedSounds=new Sound[sounds.length + 1];
  ajustedSounds[0]=firstSound;
  for (int i=1; i < sounds.length + 1; i++) {
    ajustedSounds[i]=this.soundAppender.changeNbBytesPerSample(this.soundAppender.resizeToSampleRate(sounds[i - 1],firstSound.getSampleRate()),firstSound.getNbBytesPerSample());
  }
  for (  final Sound sound : ajustedSounds) {
    maxlength=Math.max(maxlength,sound.getSamples().length);
  }
  final long[] newdata=new long[maxlength];
  double max=0;
  for (int i=0; i < maxlength; i++) {
    for (    final Sound sound : ajustedSounds) {
      if (sound.getSamples().length > i) {
        newdata[i]+=sound.getSamples()[i];
      }
    }
    max=Math.max(newdata[i],max);
  }
  final double maxValue=Math.pow(256,sounds[0].getNbBytesPerSample()) - 1;
  final double ratio=maxValue / (max * ajustedSounds.length);
  for (int i=0; i < maxlength; i++) {
    newdata[i]*=ratio;
  }
  return new Sound(newdata,firstSound.getNbBytesPerSample(),firstSound.getSampleRate(),firstSound.getChannelNum());
}
Program: 81337
Project: 81337
Buggy source:
public MixSoundTransformation(final Sound... otherSounds1){
  this.soundAppender=$.select(SoundAppender.class);
  this.otherSounds=otherSounds1;
}

Fixed version (ground truth):
public MixSoundTransformation(final List<Sound[]> otherSounds1){
  this.soundAppender=$.select(SoundAppender.class);
  this.otherSounds=otherSounds1;
}
Program: 81340
Project: 81340
Buggy source:
private void getLoudestFreqs(Sound sound,int threshold){
  final PeakFindWithHPSSoundTransformation peak=new PeakFindWithHPSSoundTransformation(threshold,-1);
  peak.setObservers(this.observers);
  peak.transform(sound);
  freqs=peak.getLoudestFreqs();
}

Fixed version (ground truth):
private int[] getLoudestFreqs(Sound sound,int threshold){
  final PeakFindWithHPSSoundTransformation peak=new PeakFindWithHPSSoundTransformation(threshold,-1);
  peak.setObservers(this.observers);
  peak.transform(sound);
  return peak.getLoudestFreqs();
}
Program: 81341
Project: 81341
Buggy source:
private boolean freqHasChanged(int freq1,int freq2){
  return Math.abs(freq1 - freq2) > freq1 * 2.0 / 100;
}

Fixed version (ground truth):
private boolean freqHasChanged(int freq1,int freq2){
  return Math.abs(freq1 - freq2) > freq1 * 5.0 / 100;
}
Program: 81342
Project: 81342
Buggy source:
@Test public void test1() throws SoundTransformException {
  final int value=200;
  final int twopercents=(int)(value * 2.0 / 100 - 1);
  final List<String> messages=new LinkedList<String>();
  final int[] t=new int[2000];
  for (int i=200; i < 600; i++) {
    t[i]=(int)(value + Math.random() * twopercents - twopercents / 2);
  }
  for (int i=800; i < 1000; i++) {
    t[i]=(int)(value + Math.random() * twopercents - twopercents / 2);
  }
  for (int i=1100; i < 1600; i++) {
    t[i]=(int)(value + Math.random() * twopercents - twopercents / 2);
  }
  new ShapeSoundTransformation(Library.defaultPack,"String_Node_Str",t).setObservers(new PrintlnTransformObserver(),new Observer(){
    @Override public void notify(    final LogEvent logEvent){
      messages.add(logEvent.toString());
    }
  }
).transform(200000,100,2,44100,1);
  Assert.assertTrue(messages.get(0).endsWith("String_Node_Str"));
  Assert.assertTrue(messages.get(1).endsWith("String_Node_Str"));
  Assert.assertTrue(messages.get(2).endsWith("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void test1() throws SoundTransformException {
  final int value=200;
  final int twopercents=(int)(value * 5.0 / 100 - 1);
  final List<String> messages=new LinkedList<String>();
  final int[] t=new int[2000];
  for (int i=200; i < 600; i++) {
    t[i]=(int)(value + Math.random() * twopercents - twopercents / 2);
  }
  for (int i=800; i < 1000; i++) {
    t[i]=(int)(value + Math.random() * twopercents - twopercents / 2);
  }
  for (int i=1100; i < 1600; i++) {
    t[i]=(int)(value + Math.random() * twopercents - twopercents / 2);
  }
  new ShapeSoundTransformation(Library.defaultPack,"String_Node_Str",t).setObservers(new PrintlnTransformObserver(),new Observer(){
    @Override public void notify(    final LogEvent logEvent){
      messages.add(logEvent.toString());
    }
  }
).transform(200000,100,2,44100,1);
  Assert.assertTrue(messages.get(0).endsWith("String_Node_Str"));
  Assert.assertTrue(messages.get(1).endsWith("String_Node_Str"));
  Assert.assertTrue(messages.get(2).endsWith("String_Node_Str"));
}
Program: 81343
Project: 81343
Buggy source:
@Override public Sound initSound(final Sound input){
  this.loudestfreqs=new int[(int)(input.getSamples().length / this.threshold) + 1];
  if (this.note) {
    this.threshold=input.getSamples().length;
    this.fsLimit=input.getSamples().length;
  }
 else {
    this.fsLimit=input.getSampleRate();
  }
  this.soundLength=input.getSamples().length;
  return super.initSound(input);
}

Fixed version (ground truth):
@Override public Sound initSound(final Sound input){
  if (this.note) {
    this.threshold=input.getSamples().length;
    this.fsLimit=input.getSamples().length;
    this.loudestfreqs=new int[1];
  }
 else {
    this.loudestfreqs=new int[(int)(input.getSamples().length / this.threshold) + 1];
    this.fsLimit=input.getSampleRate();
  }
  this.soundLength=input.getSamples().length;
  return super.initSound(input);
}
Program: 81344
Project: 81344
Buggy source:
public Sound transform(int length,int threshold,int nbBytesPerSample,int sampleRate,int channelNum) throws SoundTransformException {
  final Sound builtSound=new Sound(new long[length],nbBytesPerSample,sampleRate,channelNum);
  double lastFreq=freqs[0];
  int lastBegining=0;
  int countZeros=0;
  for (int i=0; i < freqs.length; i++) {
    final float lengthInSeconds=(i - lastBegining < 1 ? freqs[i] * threshold : (i - 1 - lastBegining) * threshold * 1.0f) / sampleRate;
    final boolean freqChanged=Math.abs(freqs[i] - lastFreq) > freqs[i] / 100;
    if (freqChanged && freqs[i] == 0) {
      countZeros++;
    }
 else {
      countZeros=0;
    }
    if (i == freqs.length - 1 || freqChanged && (lastFreq == 0 || freqs[i] == 0 && countZeros >= 3)) {
      countZeros=0;
      Note note=this.findNote(lastFreq,sampleRate,i,lastBegining);
      this.soundAppender.appendNote(builtSound,note,lastFreq,threshold * lastBegining,channelNum,lengthInSeconds);
      lastBegining=i;
      lastFreq=freqs[i];
    }
  }
  return builtSound;
}

Fixed version (ground truth):
public Sound transform(int length,int threshold,int nbBytesPerSample,int sampleRate,int channelNum) throws SoundTransformException {
  final Sound builtSound=new Sound(new long[length],nbBytesPerSample,sampleRate,channelNum);
  double lastFreq=freqs[0];
  int lastBegining=0;
  int countZeros=0;
  for (int i=0; i < freqs.length; i++) {
    final float lengthInSeconds=(i - lastBegining < 1 ? freqs[i] * threshold : (i - 1 - lastBegining) * threshold * 1.0f) / sampleRate;
    final boolean freqChanged=Math.abs(freqs[i] - lastFreq) > freqs[i] / 100;
    if (freqChanged && freqs[i] == 0) {
      countZeros++;
    }
 else {
      countZeros=0;
    }
    if (i == freqs.length - 1 || freqChanged && (lastFreq == 0 || freqs[i] == 0 && countZeros >= 3)) {
      countZeros=0;
      Note note=this.findNote(lastFreq,sampleRate,i,lastBegining);
      this.soundAppender.appendNote(builtSound,note,lastFreq,threshold * lastBegining,channelNum,lengthInSeconds);
      lastBegining=i;
      lastFreq=freqs[i];
    }
  }
  this.freqs=null;
  return builtSound;
}
Program: 81345
Project: 81345
Buggy source:
@Test public void test1() throws SoundTransformException {
  final int value=200;
  final int tenpercent=(int)(value * 2 / 100 - 1);
  final List<String> messages=new LinkedList<String>();
  final int[] t=new int[2000];
  for (int i=200; i < 600; i++) {
    t[i]=(int)(value + Math.random() * tenpercent - tenpercent / 2);
  }
  for (int i=800; i < 1000; i++) {
    t[i]=(int)(value + Math.random() * tenpercent - tenpercent / 2);
  }
  for (int i=1100; i < 1600; i++) {
    t[i]=(int)(value + Math.random() * tenpercent - tenpercent / 2);
  }
  new ShapeSoundTransformation(Library.defaultPack,"String_Node_Str",t).setObservers(new PrintlnTransformObserver(),new Observer(){
    @Override public void notify(    final LogEvent logEvent){
      messages.add(logEvent.toString());
    }
  }
).transform(200000,100,2,44100,1);
  Assert.assertTrue(messages.get(0).endsWith("String_Node_Str"));
  Assert.assertTrue(messages.get(1).endsWith("String_Node_Str"));
  Assert.assertTrue(messages.get(2).endsWith("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void test1() throws SoundTransformException {
  final int value=200;
  final int twopercents=(int)(value * 2.0 / 100 - 1);
  final List<String> messages=new LinkedList<String>();
  final int[] t=new int[2000];
  for (int i=200; i < 600; i++) {
    t[i]=(int)(value + Math.random() * twopercents - twopercents / 2);
  }
  for (int i=800; i < 1000; i++) {
    t[i]=(int)(value + Math.random() * twopercents - twopercents / 2);
  }
  for (int i=1100; i < 1600; i++) {
    t[i]=(int)(value + Math.random() * twopercents - twopercents / 2);
  }
  new ShapeSoundTransformation(Library.defaultPack,"String_Node_Str",t).setObservers(new PrintlnTransformObserver(),new Observer(){
    @Override public void notify(    final LogEvent logEvent){
      messages.add(logEvent.toString());
    }
  }
).transform(200000,100,2,44100,1);
  Assert.assertTrue(messages.get(0).endsWith("String_Node_Str"));
  Assert.assertTrue(messages.get(1).endsWith("String_Node_Str"));
  Assert.assertTrue(messages.get(2).endsWith("String_Node_Str"));
}
Program: 81348
Project: 81348
Buggy source:
@Override public Sound initSound(Sound input){
  this.loudestfreqs=new LinkedList<Integer>();
  if (this.note) {
    this.threshold=input.getSamples().length;
    this.fsLimit=input.getSamples().length;
  }
 else {
    this.fsLimit=input.getSampleRate();
  }
  this.soundLength=input.getSamples().length;
  return super.initSound(input);
}

Fixed version (ground truth):
@Override public Sound initSound(Sound input){
  this.loudestfreqs=new ArrayList<Integer>();
  if (this.note) {
    this.threshold=input.getSamples().length;
    this.fsLimit=input.getSamples().length;
  }
 else {
    this.fsLimit=input.getSampleRate();
  }
  this.soundLength=input.getSamples().length;
  return super.initSound(input);
}
Program: 81349
Project: 81349
Buggy source:
@Override public Sound transform(Sound sound){
  int threshold=100;
  int channelNum=sound.getChannelNum();
  Sound builtSound=new Sound(new long[sound.getSamples().length],sound.getNbBytesPerSample(),sound.getSampleRate(),channelNum);
  List<Integer> freqs;
  this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str"));
  PeakFindWithHPSSoundTransformation peak=new PeakFindWithHPSSoundTransformation(100,-1);
  peak.setObservers(this.observers);
  peak.transform(sound);
  freqs=peak.getLoudestFreqs();
  double lastFreq=freqs.get(0);
  int lastBegining=0;
  for (int i=0; i < freqs.size(); i++) {
    this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str" + i + "String_Node_Str"+ freqs.size()));
    float length=(i - lastBegining < 1 ? freqs.size() * threshold : (i - 1 - lastBegining) * threshold) / sound.getSampleRate();
    if (i == freqs.size() - 1 || (Math.abs(freqs.get(i) - lastFreq) > freqs.get(i) / 100 && length > sound.getSampleRate() / 2)) {
      Note note=this.pack.get(this.instrument).getNearestNote((int)lastFreq);
      Sound attack=note.getAttack((int)lastFreq,channelNum,length);
      Sound decay=note.getDecay((int)lastFreq,channelNum,length);
      Sound sustain=note.getSustain((int)lastFreq,channelNum,length);
      Sound release=note.getRelease((int)lastFreq,channelNum,length);
      soundAppender.append(builtSound,threshold * lastBegining,attack,decay,sustain,release);
      lastBegining=i;
      lastFreq=freqs.get(i);
    }
  }
  return builtSound;
}

Fixed version (ground truth):
@Override public Sound transform(Sound sound){
  int threshold=100;
  int channelNum=sound.getChannelNum();
  Sound builtSound=new Sound(new long[sound.getSamples().length],sound.getNbBytesPerSample(),sound.getSampleRate(),channelNum);
  List<Integer> freqs;
  this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str"));
  PeakFindWithHPSSoundTransformation peak=new PeakFindWithHPSSoundTransformation(100,-1);
  peak.setObservers(this.observers);
  peak.transform(sound);
  freqs=peak.getLoudestFreqs();
  double lastFreq=freqs.get(0);
  int lastBegining=0;
  for (int i=0; i < freqs.size(); i++) {
    this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str" + i + "String_Node_Str"+ freqs.size()));
    float lengthInSeconds=(i - lastBegining < 1 ? freqs.size() * threshold : (i - 1 - lastBegining) * threshold) / sound.getSampleRate();
    if (i == freqs.size() - 1 || (Math.abs(freqs.get(i) - lastFreq) > freqs.get(i) / 100 && lengthInSeconds > 0.5)) {
      Note note=this.pack.get(this.instrument).getNearestNote((int)lastFreq);
      Sound attack=note.getAttack((int)lastFreq,channelNum,lengthInSeconds);
      Sound decay=note.getDecay((int)lastFreq,channelNum,lengthInSeconds);
      Sound sustain=note.getSustain((int)lastFreq,channelNum,lengthInSeconds);
      Sound release=note.getRelease((int)lastFreq,channelNum,lengthInSeconds);
      soundAppender.append(builtSound,threshold * lastBegining,attack,decay,sustain,release);
      lastBegining=i;
      lastFreq=freqs.get(i);
    }
  }
  return builtSound;
}
Program: 81350
Project: 81350
Buggy source:
@Override public Sound transform(Sound sound){
  int threshold=100;
  int channelNum=sound.getChannelNum();
  Sound builtSound=new Sound(new long[sound.getSamples().length],sound.getNbBytesPerSample(),sound.getSampleRate(),channelNum);
  List<Integer> freqs;
  this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str"));
  PeakFindWithHPSSoundTransformation peak=new PeakFindWithHPSSoundTransformation(100,-1);
  peak.setObservers(this.observers);
  peak.transform(sound);
  freqs=peak.getLoudestFreqs();
  double lastFreq=freqs.get(0);
  int lastBegining=0;
  for (int i=0; i < freqs.size(); i++) {
    this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str" + i + "String_Node_Str"+ freqs.size()));
    float lengthInSeconds=(i - lastBegining < 1 ? freqs.size() * threshold : (i - 1 - lastBegining) * threshold) / sound.getSampleRate();
    if (i == freqs.size() - 1 || (Math.abs(freqs.get(i) - lastFreq) > freqs.get(i) / 100 && lengthInSeconds > 0.5)) {
      Note note=this.pack.get(this.instrument).getNearestNote((int)lastFreq);
      Sound attack=note.getAttack((int)lastFreq,channelNum,lengthInSeconds);
      Sound decay=note.getDecay((int)lastFreq,channelNum,lengthInSeconds);
      Sound sustain=note.getSustain((int)lastFreq,channelNum,lengthInSeconds);
      Sound release=note.getRelease((int)lastFreq,channelNum,lengthInSeconds);
      soundAppender.append(builtSound,threshold * lastBegining,attack,decay,sustain,release);
      lastBegining=i;
      lastFreq=freqs.get(i);
    }
  }
  return builtSound;
}

Fixed version (ground truth):
@Override public Sound transform(Sound sound){
  int threshold=100;
  int channelNum=sound.getChannelNum();
  Sound builtSound=new Sound(new long[sound.getSamples().length],sound.getNbBytesPerSample(),sound.getSampleRate(),channelNum);
  List<Integer> freqs;
  this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str"));
  PeakFindWithHPSSoundTransformation peak=new PeakFindWithHPSSoundTransformation(threshold,-1);
  peak.setObservers(this.observers);
  peak.transform(sound);
  freqs=peak.getLoudestFreqs();
  double lastFreq=freqs.get(0);
  int lastBegining=0;
  for (int i=0; i < freqs.size(); i++) {
    this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str" + i + "String_Node_Str"+ freqs.size()));
    float lengthInSeconds=(i - lastBegining < 1 ? freqs.size() * threshold : (i - 1 - lastBegining) * threshold) / sound.getSampleRate();
    if (i == freqs.size() - 1 || (Math.abs(freqs.get(i) - lastFreq) > freqs.get(i) / 100 && lengthInSeconds > 0.5)) {
      Note note=this.pack.get(this.instrument).getNearestNote((int)lastFreq);
      Sound attack=note.getAttack((int)lastFreq,channelNum,lengthInSeconds);
      Sound decay=note.getDecay((int)lastFreq,channelNum,lengthInSeconds);
      Sound sustain=note.getSustain((int)lastFreq,channelNum,lengthInSeconds);
      Sound release=note.getRelease((int)lastFreq,channelNum,lengthInSeconds);
      soundAppender.append(builtSound,threshold * lastBegining,attack,decay,sustain,release);
      lastBegining=i;
      lastFreq=freqs.get(i);
    }
  }
  return builtSound;
}