nus-yam/ex-repair huggingface dataset:
Program: 81397
Project: 81397
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.computeLoudestFreq(fscep);
  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.computeLoudestFreq(fscep);
  this.index++;
  return fscep;
}
Program: 81398
Project: 81398
Buggy source:
protected static double computeLoudestFreq(FrequenciesState fs,int maxFrequency){
  double max=0;
  double freq=0;
  for (int i=0; i < maxFrequency; 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,int maxFrequency){
  double max=0;
  double freq=0;
  for (int i=0; i < maxFrequency / 2; i++) {
    double val=fs.getState()[i].abs();
    freq=(max < val ? i : freq);
    max=(max < val ? val : max);
  }
  return freq;
}
Program: 81399
Project: 81399
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;
  int usedarraylength=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=builtSound.concat(true,usedarraylength,attack,decay,sustain,release);
      usedarraylength+=threshold;
      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) {
      System.out.println(length);
      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;
}
Program: 81400
Project: 81400
Buggy source:
protected byte[] framesToByteArray(Sound[] channels,int sampleSize,boolean bigEndian,boolean pcmSigned){
  int length=channels.length * sampleSize * channels[0].getSamples().length;
  byte[] data=new byte[length];
  double value=0;
  double dividedValue=0;
  byte byteValueSigned=0;
  long neutral=(pcmSigned ? this.getNeutral(sampleSize) : 0);
  for (int i=0; i < data.length; i++) {
    int numByte=i % sampleSize;
    int currentChannel=(i / sampleSize) % channels.length;
    int currentFrame=i / (sampleSize * channels.length);
    if (numByte == 0) {
      value=channels[currentChannel].getSamples()[currentFrame] + neutral;
    }
    dividedValue=value / 256;
    byteValueSigned=(byte)(value + (pcmSigned ? Byte.MIN_VALUE : 0));
    data[i + (!bigEndian ? 0 : (sampleSize - 2 * numByte) - 1)]=byteValueSigned;
    value=dividedValue;
  }
  return data;
}

Fixed version (ground truth):
protected byte[] framesToByteArray(Sound[] channels,int sampleSize,boolean bigEndian,boolean pcmSigned){
  int length=channels.length * sampleSize * channels[0].getSamples().length;
  byte[] data=new byte[length];
  double value=0;
  double dividedValue=0;
  byte byteValueSigned=0;
  long neutral=(pcmSigned ? this.getNeutral(sampleSize) : 0);
  for (int i=0; i < data.length; i++) {
    int numByte=i % sampleSize;
    int currentChannel=(i / sampleSize) % channels.length;
    int currentFrame=i / (sampleSize * channels.length);
    if (numByte == 0 && channels[currentChannel].getSamples().length > currentFrame) {
      value=channels[currentChannel].getSamples()[currentFrame] + neutral;
    }
    dividedValue=value / 256;
    byteValueSigned=(byte)(value + (pcmSigned ? Byte.MIN_VALUE : 0));
    data[i + (!bigEndian ? 0 : (sampleSize - 2 * numByte) - 1)]=byteValueSigned;
    value=dividedValue;
  }
  return data;
}
Program: 81401
Project: 81401
Buggy source:
@Override public void log(LogEvent logEvent){
  for (  TransformObserver transformObserver : this.observers) {
    transformObserver.notify(logEvent);
  }
}

Fixed version (ground truth):
@Override public void log(LogEvent logEvent){
  if (this.observers == null) {
    return;
  }
  for (  TransformObserver transformObserver : this.observers) {
    transformObserver.notify(logEvent);
  }
}
Program: 81402
Project: 81402
Buggy source:
private static int findSustain(Sound channel1,int decay){
  final int threshold=100;
  final double[] magnitude=new double[channel1.getSamples().length / threshold + 1];
  int sustainIndex=decay;
  SoundTransformation magnitudeTransform=new NoOpFrequencySoundTransformation(){
    int arraylength=0;
    @Override public Sound initSound(    Sound input){
      this.arraylength=0;
      return super.initSound(input);
    }
    @Override protected double getLowThreshold(    double defaultValue){
      return threshold;
    }
    @Override public FrequenciesState transformFrequencies(    FrequenciesState fs,    int offset,    int powOf2NearestLength,    int length,    double maxFrequency){
      magnitude[arraylength++]=Sound2Note.computeMagnitude(fs);
      return super.transformFrequencies(fs,offset,powOf2NearestLength,length,maxFrequency);
    }
  }
;
  magnitudeTransform.transform(channel1);
  try {
    MathArrays.checkOrder(Arrays.copyOfRange(magnitude,decay,magnitude.length),MathArrays.OrderDirection.DECREASING,true);
  }
 catch (  NonMonotonicSequenceException nmse) {
    sustainIndex=(nmse.getIndex() - 1) * threshold;
  }
  return sustainIndex;
}

