nus-yam/ex-repair huggingface dataset:
Program: 81352
Project: 81352
Buggy source:
private float getRatio(Sound[] subsound){
  float lengthOfSubsound=1.0f * subsound[0].getSamples().length / subsound[0].getSampleRate();
  float lengthOfSound=1.0f * (this.attack[0].getSamples().length / this.attack[0].getSampleRate() + this.decay[0].getSamples().length / this.decay[0].getSampleRate() + this.sustain[0].getSamples().length / this.sustain[0].getSampleRate() + this.release[0].getSamples().length / this.release[0].getSampleRate());
  return lengthOfSubsound * 1.0f / lengthOfSound;
}

Fixed version (ground truth):
private float getRatio(Sound[] subsound){
  float lengthOfSubsound=1.0f * subsound[0].getSamples().length / subsound[0].getSampleRate();
  float lengthOfSound=(1.0f * this.attack[0].getSamples().length / this.attack[0].getSampleRate() + 1.0f * this.decay[0].getSamples().length / this.decay[0].getSampleRate() + 1.0f * this.sustain[0].getSamples().length / this.sustain[0].getSampleRate() + 1.0f * this.release[0].getSamples().length / this.release[0].getSampleRate());
  return lengthOfSubsound * 1.0f / lengthOfSound;
}
Program: 81353
Project: 81353
Buggy source:
@Override public Sound getSustain(int frequency,int channelnum,float length){
  return new SoundPitchAndTempoService().callTransform(this.get(this.sustain,channelnum),this.getPercent(frequency),(int)(this.getRatio(this.sustain) * length));
}

Fixed version (ground truth):
@Override public Sound getSustain(int frequency,int channelnum,float length){
  return new SoundPitchAndTempoService().callTransform(this.get(this.sustain,channelnum),this.getPercent(frequency),(float)(this.getRatio(this.sustain) * length));
}
Program: 81354
Project: 81354
Buggy source:
@Override public Sound getAttack(int frequency,int channelnum,float length){
  return new SoundPitchAndTempoService().callTransform(this.get(this.attack,channelnum),this.getPercent(frequency),(int)(this.getRatio(this.attack) * length));
}

Fixed version (ground truth):
@Override public Sound getAttack(int frequency,int channelnum,float length){
  return new SoundPitchAndTempoService().callTransform(this.get(this.attack,channelnum),this.getPercent(frequency),(float)(this.getRatio(this.attack) * length));
}
Program: 81355
Project: 81355
Buggy source:
@Override public Sound getDecay(int frequency,int channelnum,float length){
  return new SoundPitchAndTempoService().callTransform(this.get(this.decay,channelnum),this.getPercent(frequency),(int)(this.getRatio(this.decay) * length));
}

Fixed version (ground truth):
@Override public Sound getDecay(int frequency,int channelnum,float length){
  return new SoundPitchAndTempoService().callTransform(this.get(this.decay,channelnum),this.getPercent(frequency),(float)(this.getRatio(this.decay) * length));
}
Program: 81356
Project: 81356
Buggy source:
@Override public Sound getRelease(int frequency,int channelnum,float length){
  return new SoundPitchAndTempoService().callTransform(this.get(this.release,channelnum),this.getPercent(frequency),(int)(this.getRatio(this.release) * length));
}