Fixed version (ground truth):
private static int findSustain(Sound channel1,int decay){
  final int threshold=100;
  final double[] magnitude=new double[channel1.getSamples().length / threshold + 1];
  int sustainIndex=decay;
  SoundTransformation magnitudeTransform=new NoOpFrequencySoundTransformation(){
    int arraylength=0;
    @Override public Sound initSound(    Sound input){
      this.arraylength=0;
      return super.initSound(input);
    }
    @Override protected double getLowThreshold(    double defaultValue){
      return threshold;
    }
    @Override public FrequenciesState transformFrequencies(    FrequenciesState fs,    int offset,    int powOf2NearestLength,    int length,    double maxFrequency){
      magnitude[arraylength++]=Sound2Note.computeMagnitude(fs);
      return super.transformFrequencies(fs,offset,powOf2NearestLength,length,maxFrequency);
    }
  }
;
  magnitudeTransform.transform(channel1);
  try {
    MathArrays.checkOrder(Arrays.copyOfRange(magnitude,decay / threshold,magnitude.length),MathArrays.OrderDirection.DECREASING,true);
  }
 catch (  NonMonotonicSequenceException nmse) {
    sustainIndex=(nmse.getIndex() - 1) * threshold;
  }
  return sustainIndex;
}
Program: 81403
Project: 81403
Buggy source:
private static int findRelease(Sound channel1){
  final int threshold=channel1.getFreq() / 10;
  Sound reversed=new ReverseSoundTransformation().transform(channel1);
  final double[] magnitude=new double[channel1.getSamples().length / threshold + 1];
  int releaseIndexFromReversed=0;
  SoundTransformation magnitudeTransform=new NoOpFrequencySoundTransformation(){
    int arraylength=0;
    @Override public Sound initSound(    Sound input){
      this.arraylength=0;
      return super.initSound(input);
    }
    @Override protected double getLowThreshold(    double defaultValue){
      return threshold;
    }
    @Override public FrequenciesState transformFrequencies(    FrequenciesState fs,    int offset,    int powOf2NearestLength,    int length,    double maxFrequency){
      magnitude[arraylength++]=Sound2Note.computeMagnitude(fs);
      return super.transformFrequencies(fs,offset,powOf2NearestLength,length,maxFrequency);
    }
  }
;
  magnitudeTransform.transform(reversed);
  try {
    MathArrays.checkOrder(magnitude,MathArrays.OrderDirection.INCREASING,true);
  }
 catch (  NonMonotonicSequenceException nmse) {
    releaseIndexFromReversed=(nmse.getIndex() - 1) * threshold;
  }
  return channel1.getSamples().length - releaseIndexFromReversed;
}

Fixed version (ground truth):
private static int findRelease(Sound channel1){
  final int threshold=100;
  Sound reversed=new ReverseSoundTransformation().transform(channel1);
  final double[] magnitude=new double[channel1.getSamples().length / threshold + 1];
  int releaseIndexFromReversed=0;
  SoundTransformation magnitudeTransform=new NoOpFrequencySoundTransformation(){
    int arraylength=0;
    @Override public Sound initSound(    Sound input){
      this.arraylength=0;
      return super.initSound(input);
    }
    @Override protected double getLowThreshold(    double defaultValue){
      return threshold;
    }
    @Override public FrequenciesState transformFrequencies(    FrequenciesState fs,    int offset,    int powOf2NearestLength,    int length,    double maxFrequency){
      magnitude[arraylength++]=Sound2Note.computeMagnitude(fs);
      return super.transformFrequencies(fs,offset,powOf2NearestLength,length,maxFrequency);
    }
  }
;
  magnitudeTransform.transform(reversed);
  try {
    MathArrays.checkOrder(magnitude,MathArrays.OrderDirection.INCREASING,true);
  }
 catch (  NonMonotonicSequenceException nmse) {
    releaseIndexFromReversed=(nmse.getIndex() - 1) * threshold;
  }
  return channel1.getSamples().length - releaseIndexFromReversed;
}
Program: 81404
Project: 81404
Buggy source:
public void testShape(){
  try {
    System.out.println("String_Node_Str");
    PacksList packsList=PacksList.getInstance();
    new TransformSound(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");
    PacksList packsList=PacksList.getInstance();
    new TransformSound(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: 81405
Project: 81405
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 / subSound[0].getSamples().length;
  if (factor == 0) {
    return result;
  }
 else   if (factor < 0.98 || factor > 1.02) {
    if (factor < 0.98) {
      SpeedUpSoundTransformation speedup=new SpeedUpSoundTransformation(100,percent);
      result=speedup.transform(result);
    }
 else     if (factor > 1.02) {
      SlowdownSoundTransformation slowdown=new SlowdownSoundTransformation(100,percent);
      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[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 / subSound[0].getSamples().length;
  if (factor == 0) {
    return result;
  }
 else   if (factor < 0.98 || factor > 1.02) {
    if (factor < 0.98) {
      SpeedUpSoundTransformation speedup=new SpeedUpSoundTransformation(100,percent);
      result=speedup.transform(result);
    }
 else     if (factor > 1.02) {
      SlowdownSoundTransformation slowdown=new SlowdownSoundTransformation(100,percent);
      result=slowdown.transform(result);
    }
  }
  return result;
}
Program: 81406
Project: 81406
Buggy source:
@Test public void testShape(){
  try {
    System.out.println("String_Node_Str");
    PacksList packsList=PacksList.getInstance();
    new TransformSound(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[]{1,1,1,1,1,1,1,0.70,0.30,0.10,0.10,0.10,0.10,0.10,0.10}),new PurifySoundTransformation(),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");
    PacksList packsList=PacksList.getInstance();
    new TransformSound(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[]{1,1,1,1,1,1,1,0.70,0.30,0.10,0.10,0.10,0.10,0.10,0.10}),new ShapeSoundTransformation(packsList.defaultPack,"String_Node_Str"));
  }
 catch (  UnsupportedAudioFileException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}
Program: 81407
Project: 81407
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=length / subSound.length;
  if (factor < 0.98 || factor > 1.02) {
    if (factor < 0.98) {
      SpeedUpSoundTransformation speedup=new SpeedUpSoundTransformation(100,percent);
      result=speedup.transform(result);
    }
 else     if (factor > 1.02) {
      SlowdownSoundTransformation slowdown=new SlowdownSoundTransformation(100,percent);
      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[channelNum];
  PitchSoundTransformation pitcher=new PitchSoundTransformation(percent);
  if (percent < 98 || percent > 102) {
    result=pitcher.transform(result);
  }
  double factor=length / subSound[0].getSamples().length;
  if (factor < 0.98 || factor > 1.02) {
    if (factor < 0.98) {
      SpeedUpSoundTransformation speedup=new SpeedUpSoundTransformation(100,percent);
      result=speedup.transform(result);
    }
 else     if (factor > 1.02) {
      SlowdownSoundTransformation slowdown=new SlowdownSoundTransformation(100,percent);
      result=slowdown.transform(result);
    }
  }
  return result;
}
Program: 81408
Project: 81408
Buggy source:
@Override public Sound transform(Sound sound){
  int threshold=2000;
  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;
  int usedarraylength=0;
  for (int i=0; i < freqs.length; i++) {
    this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str" + i + "String_Node_Str"+ freqs.length));
    if (Math.abs(freqs[i] - lastFreq) > freqs[i] / 100) {
      int length=(i - 1 - lastBegining) * threshold;
      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=builtSound.concat(true,usedarraylength,attack,decay,sustain,release);
      usedarraylength+=attack.getSamples().length + decay.getSamples().length + sustain.getSamples().length+ release.getSamples().length;
      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;
  int usedarraylength=0;
  for (int i=0; i < freqs.length; i++) {
    this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str" + i + "String_Node_Str"+ freqs.length));
    if (Math.abs(freqs[i] - lastFreq) > freqs[i] / 100) {
      int length=(i - 1 - lastBegining) * threshold;
      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=builtSound.concat(true,usedarraylength,attack,decay,sustain,release);
      usedarraylength+=attack.getSamples().length + decay.getSamples().length + sustain.getSamples().length+ release.getSamples().length;
      lastBegining=i;
      lastFreq=freqs[i];
    }
  }
  return builtSound;
}
Program: 81409
Project: 81409
Buggy source:
public String toString(){
  float lastFrequency=maxfrequency / 2.0f;
  int length=(int)lastFrequency / 20;
  int height=15;
  int maxMagn=this.getMaxValue();
  StringBuffer sb=new StringBuffer();
  int step=(int)lastFrequency / length;
  int[] valuesOnPlot=new int[length];
  int max=0;
  int maxValue=0;
  for (int i=0; i < valuesOnPlot.length; i++) {
    double sum=0;
    for (int j=0; j < step; j++) {
      sum+=state[i * step + j].abs();
    }
    valuesOnPlot[i]=(int)(sum * 1.0 / step * height / (maxMagn));
    if (maxValue < valuesOnPlot[i]) {
      maxValue=valuesOnPlot[i];
      max=i;
    }
  }
  for (int j=height; j >= 0; j--) {
    if (j == height) {
      sb.append("String_Node_Str" + maxMagn + "String_Node_Str");
      continue;
    }
 else {
      sb.append("String_Node_Str");
    }
    for (int i=0; i < length; i++) {
      if (valuesOnPlot[i] == j) {
        sb.append("String_Node_Str");
      }
 else       if (valuesOnPlot[i] > j) {
        sb.append("String_Node_Str");
      }
 else {
        sb.append("String_Node_Str");
      }
    }
    sb.append("String_Node_Str");
  }
  sb.append("String_Node_Str");
  for (int i=0; i < length; i++) {
    sb.append("String_Node_Str");
  }
  sb.append("String_Node_Str" + lastFrequency + "String_Node_Str");
  sb.append("String_Node_Str" + (int)(max * 1.0 / length * lastFrequency) + "String_Node_Str"+ (int)((max + 1.0) / length * lastFrequency)+ "String_Node_Str");
  return sb.toString();
}

Fixed version (ground truth):
public String toString(){
  float lastFrequency=maxfrequency / 2.0f;
  int length=(int)lastFrequency / 20;
  int height=15;
  int maxMagn=this.getMaxValue();
  StringBuffer sb=new StringBuffer();
  int step=(int)lastFrequency / length;
  int[] valuesOnPlot=new int[length];
  int max=0;
  int maxValue=0;
  for (int i=0; i < valuesOnPlot.length; i++) {
    double peak=0;
    for (int j=0; j < step; j++) {
      if (peak < state[i * step + j].abs()) {
        peak=state[i * step + j].abs();
      }
    }
    valuesOnPlot[i]=(int)(peak * height / (maxMagn));
    if (maxValue < valuesOnPlot[i]) {
      maxValue=valuesOnPlot[i];
      max=i;
    }
  }
  for (int j=height; j >= 0; j--) {
    if (j == height) {
      sb.append("String_Node_Str" + maxMagn + "String_Node_Str");
      continue;
    }
 else {
      sb.append("String_Node_Str");
    }
    for (int i=0; i < length; i++) {
      if (valuesOnPlot[i] == j) {
        sb.append("String_Node_Str");
      }
 else       if (valuesOnPlot[i] > j) {
        sb.append("String_Node_Str");
      }
 else {
        sb.append("String_Node_Str");
      }
    }
    sb.append("String_Node_Str");
  }
  sb.append("String_Node_Str");
  for (int i=0; i < length; i++) {
    sb.append("String_Node_Str");
  }
  sb.append("String_Node_Str" + lastFrequency + "String_Node_Str");
  sb.append("String_Node_Str" + (int)(max * 1.0 / length * lastFrequency) + "String_Node_Str"+ (int)((max + 1.0) / length * lastFrequency)+ "String_Node_Str");
  return sb.toString();
}
Program: 81410
Project: 81410
Buggy source:
public Sound concat(boolean inPlace,Sound... otherSounds){
  int newlength=this.samples.length;
  for (int i=0; i < otherSounds.length; i++) {
    newlength+=otherSounds[i].getSamples().length;
  }
  long[] newsamples;
  if (newlength <= this.getSamples().length && inPlace) {
    newsamples=this.samples;
  }
 else {
    newsamples=new long[newlength];
    System.arraycopy(this.samples,0,newsamples,0,this.samples.length);
  }
  int newindex=this.samples.length;
  for (int i=0; i < otherSounds.length; i++) {
    System.arraycopy(otherSounds[i].samples,0,newsamples,newindex,otherSounds[i].samples.length);
    newindex+=otherSounds[i].samples.length;
  }
  return new Sound(newsamples,nbBytesPerSample,freq,channelNum);
}

Fixed version (ground truth):
public Sound concat(boolean inPlace,int offset,Sound... otherSounds){
  int newlength=offset;
  for (int i=0; i < otherSounds.length; i++) {
    newlength+=otherSounds[i].getSamples().length;
  }
  long[] newsamples;
  if (newlength <= this.getSamples().length && inPlace) {
    newsamples=this.samples;
  }
 else {
    newsamples=new long[newlength];
    System.arraycopy(this.samples,0,newsamples,0,this.samples.length);
  }
  int newindex=offset;
  for (int i=0; i < otherSounds.length; i++) {
    System.arraycopy(otherSounds[i].samples,0,newsamples,newindex,otherSounds[i].samples.length);
    newindex+=otherSounds[i].samples.length;
  }
  return new Sound(newsamples,nbBytesPerSample,freq,channelNum);
}
Program: 81411
Project: 81411
Buggy source:
@Override public Sound transform(Sound sound){
  this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str"));
  PacksList packsList=PacksList.getInstance();
  int threshold=20000;
  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));
    if (Math.abs(freqs[i] - lastFreq) > freqs[i] / 100) {
      int length=(i - 1 - lastBegining) * threshold;
      Note n=packsList.defaultPack.get("String_Node_Str").getNearestNote((int)lastFreq);
      builtSound=builtSound.concat(true,n.getAttack((int)lastFreq,channelNum,length),n.getDecay((int)lastFreq,channelNum,length),n.getSustain((int)lastFreq,channelNum,length),n.getRelease((int)lastFreq,channelNum,length));
      lastBegining=i;
      lastFreq=freqs[i];
    }
  }
  return builtSound;
}

Fixed version (ground truth):
@Override public Sound transform(Sound sound){
  int threshold=20000;
  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;
  int usedarraylength=0;
  for (int i=0; i < freqs.length; i++) {
    this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str" + i + "String_Node_Str"+ freqs.length));
    if (Math.abs(freqs[i] - lastFreq) > freqs[i] / 100) {
      int length=(i - 1 - lastBegining) * threshold;
      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=builtSound.concat(true,usedarraylength,attack,decay,sustain,release);
      usedarraylength+=attack.getSamples().length + decay.getSamples().length + sustain.getSamples().length+ release.getSamples().length;
      lastBegining=i;
      lastFreq=freqs[i];
    }
  }
  return builtSound;
}
Program: 81412
Project: 81412
Buggy source:
public ShapeSoundTransformation(){
}

Fixed version (ground truth):
public ShapeSoundTransformation(Pack pack,String instrument){
  this.pack=pack;
  this.instrument=instrument;
}
Program: 81413
Project: 81413
Buggy source:
@Test public void testShape(){
  try {
    new TransformSound(new PrintlnTransformObserver()).transformFile(input,output,new PurifySoundTransformation(),new ShapeSoundTransformation());
  }
 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");
    PacksList packsList=PacksList.getInstance();
    new TransformSound(new PrintlnTransformObserver()).transformFile(input,output,new PurifySoundTransformation(),new ShapeSoundTransformation(packsList.defaultPack,"String_Node_Str"));
  }
 catch (  UnsupportedAudioFileException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}
Program: 81414
Project: 81414
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,percent);
      result=speedup.transform(result);
    }
 else     if (factor > 1.02) {
      SlowdownSoundTransformation slowdown=new SlowdownSoundTransformation(100,percent);
      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[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;
}
Program: 81415
Project: 81415
Buggy source:
@Override public Sound transform(Sound sound){
  this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str"));
  PacksList packsList=PacksList.getInstance();
  int threshold=100;
  int channelNum=sound.getChannelNum();
  Sound builtSound=new Sound(new long[0],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));
    if (Math.abs(freqs[i] - lastFreq) > freqs[i] / 100) {
      int length=(i - 1 - lastBegining) * threshold;
      Note n=packsList.defaultPack.get("String_Node_Str").getNearestNote((int)lastFreq);
      builtSound.concat(n.getAttack((int)lastFreq,channelNum,length),n.getDecay((int)lastFreq,channelNum,length),n.getSustain((int)lastFreq,channelNum,length),n.getRelease((int)lastFreq,channelNum,length));
      lastBegining=i;
      lastFreq=freqs[i];
    }
  }
  return builtSound;
}

Fixed version (ground truth):
@Override public Sound transform(Sound sound){
  this.log(new LogEvent(LogLevel.VERBOSE,"String_Node_Str"));
  PacksList packsList=PacksList.getInstance();
  int threshold=2000;
  int channelNum=sound.getChannelNum();
  Sound builtSound=new Sound(new long[0],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));
    if (Math.abs(freqs[i] - lastFreq) > freqs[i] / 100) {
      int length=(i - 1 - lastBegining) * threshold;
      Note n=packsList.defaultPack.get("String_Node_Str").getNearestNote((int)lastFreq);
      builtSound=builtSound.concat(n.getAttack((int)lastFreq,channelNum,length),n.getDecay((int)lastFreq,channelNum,length),n.getSustain((int)lastFreq,channelNum,length),n.getRelease((int)lastFreq,channelNum,length));
      lastBegining=i;
      lastFreq=freqs[i];
    }
  }
  return builtSound;
}
Program: 81416
Project: 81416
Buggy source:
@Test public void testShape(){
  try {
    new TransformSound(new PrintlnTransformObserver()).transformFile(input,output,new ShapeSoundTransformation());
  }
 catch (  UnsupportedAudioFileException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
@Test public void testShape(){
  try {
    new TransformSound(new PrintlnTransformObserver()).transformFile(input,output,new PurifySoundTransformation(),new ShapeSoundTransformation());
  }
 catch (  UnsupportedAudioFileException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}
Program: 81417
Project: 81417
Buggy source:
private float getRatio(Sound[] subsound){
  return subsound[0].getSamples().length * 1.0f / (this.attack[0].getSamples().length + this.decay[0].getSamples().length + this.sustain[0].getSamples().length+ this.release[0].getSamples().length);
}

Fixed version (ground truth):
private float getRatio(Sound[] subsound){
  int lengthOfSubsound=subsound[0].getSamples().length;
  int lengthOfSound=(this.attack[0].getSamples().length + this.decay[0].getSamples().length + this.sustain[0].getSamples().length+ this.release[0].getSamples().length);
  return lengthOfSubsound * 1.0f / lengthOfSound;
}
Program: 81418
Project: 81418
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 / subSound[0].getSamples().length;
  if (factor == 0) {
    return result;
  }
 else   if (factor < 0.98 || factor > 1.02) {
    if (factor < 0.98) {
      SpeedUpSoundTransformation speedup=new SpeedUpSoundTransformation(100,percent);
      result=speedup.transform(result);
    }
 else     if (factor > 1.02) {
      SlowdownSoundTransformation slowdown=new SlowdownSoundTransformation(100,percent);
      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[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,percent);
      result=speedup.transform(result);
    }
 else     if (factor > 1.02) {
      SlowdownSoundTransformation slowdown=new SlowdownSoundTransformation(100,percent);
      result=slowdown.transform(result);
    }
  }
  return result;
}
Program: 81419
Project: 81419
Buggy source:
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;
}

Fixed version (ground truth):
private int 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);
  }
  return (int)freq;
}
Program: 81420
Project: 81420
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.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: 81421
Project: 81421
Buggy source:
private void byteArrayToFrame(byte[] frame,Sound sound,int position,boolean bigEndian){
  double value=0;
  int destination=(!bigEndian ? 0 : frame.length - 1);
  for (int j=0; j <= frame.length; j++) {
    int i=(bigEndian ? frame.length - j - 1 : j);
    int fromIndex=(i < destination ? i : destination);
    int toIndex=(i < destination ? destination : i);
    if (fromIndex < toIndex && !new HashSet<Object>(Arrays.asList(this.toObject(frame)).subList(fromIndex,toIndex)).equals(new HashSet<Object>(Arrays.asList(new byte[]{0})))) {
      value+=frame[i - 1] * Math.pow(256,i - 1);
    }
  }
  sound.getSamples()[position]=value;
}