Fixed version (ground truth):
@Override public Sound getRelease(int frequency,int channelnum,float length){
  return new SoundPitchAndTempoService().callTransform(this.get(this.release,channelnum),this.getPercent(frequency),(float)(this.getRatio(this.release) * length));
}
Program: 81357
Project: 81357
Buggy source:
public void testShape(){
  try {
    System.out.println("String_Node_Str");
    Library packsList=Library.getInstance();
    new TransformSoundService(new PrintlnTransformObserver()).transformFile(input,output,new EqualizerSoundTransformation(new double[]{0,20,50,100,120,140,160,180,200,220,1000,2000,5000,11000,22050},new double[]{0,0.5,0.75,1,1,1,1,0.70,0.30,0.00,0.00,0.00,0.00,0.00,0.00}),new NormalizeSoundTransformation(),new ShapeSoundTransformation(packsList.defaultPack,"String_Node_Str"));
  }
 catch (  UnsupportedAudioFileException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
@Test public void testShape(){
  try {
    System.out.println("String_Node_Str");
    Library packsList=Library.getInstance();
    new TransformSoundService(new PrintlnTransformObserver()).transformFile(input,output,new EqualizerSoundTransformation(new double[]{0,20,50,100,120,140,160,180,200,220,1000,2000,5000,11000,44100},new double[]{0,0.5,0.75,1,1,1,1,0.70,0.30,0.00,0.00,0.00,0.00,0.00,0.00}),new NormalizeSoundTransformation(),new ShapeSoundTransformation(packsList.defaultPack,"String_Node_Str"));
  }
 catch (  UnsupportedAudioFileException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}
Program: 81358
Project: 81358
Buggy source:
public AudioInputStream getAudioInputStream(File inputFile) throws UnsupportedAudioFileException, IOException {
  File tempFile=File.createTempFile("String_Node_Str","String_Node_Str");
  if (inputFile.getName().toLowerCase().endsWith("String_Node_Str")) {
    AudioInputStream ais=new javazoom.spi.mpeg.sampled.file.MpegAudioFileReader().getAudioInputStream(inputFile);
    AudioFormat cdFormat=new AudioFormat(44100,16,2,true,false);
    javazoom.spi.mpeg.sampled.convert.DecodedMpegAudioInputStream decodedais=new javazoom.spi.mpeg.sampled.convert.DecodedMpegAudioInputStream(cdFormat,ais);
    AudioSystem.write(decodedais,AudioFileFormat.Type.WAVE,tempFile);
  }
  return AudioSystem.getAudioInputStream(tempFile);
}

Fixed version (ground truth):
public AudioInputStream getAudioInputStream(File inputFile) throws UnsupportedAudioFileException, IOException {
  File readFile=inputFile;
  if (inputFile.getName().toLowerCase().endsWith("String_Node_Str")) {
    File tempFile=File.createTempFile("String_Node_Str","String_Node_Str");
    AudioInputStream ais=new javazoom.spi.mpeg.sampled.file.MpegAudioFileReader().getAudioInputStream(inputFile);
    AudioFormat cdFormat=new AudioFormat(44100,16,2,true,false);
    javazoom.spi.mpeg.sampled.convert.DecodedMpegAudioInputStream decodedais=new javazoom.spi.mpeg.sampled.convert.DecodedMpegAudioInputStream(cdFormat,ais);
    AudioSystem.write(decodedais,AudioFileFormat.Type.WAVE,tempFile);
    readFile=tempFile;
  }
  return AudioSystem.getAudioInputStream(readFile);
}
Program: 81359
Project: 81359
Buggy source:
public Sound transform(AbstractFrequencySoundTransformation st,Sound sound){
  Sound output=st.initSound(sound);
  double freqmax=sound.getSampleRate();
  double threshold=st.getLowThreshold(freqmax);
  int maxlength=st.getWindowLength(freqmax);
  long[] data=sound.getSamples();
  long[] newdata=output.getSamples();
  double[] transformeddata=new double[maxlength];
  FastFourierTransformer fastFourierTransformer=new FastFourierTransformer(DftNormalization.STANDARD);
  for (int i=0; i < data.length; i+=threshold) {
    int length=Math.min(maxlength,data.length - i);
    for (int j=i; j < i + length; j++) {
      transformeddata[j - i]=data[j];
    }
    Complex[] complexArray=fastFourierTransformer.transform(transformeddata,TransformType.FORWARD);
    Spectrum fs=new Spectrum(complexArray,(int)freqmax,sound.getNbBytesPerSample() / sound.getSamples().length);
    Spectrum result=st.transformFrequencies(fs,i,maxlength,length);
    if (result == null) {
      continue;
    }
    complexArray=fastFourierTransformer.transform(result.getState(),TransformType.INVERSE);
    int k=st.getOffsetFromASimpleLoop(i,freqmax);
    for (int j=0; j < freqmax; j++) {
      if (i + j + k < newdata.length && newdata[i + j + k] == 0) {
        newdata[i + j + k]=(long)Math.floor(complexArray[j].getReal());
      }
    }
  }
  return output;
}

Fixed version (ground truth):
public Sound transform(AbstractFrequencySoundTransformation st,Sound sound){
  Sound output=st.initSound(sound);
  double freqmax=sound.getSampleRate();
  double threshold=st.getLowThreshold(freqmax);
  int maxlength=st.getWindowLength(freqmax);
  long[] data=sound.getSamples();
  long[] newdata=output.getSamples();
  double[] transformeddata=new double[maxlength];
  FastFourierTransformer fastFourierTransformer=new FastFourierTransformer(DftNormalization.STANDARD);
  for (int i=0; i < data.length; i+=threshold) {
    int length=Math.min(maxlength,data.length - i);
    for (int j=i; j < i + length; j++) {
      transformeddata[j - i]=data[j];
    }
    Complex[] complexArray=fastFourierTransformer.transform(transformeddata,TransformType.FORWARD);
    Spectrum fs=new Spectrum(complexArray,(int)freqmax,sound.getNbBytesPerSample());
    Spectrum result=st.transformFrequencies(fs,i,maxlength,length);
    if (result == null) {
      continue;
    }
    complexArray=fastFourierTransformer.transform(result.getState(),TransformType.INVERSE);
    int k=st.getOffsetFromASimpleLoop(i,freqmax);
    for (int j=0; j < freqmax; j++) {
      if (i + j + k < newdata.length && newdata[i + j + k] == 0) {
        newdata[i + j + k]=(long)Math.floor(complexArray[j].getReal());
      }
    }
  }
  return output;
}
Program: 81360
Project: 81360
Buggy source:
public int getMaxIndex(Spectrum fs,int low,int high){
  double max=0;
  int maxIndex=0;
  int reallow=low == 0 ? 1 : low;
  int realhigh=Math.min(high,fs.getState().length);
  for (int i=reallow; i < realhigh; i++) {
    if (max < fs.getState()[i].abs() && fs.getState()[i].abs() > Math.pow(256,fs.getNbBytes()) / 2) {
      max=fs.getState()[i].abs();
      maxIndex=i;
    }
  }
  return maxIndex;
}

Fixed version (ground truth):
public int getMaxIndex(Spectrum fs,int low,int high){
  double max=0;
  int maxIndex=0;
  int reallow=low == 0 ? 1 : low;
  int realhigh=Math.min(high,fs.getState().length);
  for (int i=reallow; i < realhigh; i++) {
    if (max < fs.getState()[i].abs() && fs.getState()[i].abs() > Math.pow(256,fs.getNbBytes()) + 1) {
      max=fs.getState()[i].abs();
      maxIndex=i;
    }
  }
  return maxIndex;
}
Program: 81361
Project: 81361
Buggy source:
public Spectrum(Complex[] state,int sampleRate,int nbBytes){
  super();
  this.state=state;
  this.sampleRate=sampleRate;
}

Fixed version (ground truth):
public Spectrum(Complex[] state,int sampleRate,int nbBytes){
  super();
  this.state=state;
  this.sampleRate=sampleRate;
  this.nbBytes=nbBytes;
}
Program: 81362
Project: 81362
Buggy source:
private static Sound pitch(Sound sound,float percent){
  float total=100;
  if (percent == total) {
    return new Sound(sound.getSamples(),sound.getNbBytesPerSample(),sound.getSampleRate(),sound.getChannelNum());
  }
  float nbSamples=sound.getSamples().length;
  float nbFiltered=Math.abs(percent / total * nbSamples);
  float incr=nbSamples / nbFiltered;
  long[] data=sound.getSamples();
  long[] ret=new long[(int)(nbFiltered)];
  for (float i=0; i < incr * nbFiltered; i+=incr) {
    int j=(int)(i / incr);
    if (j < ret.length) {
      ret[j]=data[(int)i];
    }
  }
  return new Sound(ret,sound.getNbBytesPerSample(),sound.getSampleRate(),sound.getChannelNum());
}

Fixed version (ground truth):
private static Sound pitch(Sound sound,float percent){
  float total=100;
  if (percent == total) {
    return new Sound(sound.getSamples(),sound.getNbBytesPerSample(),sound.getSampleRate(),sound.getChannelNum());
  }
  float nbSamples=sound.getSamples().length;
  float nbFiltered=Math.abs(total * nbSamples / percent);
  float incr=nbSamples / nbFiltered;
  long[] data=sound.getSamples();
  long[] ret=new long[(int)(nbFiltered)];
  for (float i=0; i < incr * nbFiltered; i+=incr) {
    int j=(int)(i / incr);
    if (j < ret.length) {
      ret[j]=data[(int)i];
    }
  }
  return new Sound(ret,sound.getNbBytesPerSample(),sound.getSampleRate(),sound.getChannelNum());
}
Program: 81363
Project: 81363
Buggy source:
@Test public void testPitch(){
  try {
    new TransformSoundService(new PrintlnTransformObserver()).transformFile(input,output,new PitchSoundTransformation(85));
  }
 catch (  UnsupportedAudioFileException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
@Test public void testPitch(){
  try {
    new TransformSoundService(new PrintlnTransformObserver()).transformFile(input,output,new PitchSoundTransformation(100));
  }
 catch (  UnsupportedAudioFileException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}
Program: 81364
Project: 81364
Buggy source:
private static Sound upsampleWithRatio(Sound sound,float ratio){
  float appendWhileLessThanOrEqualsRatio=0;
  int indexResult=0;
  long[] result=new long[(int)Math.ceil(sound.getSamples().length * ratio)];
  for (int i=0; i < sound.getSamples().length; i++) {
    while (appendWhileLessThanOrEqualsRatio <= ratio) {
      result[indexResult++]=sound.getSamples()[i];
      appendWhileLessThanOrEqualsRatio++;
    }
    appendWhileLessThanOrEqualsRatio-=ratio;
  }
  return new Sound(result,sound.getNbBytesPerSample(),(int)(sound.getSampleRate() * ratio),sound.getChannelNum());
}

Fixed version (ground truth):
private static Sound upsampleWithRatio(Sound sound,float ratio){
  float appendWhileLessThanOrEqualsRatio=0;
  int indexResult=0;
  long[] result=new long[(int)Math.ceil(sound.getSamples().length * (ratio + 1))];
  for (int i=0; i < sound.getSamples().length; i++) {
    while (appendWhileLessThanOrEqualsRatio <= ratio) {
      result[indexResult++]=sound.getSamples()[i];
      appendWhileLessThanOrEqualsRatio++;
    }
    appendWhileLessThanOrEqualsRatio-=ratio;
  }
  return new Sound((indexResult == 0 ? new long[0] : Arrays.copyOfRange(result,0,indexResult - 1)),sound.getNbBytesPerSample(),(int)(sound.getSampleRate() * ratio),sound.getChannelNum());
}
Program: 81366
Project: 81366
Buggy source:
private Sound transformSubsound(Sound[] subSound,int channelNum,int frequency,int length){
  int percent=(int)(frequency * 100.0 / this.frequency);
  Sound result=subSound[channelNum];
  PitchSoundTransformation pitcher=new PitchSoundTransformation(percent);
  if (percent < 98 || percent > 102) {
    result=pitcher.transform(result);
  }
  double factor=subSound[0].getSamples().length == 0 ? 0 : length * 1.0 / result.getSamples().length;
  if (factor == 0) {
    return result;
  }
 else   if (factor < 0.98 || factor > 1.02) {
    if (factor < 0.98) {
      SpeedUpSoundTransformation speedup=new SpeedUpSoundTransformation(100,(float)(1 / factor));
      result=speedup.transform(result);
    }
 else     if (factor > 1.02) {
      SlowdownSoundTransformation slowdown=new SlowdownSoundTransformation(100,(float)factor);
      result=slowdown.transform(result);
    }
  }
  return result;
}

Fixed version (ground truth):
private Sound transformSubsound(Sound[] subSound,int channelNum,int frequency,int length){
  int percent=(int)(frequency * 100.0 / this.frequency);
  Sound result=subSound[(subSound.length > channelNum ? channelNum : subSound.length - 1)];
  PitchSoundTransformation pitcher=new PitchSoundTransformation(percent);
  if (percent < 98 || percent > 102) {
    result=pitcher.transform(result);
  }
  double factor=subSound[0].getSamples().length == 0 ? 0 : length * 1.0 / result.getSamples().length;
  if (factor == 0) {
    return result;
  }
 else   if (factor < 0.98 || factor > 1.02) {
    if (factor < 0.98) {
      SpeedUpSoundTransformation speedup=new SpeedUpSoundTransformation(100,(float)(1 / factor));
      result=speedup.transform(result);
    }
 else     if (factor > 1.02) {
      SlowdownSoundTransformation slowdown=new SlowdownSoundTransformation(100,(float)factor);
      result=slowdown.transform(result);
    }
  }
  return result;
}
Program: 81367
Project: 81367
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.getFreq(),channelNum);
  List<Integer> freqs;
  this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str"));
  PeakFindSoundTransformation peak=new PeakFindSoundTransformation(threshold);
  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()));
    int length=(i - 1 - lastBegining) * threshold;
    if (Math.abs(freqs.get(i) - lastFreq) > freqs.get(i) / 100 && length > sound.getFreq() / 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);
      builtSound.append(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.getFreq(),channelNum);
  List<Integer> freqs;
  this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str"));
  PeakFindSoundTransformation peak=new PeakFindSoundTransformation(threshold);
  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()));
    int length=(i - 1 - lastBegining) * threshold;
    if (i == freqs.size() - 1 || (Math.abs(freqs.get(i) - lastFreq) > freqs.get(i) / 100 && length > sound.getFreq() / 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);
      builtSound.append(threshold * lastBegining,attack,decay,sustain,release);
      lastBegining=i;
      lastFreq=freqs.get(i);
    }
  }
  return builtSound;
}
Program: 81369
Project: 81369
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   if (this.windowLength != -1) {
    this.fsLimit=input.getSampleRate();
  }
  return super.initSound(input);
}