Fixed version (ground truth):
private void byteArrayToFrame(byte[] frame,Sound sound,int position,boolean bigEndian){
  double value=0;
  int destination=(!bigEndian ? 0 : frame.length - 1);
  for (int j=0; j < frame.length; j++) {
    int cursor=(!bigEndian ? frame.length - j - 1 : j);
    int fromIndex=(cursor < destination ? cursor : destination);
    int toIndex=(cursor < destination ? destination : cursor);
    if (fromIndex <= toIndex) {
      value+=frame[cursor] * Math.pow(256,cursor);
    }
  }
  sound.getSamples()[position]=value;
}
Program: 81422
Project: 81422
Buggy source:
private static Sound normalize(Sound sound){
  double[] data=sound.getSamples();
  double[] newdata=new double[sound.getSamples().length];
  double max=0;
  for (int i=0; i < data.length; i++) {
    if (Math.abs(data[i]) > max)     max=Math.abs(data[i]);
  }
  double maxValue=Math.pow(256,sound.getNbBytesPerFrame() - 1) / 2;
  double ratio=maxValue / max;
  for (int i=0; i < data.length; i++) {
    double rescaled=data[i] * ratio;
    newdata[i]=Math.floor(rescaled);
  }
  return new Sound(newdata,sound.getNbBytesPerFrame(),sound.getFreq());
}