Fixed version (ground truth):
@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();
  }
  return super.initSound(input);
}
Program: 81370
Project: 81370
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,(int)Math.pow(2,Math.ceil(Math.log(sound.getSamples().length) / Math.log(2))));
  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()));
    int length=(i - lastBegining < 1 ? freqs.size() * threshold : (i - 1 - lastBegining) * threshold);
    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.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()));
    int length=(i - lastBegining < 1 ? freqs.size() * threshold : (i - 1 - lastBegining) * threshold);
    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;
}
Program: 81371
Project: 81371
Buggy source:
public void testShape(){
  try {
    System.out.println("String_Node_Str");
    Library packsList=Library.getInstance();
    new TransformSoundService(new PrintlnTransformObserver()).transformFile(input,output,new EqualizerSoundTransformation(new double[]{0,20,50,100,120,140,160,180,200,220,1000,2000,5000,11000,22050},new double[]{0,0.5,0.75,1,1,1,1,0.70,0.30,0.00,0.00,0.00,0.00,0.00,0.00}),new NormalizeSoundTransformation(),new ShapeSoundTransformation(packsList.defaultPack,"String_Node_Str"));
  }
 catch (  UnsupportedAudioFileException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
@Test public void testShape(){
  try {
    System.out.println("String_Node_Str");
    Library packsList=Library.getInstance();
    new TransformSoundService(new PrintlnTransformObserver()).transformFile(input,output,new EqualizerSoundTransformation(new double[]{0,20,50,100,120,140,160,180,200,220,1000,2000,5000,11000,22050},new double[]{0,0.5,0.75,1,1,1,1,0.70,0.30,0.00,0.00,0.00,0.00,0.00,0.00}),new NormalizeSoundTransformation(),new ShapeSoundTransformation(packsList.defaultPack,"String_Node_Str"));
  }
 catch (  UnsupportedAudioFileException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}
Program: 81372
Project: 81372
Buggy source:
public Sound toSubSound(int beginning,int end){
  long[] newsamples=Arrays.copyOfRange(this.samples,beginning,end);
  return new Sound(newsamples,nbBytesPerSample,freq,channelNum);
}

Fixed version (ground truth):
public Sound toSubSound(int beginning,int end){
  long[] newsamples=(beginning < end ? Arrays.copyOfRange(this.samples,beginning,end) : new long[0]);
  return new Sound(newsamples,nbBytesPerSample,freq,channelNum);
}
Program: 81373
Project: 81373
Buggy source:
private static int getMaxIndex(FrequenciesState fs,int low,int high){
  int max=0;
  int maxIndex=0;
  for (int i=low; i < high; i++) {
    if (max < fs.getState()[i].abs()) {
      max=(int)Math.ceil(fs.getState()[i].abs());
      maxIndex=i;
    }
  }
  return maxIndex;
}

Fixed version (ground truth):
private static int getMaxIndex(FrequenciesState fs,int low,int high){
  int max=0;
  int maxIndex=0;
  int realhigh=Math.min(high,fs.getState().length);
  for (int i=low; i < realhigh; i++) {
    if (max < fs.getState()[i].abs()) {
      max=(int)Math.ceil(fs.getState()[i].abs());
      maxIndex=i;
    }
  }
  return maxIndex;
}
Program: 81375
Project: 81375
Buggy source:
private int bestCandidate(int[] peaks){
  int leftEdge=0;
  while (leftEdge < peaks.length && peaks[leftEdge] == 0) {
    leftEdge++;
  }
  int rightEdge=leftEdge;
  while (rightEdge < peaks.length && Math.abs((peaks[rightEdge] - peaks[leftEdge]) * 1.0 / peaks[rightEdge]) * 100.0 < 10) {
    rightEdge++;
  }
  int sum=0;
  for (int i=leftEdge; i < rightEdge; i++) {
    sum+=peaks[i];
  }
  return (rightEdge == leftEdge ? sum : sum / (rightEdge - leftEdge));
}

Fixed version (ground truth):
private int bestCandidate(int[] peaks){
  int leftEdge=0;
  while (leftEdge < peaks.length && peaks[leftEdge] <= 0) {
    leftEdge++;
  }
  int rightEdge=leftEdge;
  while (rightEdge < peaks.length && Math.abs((peaks[rightEdge] - peaks[leftEdge]) * 1.0 / peaks[rightEdge]) * 100.0 < 10) {
    rightEdge++;
  }
  int sum=0;
  for (int i=leftEdge; i < rightEdge; i++) {
    sum+=peaks[i];
  }
  return (rightEdge == leftEdge ? sum : sum / (rightEdge - leftEdge));
}
Program: 81376
Project: 81376
Buggy source:
public PurifySoundTransformation(){
}

Fixed version (ground truth):
public PurifySoundTransformation(int increment){
  this.increment=increment;
}
Program: 81377
Project: 81377
Buggy source:
@Test public void testPurify(){
  try {
    new TransformSound(new PrintlnTransformObserver()).transformFile(input,output,new PurifySoundTransformation());
  }
 catch (  UnsupportedAudioFileException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
@Test public void testPurify(){
  try {
    new TransformSound(new PrintlnTransformObserver()).transformFile(input,output,new PurifySoundTransformation(100));
  }
 catch (  UnsupportedAudioFileException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}
Program: 81378
Project: 81378
Buggy source:
@Override public FrequenciesState transformFrequencies(FrequenciesState fs,int offset,int powOf2NearestLength,int length){
  for (int i=0; i < fs.getState().length; i++) {
    Complex c=fs.getState()[i];
    double abs=c.abs();
    double abs2=Math.pow(abs,2);
    double log=Math.log(abs2);
    fs.getState()[i]=new Complex(log);
  }
  FastFourierTransformer fastFourierTransformer=new FastFourierTransformer(DftNormalization.STANDARD);
  FrequenciesState fscep=new FrequenciesState(fastFourierTransformer.transform(fs.getState(),TransformType.INVERSE),fs.getMaxfrequency());
  this.loudestfreqs[index]=this.computeLoudestFreq(fscep);
  ;
  this.index++;
  return fscep;
}

Fixed version (ground truth):
@Override public FrequenciesState transformFrequencies(FrequenciesState fs,int offset,int powOf2NearestLength,int length){
  for (int i=0; i < fs.getState().length; i++) {
    Complex c=fs.getState()[i];
    double abs=c.abs();
    double abs2=Math.pow(abs,2);
    double log=Math.log(abs2);
    fs.getState()[i]=new Complex(log);
  }
  FastFourierTransformer fastFourierTransformer=new FastFourierTransformer(DftNormalization.STANDARD);
  FrequenciesState fscep=new FrequenciesState(fastFourierTransformer.transform(fs.getState(),TransformType.INVERSE),fs.getMaxfrequency());
  this.loudestfreqs[index]=this.computeLoudestFreq(fscep);
  this.index++;
  return fscep;
}
Program: 81379
Project: 81379
Buggy source:
private int bestCandidate(int[] peaks){
  int leftEdge=0;
  while (leftEdge < peaks.length && peaks[leftEdge] == 0) {
    leftEdge++;
  }
  int rightEdge=leftEdge;
  while (rightEdge < peaks.length && Math.abs((peaks[rightEdge] - peaks[leftEdge]) * 1.0 / peaks[rightEdge]) * 100.0 < 10) {
    rightEdge++;
  }
  int sum=0;
  for (int i=leftEdge; i < rightEdge; i++) {
    sum+=peaks[i];
  }
  return sum / (rightEdge - leftEdge);
}

Fixed version (ground truth):
private int bestCandidate(int[] peaks){
  int leftEdge=0;
  while (leftEdge < peaks.length && peaks[leftEdge] == 0) {
    leftEdge++;
  }
  int rightEdge=leftEdge;
  while (rightEdge < peaks.length && Math.abs((peaks[rightEdge] - peaks[leftEdge]) * 1.0 / peaks[rightEdge]) * 100.0 < 10) {
    rightEdge++;
  }
  int sum=0;
  for (int i=leftEdge; i < rightEdge; i++) {
    sum+=peaks[i];
  }
  return (rightEdge == leftEdge ? sum : sum / (rightEdge - leftEdge));
}
Program: 81380
Project: 81380
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.getFreq(),channelNum);
  int[] freqs;
  this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str"));
  CepstrumSoundTransformation peak=new CepstrumSoundTransformation(threshold);
  peak.transform(sound);
  freqs=peak.getLoudestFreqs();
  double lastFreq=freqs[0];
  int lastBegining=0;
  for (int i=0; i < freqs.length; i++) {
    this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str" + i + "String_Node_Str"+ freqs.length));
    int length=(i - 1 - lastBegining) * threshold;
    if (Math.abs(freqs[i] - lastFreq) > freqs[i] / 100 && length > sound.getFreq() / 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);
      builtSound.append(threshold * lastBegining,attack,decay,sustain,release);
      lastBegining=i;
      lastFreq=freqs[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.getFreq(),channelNum);
  int[] freqs;
  this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str"));
  PeakFindSoundTransformation peak=new PeakFindSoundTransformation(threshold);
  peak.transform(sound);
  freqs=peak.getLoudestFreqs();
  double lastFreq=freqs[0];
  int lastBegining=0;
  for (int i=0; i < freqs.length; i++) {
    this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str" + i + "String_Node_Str"+ freqs.length));
    int length=(i - 1 - lastBegining) * threshold;
    if (Math.abs(freqs[i] - lastFreq) > freqs[i] / 100 && length > sound.getFreq() / 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);
      builtSound.append(threshold * lastBegining,attack,decay,sustain,release);
      lastBegining=i;
      lastFreq=freqs[i];
    }
  }
  return builtSound;
}
Program: 81381
Project: 81381
Buggy source:
@Override public FrequenciesState transformFrequencies(FrequenciesState fs,int offset,int powOf2NearestLength,int length){
  int[] peaks=new int[10];
  for (int i=1; i <= 10; i++) {
    peaks[i - 1]=FrequenciesHelper.f0(fs,i);
  }
  Arrays.sort(peaks);
  int f0=this.bestCandidate(peaks);
  this.loudestfreqs[index]=f0;
  this.index++;
  return fs;
}

Fixed version (ground truth):
@Override public FrequenciesState transformFrequencies(FrequenciesState fs,int offset,int powOf2NearestLength,int length){
  int[] peaks=new int[10];
  for (int i=1; i <= 10; i++) {
    peaks[i - 1]=FrequenciesHelper.f0(fs,i);
  }
  Arrays.sort(peaks);
  int f0=this.bestCandidate(peaks);
  if (this.index < this.loudestfreqs.length) {
    this.loudestfreqs[this.index]=f0;
  }
  this.index++;
  return fs;
}
Program: 81382
Project: 81382
Buggy source:
private static FrequenciesState hpc(FrequenciesState fs,int factor){
  Complex[] result=new Complex[fs.getMaxfrequency() / (2 * factor)];
  for (int i=0; i < fs.getMaxfrequency() / (2 * factor); i++) {
    double val=fs.getState()[i].abs();
    for (int j=1; j < factor; j++) {
      if (i * factor < fs.getMaxfrequency() / 2 && i * factor < fs.getState().length) {
        val*=fs.getState()[i * factor].abs();
      }
    }
    result[i]=new Complex(val);
  }
  return new FrequenciesState(result,fs.getMaxfrequency() / factor);
}

Fixed version (ground truth):
private static FrequenciesState hpc(FrequenciesState fs,int factor){
  int max=Math.min(fs.getMaxfrequency() / (2 * factor),fs.getState().length);
  Complex[] result=new Complex[max];
  for (int i=0; i < max; i++) {
    double val=fs.getState()[i].abs();
    for (int j=1; j < factor; j++) {
      if (i * factor < fs.getMaxfrequency() / 2 && i * factor < fs.getState().length) {
        val*=fs.getState()[i * factor].abs();
      }
    }
    result[i]=new Complex(val);
  }
  return new FrequenciesState(result,fs.getMaxfrequency() / factor);
}
Program: 81383
Project: 81383
Buggy source:
public static int loudestMultiple(FrequenciesState fs,int f0,int low,int high){
  if (f0 == 0) {
    return 0;
  }
  int loudest=f0;
  double loudestValue=fs.getState()[f0].abs();
  int i=Math.max(f0,low);
  while (i < high) {
    if (fs.getState()[i].abs() > loudestValue) {
      loudest=i;
      loudestValue=fs.getState()[i].abs();
    }
    i+=f0;
  }
  return loudest;
}

Fixed version (ground truth):
public static int loudestMultiple(FrequenciesState fs,int f0,int low,int high){
  if (f0 == 0) {
    return 0;
  }
  int loudest=f0;
  double loudestValue=fs.getState()[f0].abs();
  int i=Math.max(f0,low);
  int realhigh=Math.min(high,fs.getState().length);
  while (i < realhigh) {
    if (fs.getState()[i].abs() > loudestValue) {
      loudest=i;
      loudestValue=fs.getState()[i].abs();
    }
    i+=f0;
  }
  return loudest;
}
Program: 81384
Project: 81384
Buggy source:
public static FrequenciesState spectrumToCepstrum(FrequenciesState fs){
  for (int i=0; i < fs.getState().length; i++) {
    Complex c=fs.getState()[i];
    double log=Math.log(Math.pow(c.abs(),2));
    fs.getState()[i]=new Complex(log);
  }
  FastFourierTransformer fastFourierTransformer=new FastFourierTransformer(DftNormalization.STANDARD);
  FrequenciesState fscep=new FrequenciesState(fastFourierTransformer.transform(fs.getState(),TransformType.FORWARD),fs.getMaxfrequency());
  for (int i=0; i < fscep.getState().length; i++) {
    Complex c=fscep.getState()[i];
    double sqr=Math.pow(c.abs(),2);
    fscep.getState()[i]=new Complex(sqr);
  }
  return fscep;
}

Fixed version (ground truth):
public static FrequenciesState spectrumToCepstrum(FrequenciesState fs){
  for (int i=0; i < fs.getState().length; i++) {
    Complex c=fs.getState()[i];
    double log=Math.log(Math.pow(c.abs(),2));
    fs.getState()[i]=new Complex(log);
  }
  FastFourierTransformer fastFourierTransformer=new FastFourierTransformer(DftNormalization.STANDARD);
  FrequenciesState fscep=new FrequenciesState(fastFourierTransformer.transform(fs.getState(),TransformType.FORWARD),fs.getMaxfrequency());
  for (int i=0; i < fscep.getState().length; i++) {
    Complex c=fscep.getState()[i];
    double sqr=Math.pow(c.abs(),2);
    fscep.getState()[i]=new Complex(sqr);
  }
  for (int i=0; i < 50; i++) {
    fscep.getState()[i]=new Complex(0);
  }
  for (int i=fscep.getState().length - 50; i < fscep.getState().length; i++) {
    fscep.getState()[i]=new Complex(0);
  }
  return fscep;
}
Program: 81385
Project: 81385
Buggy source:
private static int findFrequency(Sound channel1){
  double sum=0;
  int nb=0;
  PeakFindSoundTransformation peak=new PeakFindSoundTransformation(100);
  peak.transform(channel1);
  int[] magnitude=peak.getLoudestFreqs();
  for (int i=0; i < magnitude.length; i++) {
    if (magnitude[i] > 70) {
      sum+=magnitude[i];
      nb++;
    }
  }
  return (int)(sum / nb);
}

Fixed version (ground truth):
private static int findFrequency(Sound channel1){
  double sum=0;
  int nb=0;
  PeakFindSoundTransformation peak=new PeakFindSoundTransformation(100);
  peak.transform(channel1);
  int[] magnitude=peak.getLoudestFreqs();
  for (int i=0; i < magnitude.length; i++) {
    sum+=magnitude[i];
    nb++;
  }
  return (int)(sum / nb);
}
Program: 81386
Project: 81386
Buggy source:
@Override public Sound initSound(Sound input){
  this.loudestfreqs=new int[(int)(input.getSamples().length / threshold) + 1];
  this.index=0;
  return super.initSound(input);
}

Fixed version (ground truth):
@Override public Sound initSound(Sound input){
  this.loudestfreqs=new int[(int)(input.getSamples().length / threshold) + 1];
  this.index=0;
  this.length=input.getSamples().length;
  if (this.length < CepstrumSoundTransformation.shortSoundLength) {
    this.loudestfreqs=new int[1];
  }
 else {
    this.loudestfreqs=new int[(int)(input.getSamples().length / threshold) + 1];
  }
  return super.initSound(input);
}
Program: 81387
Project: 81387
Buggy source:
@Override protected double getLowThreshold(double defaultValue){
  return this.threshold;
}

Fixed version (ground truth):
@Override protected double getLowThreshold(double defaultValue){
  if (this.length < CepstrumSoundTransformation.shortSoundLength) {
    return this.length;
  }
  return this.threshold;
}
Program: 81388
Project: 81388
Buggy source:
@Override public FrequenciesState transformFrequencies(FrequenciesState fs,int offset,int powOf2NearestLength,int length){
  int f0=FrequenciesHelper.f0(fs,10);
  int fk=FrequenciesHelper.loudestMultiple(fs,f0,50,1200);
  this.loudestfreqs[index]=fk;
  this.index++;
  return fs;
}

Fixed version (ground truth):
@Override public FrequenciesState transformFrequencies(FrequenciesState fs,int offset,int powOf2NearestLength,int length){
  int avg=0;
  int nb=0;
  for (int i=1; i < 10; i++) {
    int f0=FrequenciesHelper.f0(fs,i);
    int fk=FrequenciesHelper.loudestMultiple(fs,f0,50,1200);
    if (fk != 0) {
      avg+=fk;
      nb++;
    }
  }
  this.loudestfreqs[index]=avg / nb;
  this.index++;
  return fs;
}
Program: 81389
Project: 81389
Buggy source:
private static Sound pitch(Sound sound,float percent){
  float total=100;
  if (percent == total) {
    return new Sound(sound.getSamples(),sound.getNbBytesPerSample(),sound.getFreq(),sound.getChannelNum());
  }
  float nbSamples=sound.getSamples().length;
  float nbFiltered=percent / total * nbSamples;
  float incr=nbSamples / nbFiltered;
  long[] data=sound.getSamples();
  long[] ret=new long[(int)(nbFiltered)];
  for (float i=0; i < incr * nbFiltered; i+=incr) {
    int j=(int)(i / incr);
    if (j < ret.length) {
      ret[j]=data[(int)i];
    }
  }
  return new Sound(ret,sound.getNbBytesPerSample(),sound.getFreq(),sound.getChannelNum());
}

Fixed version (ground truth):
private static Sound pitch(Sound sound,float percent){
  float total=100;
  if (percent == total) {
    return new Sound(sound.getSamples(),sound.getNbBytesPerSample(),sound.getFreq(),sound.getChannelNum());
  }
  float nbSamples=sound.getSamples().length;
  float nbFiltered=Math.abs(percent / total * nbSamples);
  float incr=nbSamples / nbFiltered;
  long[] data=sound.getSamples();
  long[] ret=new long[(int)(nbFiltered)];
  for (float i=0; i < incr * nbFiltered; i+=incr) {
    int j=(int)(i / incr);
    if (j < ret.length) {
      ret[j]=data[(int)i];
    }
  }
  return new Sound(ret,sound.getNbBytesPerSample(),sound.getFreq(),sound.getChannelNum());
}
Program: 81390
Project: 81390
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.getFreq(),channelNum);
  double[] freqs=new double[sound.getSamples().length / threshold + 1];
  this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str"));
  Sound2Note.getSoundLoudestFreqs(freqs,sound,threshold);
  double lastFreq=freqs[0];
  int lastBegining=0;
  for (int i=0; i < freqs.length; i++) {
    this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str" + i + "String_Node_Str"+ freqs.length));
    int length=(i - 1 - lastBegining) * threshold;
    if (Math.abs(freqs[i] - lastFreq) > freqs[i] / 100 && length > sound.getFreq() / 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);
      builtSound.append(threshold * i,attack,decay,sustain,release);
      lastBegining=i;
      lastFreq=freqs[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.getFreq(),channelNum);
  double[] freqs=new double[sound.getSamples().length / threshold + 1];
  this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str"));
  Sound2Note.getSoundLoudestFreqs(freqs,sound,threshold);
  double lastFreq=freqs[0];
  int lastBegining=0;
  for (int i=0; i < freqs.length; i++) {
    this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str" + i + "String_Node_Str"+ freqs.length));
    int length=(i - 1 - lastBegining) * threshold;
    if (Math.abs(freqs[i] - lastFreq) > freqs[i] / 100 && length > sound.getFreq() / 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);
      builtSound.append(threshold * lastBegining,attack,decay,sustain,release);
      lastBegining=i;
      lastFreq=freqs[i];
    }
  }
  return builtSound;
}
Program: 81391
Project: 81391
Buggy source:
@Override protected FrequenciesState transformFrequencies(FrequenciesState fs,int offset,int powOf2NearestLength,int length,double maxfrequency){
  int total=(int)(this.sound.getSamples().length * factor);
  if (offset % ((total / 100 - (total / 100) % this.threshold)) == 0) {
    this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str" + offset + "String_Node_Str"+ (int)(sound.getSamples().length / factor)));
  }
  FastFourierTransformer fastFourierTransformer=new FastFourierTransformer(DftNormalization.STANDARD);
  Complex[] complexArray=fs.getState();
  float remaining=(float)(factor - Math.floor(factor));
  int padding=(int)Math.floor(this.writeIfGreaterEqThan1 + remaining);
  int loops=(int)(factor + padding - 1);
  this.additionalFrames+=loops;
  for (int p=0; p < loops; p++) {
    complexArray=fastFourierTransformer.transform(complexArray,TransformType.INVERSE);
    for (int j=0; j < maxfrequency; j++) {
      if (offset + p * maxfrequency + j < this.sound.getSamples().length && this.sound.getSamples()[(int)(offset + p * maxfrequency + j)] == 0) {
        this.sound.getSamples()[(int)(offset + p * maxfrequency + j)]=(long)Math.floor(complexArray[j].getReal());
      }
    }
  }
  if (padding == 1) {
    this.writeIfGreaterEqThan1-=1;
  }
 else {
    this.writeIfGreaterEqThan1+=remaining;
  }
  return fs;
}

Fixed version (ground truth):
@Override protected FrequenciesState transformFrequencies(FrequenciesState fs,int offset,int powOf2NearestLength,int length,double maxfrequency){
  int total=(int)(this.sound.getSamples().length * factor);
  if (total / 100 != 0 && (total / 100 - (total / 100) % this.threshold) != 0 && offset % ((total / 100 - (total / 100) % this.threshold)) == 0) {
    this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str" + offset + "String_Node_Str"+ (int)(sound.getSamples().length / factor)));
  }
  FastFourierTransformer fastFourierTransformer=new FastFourierTransformer(DftNormalization.STANDARD);
  Complex[] complexArray=fs.getState();
  float remaining=(float)(factor - Math.floor(factor));
  int padding=(int)Math.floor(this.writeIfGreaterEqThan1 + remaining);
  int loops=(int)(factor + padding - 1);
  this.additionalFrames+=loops;
  for (int p=0; p < loops; p++) {
    complexArray=fastFourierTransformer.transform(complexArray,TransformType.INVERSE);
    for (int j=0; j < maxfrequency; j++) {
      if (offset + p * maxfrequency + j < this.sound.getSamples().length && this.sound.getSamples()[(int)(offset + p * maxfrequency + j)] == 0) {
        this.sound.getSamples()[(int)(offset + p * maxfrequency + j)]=(long)Math.floor(complexArray[j].getReal());
      }
    }
  }
  if (padding == 1) {
    this.writeIfGreaterEqThan1-=1;
  }
 else {
    this.writeIfGreaterEqThan1+=remaining;
  }
  return fs;
}
Program: 81392
Project: 81392
Buggy source:
@Override protected FrequenciesState transformFrequencies(FrequenciesState fs,int offset,int powOf2NearestLength,int length,double maxfrequency){
  int total=(int)(this.sound.getSamples().length / factor);
  if (total != 0 && offset % ((total / 100 - (total / 100) % this.threshold)) == 0) {
    this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str" + offset + "String_Node_Str"+ (int)(sound.getSamples().length * factor)));
  }
  if (this.writeIfGreaterEqThanFactor >= factor) {
    this.writeIfGreaterEqThanFactor-=factor;
    return fs;
  }
 else {
    this.writeIfGreaterEqThanFactor++;
    return null;
  }
}

Fixed version (ground truth):
@Override protected FrequenciesState transformFrequencies(FrequenciesState fs,int offset,int powOf2NearestLength,int length,double maxfrequency){
  int total=(int)(this.sound.getSamples().length / factor);
  if (total / 100 != 0 && (total / 100 - (total / 100) % this.threshold) != 0 && offset % ((total / 100 - (total / 100) % this.threshold)) == 0) {
    this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str" + offset + "String_Node_Str"+ (int)(sound.getSamples().length * factor)));
  }
  if (this.writeIfGreaterEqThanFactor >= factor) {
    this.writeIfGreaterEqThanFactor-=factor;
    return fs;
  }
 else {
    this.writeIfGreaterEqThanFactor++;
    return null;
  }
}
Program: 81393
Project: 81393
Buggy source:
@Override protected Sound initSound(Sound input){
  long[] newdata=new long[(int)(input.getSamples().length * factor)];
  this.sound=new Sound(newdata,input.getNbBytesPerSample(),input.getFreq(),sound.getChannelNum());
  return this.sound;
}

Fixed version (ground truth):
@Override protected Sound initSound(Sound input){
  long[] newdata=new long[(int)(input.getSamples().length * factor)];
  this.sound=new Sound(newdata,input.getNbBytesPerSample(),input.getFreq(),input.getChannelNum());
  return this.sound;
}
Program: 81394
Project: 81394
Buggy source:
protected static double computeLoudestFreq(FrequenciesState fs){
  double max=0;
  double freq=0;
  for (int i=0; i < fs.getMaxfrequency() / 2; i++) {
    double val=fs.getState()[i].abs();
    freq=(max < val ? i : freq);
    max=(max < val ? val : max);
  }
  return freq;
}

Fixed version (ground truth):
protected static double computeLoudestFreq(FrequenciesState fs){
  double max=0;
  double freq=0;
  for (int i=0; i < fs.getMaxfrequency() / 2; i++) {
    double val=Math.pow(fs.getState()[i].abs(),2);
    freq=(max < val ? i : freq);
    max=(max < val ? val : max);
  }
  return freq;
}
Program: 81395
Project: 81395
Buggy source:
@Override public Sound initSound(Sound input){
  this.loudestfreqs=new int[input.getSamples().length];
  this.i=0;
  return super.initSound(input);
}

Fixed version (ground truth):
@Override public Sound initSound(Sound input){
  this.loudestfreqs=new int[(int)(input.getSamples().length / threshold) + 1];
  this.index=0;
  return super.initSound(input);
}
Program: 81396
Project: 81396
Buggy source:
private void computeLoudestFreq(FrequenciesState fs){
  double max=0;
  double freq=0;
  for (int j=0; j < fs.getMaxfrequency() / 2; j++) {
    double val=fs.getState()[j].abs();
    freq=(max < val ? i : freq);
    max=(max < val ? val : max);
  }
  this.loudestfreqs[i]=(int)freq;
}

Fixed version (ground truth):
private void computeLoudestFreq(FrequenciesState fs){
  double max=0;
  double freq=0;
  for (int j=50; j < 900; j++) {
    double val=fs.getState()[j].abs();
    freq=(max < val ? j : freq);
    max=(max < val ? val : max);
  }
  this.loudestfreqs[index]=(int)freq;
}