Fixed version (ground truth):
private static Sound normalize(Sound sound){
  double[] data=sound.getSamples();
  double[] newdata=new double[sound.getSamples().length];
  double max=0;
  for (int i=0; i < data.length; i++) {
    if (Math.abs(data[i]) > max)     max=Math.abs(data[i]);
  }
  double maxValue=Math.pow(256,sound.getNbBytesPerFrame()) / 2;
  double ratio=maxValue / max;
  for (int i=0; i < data.length; i++) {
    double rescaled=data[i] * ratio;
    newdata[i]=Math.floor(rescaled);
  }
  return new Sound(newdata,sound.getNbBytesPerFrame(),sound.getFreq());
}
Program: 81423
Project: 81423
Buggy source:
private float getRatio(Sound[] subsound){
  return subsound[0].getSamples().length / (this.attack[0].getSamples().length + this.decay[0].getSamples().length + this.sustain[0].getSamples().length+ this.release[0].getSamples().length);
}

Fixed version (ground truth):
private float getRatio(Sound[] subsound){
  return subsound[0].getSamples().length * 1.0f / (this.attack[0].getSamples().length + this.decay[0].getSamples().length + this.sustain[0].getSamples().length+ this.release[0].getSamples().length);
}
Program: 81424
Project: 81424
Buggy source:
private static int findRelease(Sound channel1){
  final int threshold=channel1.getFreq() / 10;
  Sound reversed=new ReverseSoundTransformation().transform(channel1);
  final double[] magnitude=new double[channel1.getSamples().length / threshold + 1];
  int releaseIndexFromReversed=0;
  SoundTransformation magnitudeTransform=new NoOpFrequencySoundTransformation(){
    int arraylength=0;
    @Override public Sound initSound(    Sound input){
      this.arraylength=0;
      return super.initSound(input);
    }
    @Override protected double getLowThreshold(    double defaultValue){
      return threshold;
    }
    @Override public FrequenciesState transformFrequencies(    FrequenciesState fs,    int offset,    int powOf2NearestLength,    int length,    double maxFrequency){
      magnitude[arraylength++]=Sound2Note.computeMagnitude(fs);
      return super.transformFrequencies(fs,offset,powOf2NearestLength,length,maxFrequency);
    }
  }
;
  magnitudeTransform.transform(reversed);
  try {
    MathArrays.checkOrder(magnitude,MathArrays.OrderDirection.INCREASING,true);
  }
 catch (  NonMonotonicSequenceException nmse) {
    releaseIndexFromReversed=(nmse.getIndex() - 1) * threshold;
  }
  return magnitude.length - releaseIndexFromReversed;
}

Fixed version (ground truth):
private static int findRelease(Sound channel1){
  final int threshold=channel1.getFreq() / 10;
  Sound reversed=new ReverseSoundTransformation().transform(channel1);
  final double[] magnitude=new double[channel1.getSamples().length / threshold + 1];
  int releaseIndexFromReversed=0;
  SoundTransformation magnitudeTransform=new NoOpFrequencySoundTransformation(){
    int arraylength=0;
    @Override public Sound initSound(    Sound input){
      this.arraylength=0;
      return super.initSound(input);
    }
    @Override protected double getLowThreshold(    double defaultValue){
      return threshold;
    }
    @Override public FrequenciesState transformFrequencies(    FrequenciesState fs,    int offset,    int powOf2NearestLength,    int length,    double maxFrequency){
      magnitude[arraylength++]=Sound2Note.computeMagnitude(fs);
      return super.transformFrequencies(fs,offset,powOf2NearestLength,length,maxFrequency);
    }
  }
;
  magnitudeTransform.transform(reversed);
  try {
    MathArrays.checkOrder(magnitude,MathArrays.OrderDirection.INCREASING,true);
  }
 catch (  NonMonotonicSequenceException nmse) {
    releaseIndexFromReversed=(nmse.getIndex() - 1) * threshold;
  }
  return channel1.getSamples().length - releaseIndexFromReversed;
}
Program: 81425
Project: 81425
Buggy source:
private static int findFrequency(Sound channel1){
  final int threshold=channel1.getFreq() / 10;
  double sum=0;
  final double[] magnitude=new double[channel1.getSamples().length / threshold + 1];
  SoundTransformation magnFreqTransform=new NoOpFrequencySoundTransformation(){
    int index=0;
    @Override public Sound initSound(    Sound input){
      return super.initSound(input);
    }
    @Override protected double getLowThreshold(    double defaultValue){
      return threshold;
    }
    @Override public FrequenciesState transformFrequencies(    FrequenciesState fs,    int offset,    int powOf2NearestLength,    int length,    double maxFrequency){
      index++;
      magnitude[index]+=Sound2Note.computeLoudestFreq(fs);
      return super.transformFrequencies(fs,offset,powOf2NearestLength,length,maxFrequency);
    }
  }
;
  magnFreqTransform.transform(channel1);
  for (int i=0; i < magnitude.length; i++) {
    sum+=magnitude[i];
  }
  return (int)(sum / magnitude.length);
}

Fixed version (ground truth):
private static int findFrequency(Sound channel1){
  final int threshold=100;
  double sum=0;
  final double[] magnitude=new double[channel1.getSamples().length / threshold + threshold];
  SoundTransformation magnFreqTransform=new NoOpFrequencySoundTransformation(){
    int index=0;
    @Override public Sound initSound(    Sound input){
      return super.initSound(input);
    }
    @Override protected double getLowThreshold(    double defaultValue){
      return threshold;
    }
    @Override public FrequenciesState transformFrequencies(    FrequenciesState fs,    int offset,    int powOf2NearestLength,    int length,    double maxFrequency){
      index++;
      magnitude[index]+=Sound2Note.computeLoudestFreq(fs);
      return super.transformFrequencies(fs,offset,powOf2NearestLength,length,maxFrequency);
    }
  }
;
  magnFreqTransform.transform(channel1);
  for (int i=0; i < magnitude.length; i++) {
    sum+=magnitude[i];
  }
  return (int)(sum / magnitude.length);
}
Program: 81426
Project: 81426
Buggy source:
@Test public void run() throws UnsupportedAudioFileException, IOException {
  AudioInputStream ais=AudioFileHelper.getAudioInputStream(input);
  TransformSound ts=new TransformSound();
  Note n=Sound2Note.convert(ts.fromInputStream(ais));
}

Fixed version (ground truth):
@Test public void run() throws UnsupportedAudioFileException, IOException {
  AudioInputStream ais=AudioFileHelper.getAudioInputStream(input);
  TransformSound ts=new TransformSound();
  Note n=Sound2Note.convert(ts.fromInputStream(ais));
  n.hashCode();
}
Program: 81427
Project: 81427
Buggy source:
Sound[] getSustain(int frequency,int length);

Fixed version (ground truth):
Sound getSustain(int frequency,int channelnum,int length);
Program: 81428
Project: 81428
Buggy source:
Sound[] getAttack(int frequency,int length);

Fixed version (ground truth):
Sound getAttack(int frequency,int channelnum,int length);
Program: 81429
Project: 81429
Buggy source:
Sound[] getDecay(int frequency,int length);

Fixed version (ground truth):
Sound getDecay(int frequency,int channelnum,int length);
Program: 81430
Project: 81430
Buggy source:
Sound[] getRelease(int frequency,int length);

Fixed version (ground truth):
Sound getRelease(int frequency,int channelnum,int length);
Program: 81431
Project: 81431
Buggy source:
@Override public Sound[] getSustain(int frequency,int length){
  return this.transformSubsound(this.sustain,frequency,(int)(this.getRatio(this.sustain) * length));
}

Fixed version (ground truth):
@Override public Sound getSustain(int frequency,int channelnum,int length){
  return this.transformSubsound(this.sustain,channelnum,frequency,(int)(this.getRatio(this.sustain) * length));
}
Program: 81432
Project: 81432
Buggy source:
@Override public Sound[] getAttack(int frequency,int length){
  return this.transformSubsound(this.attack,frequency,(int)(this.getRatio(this.attack) * length));
}

Fixed version (ground truth):
@Override public Sound getAttack(int frequency,int channelnum,int length){
  return this.transformSubsound(this.attack,channelnum,frequency,(int)(this.getRatio(this.attack) * length));
}
Program: 81433
Project: 81433
Buggy source:
@Override public Sound[] getDecay(int frequency,int length){
  return this.transformSubsound(this.decay,frequency,(int)(this.getRatio(this.decay) * length));
}

Fixed version (ground truth):
@Override public Sound getDecay(int frequency,int channelnum,int length){
  return this.transformSubsound(this.decay,channelnum,frequency,(int)(this.getRatio(this.decay) * length));
}