nus-yam/ex-repair huggingface dataset:
Program: 81269
Project: 81269
Buggy source:
private JsonElement toJsonElement(final Range range){
  if (range.size() == 1 && !(range.get(0) instanceof SimpleNote)) {
    return new JsonArray();
  }
  final JsonElement[] noteJsons=new JsonElement[range.size()];
  int i=0;
  for (  final Note note : range.values()) {
    noteJsons[i++]=new Gson().toJsonTree(this.toJsonElement(note));
  }
  return new Gson().toJsonTree(noteJsons);
}

Fixed version (ground truth):
private JsonElement toJsonElement(final Range range){
  if (range.size() == 1 && !(range.values().iterator().next() instanceof SimpleNote)) {
    return new JsonArray();
  }
  final JsonElement[] noteJsons=new JsonElement[range.size()];
  int i=0;
  for (  final Note note : range.values()) {
    noteJsons[i++]=SMALL_GSON_OBJECT.toJsonTree(this.toJsonElement(note));
  }
  return SMALL_GSON_OBJECT.toJsonTree(noteJsons);
}
Program: 81270
Project: 81270
Buggy source:
@Override public String toString(final Range range){
  return new GsonBuilder().setPrettyPrinting().create().toJson(this.toJsonElement(range));
}

Fixed version (ground truth):
@Override public String toString(final Range range){
  return GSON_OBJECT.toJson(this.toJsonElement(range));
}
Program: 81271
Project: 81271
Buggy source:
public StreamInfo getStreamInfo(ConverterData converterData){
  return new StreamInfo(converterData.jorbisData.info.channels,converterData.pcmData.baos == null ? 0 : (int)(converterData.pcmData.baos.size() * 1.0 / converterData.jorbisData.info.channels),2,converterData.jorbisData.info.rate,false,true,"String_Node_Str");
}

Fixed version (ground truth):
public StreamInfo getStreamInfo(ConverterData converterData){
  return new StreamInfo(converterData.jorbisData.info.channels,converterData.pcmData.baos == null ? 0 : (int)(converterData.pcmData.baos.size() * 1.0 / Byte.SIZE),2,converterData.jorbisData.info.rate,false,true,"String_Node_Str");
}
Program: 81272
Project: 81272
Buggy source:
public StreamInfo getStreamInfo(final ConverterData converterData){
  return new StreamInfo(converterData.jorbisData.info.channels,converterData.pcmData.baos == null ? 0 : (int)(converterData.pcmData.baos.size() * 1.0 * converterData.jorbisData.info.channels* 2 / Byte.SIZE),2,converterData.jorbisData.info.rate,false,true,"String_Node_Str");
}

Fixed version (ground truth):
public StreamInfo getStreamInfo(final ConverterData converterData){
  return new StreamInfo(converterData.jorbisData.info.channels,converterData.pcmData.baos == null ? 0 : (int)(converterData.pcmData.baos.size() * 1.0 * converterData.jorbisData.info.channels / Byte.SIZE),2,converterData.jorbisData.info.rate,false,true,"String_Node_Str");
}
Program: 81273
Project: 81273
Buggy source:
@Override public int findSustain(final double[] magnitudeArray,final int decay) throws SoundTransformException {
  int sustainIndex=decay;
  final int start=decay;
  final double[] sustainArray=new double[magnitudeArray.length - start];
  System.arraycopy(magnitudeArray,start,sustainArray,0,magnitudeArray.length - start);
  try {
    MathArrays.checkOrder(sustainArray,MathArrays.OrderDirection.DECREASING,true);
  }
 catch (  final NonMonotonicSequenceException nmse) {
    this.log(new LogEvent(MagnitudeADSRHelperEventCode.FOUND_EDGE,nmse));
    sustainIndex=nmse.getIndex() - 1;
  }
  return sustainIndex;
}

Fixed version (ground truth):
@Override public int findSustain(final double[] magnitudeArray,final int decay) throws SoundTransformException {
  int sustainIndex=decay;
  final int start=decay;
  final double[] sustainArray=new double[magnitudeArray.length - start];
  System.arraycopy(magnitudeArray,start,sustainArray,0,magnitudeArray.length - start);
  try {
    MathArrays.checkOrder(sustainArray,MathArrays.OrderDirection.DECREASING,true);
  }
 catch (  final NonMonotonicSequenceException nmse) {
    this.log(new LogEvent(MagnitudeADSRHelperEventCode.FOUND_EDGE,nmse));
    sustainIndex=nmse.getIndex() - 1;
  }
  return Math.max(decay,sustainIndex);
}
Program: 81274
Project: 81274
Buggy source:
/** 
 * @param noteInfo
 * @param sound
 * @param channel1
 * @param noteInfoValues
 * @return
 * @throws SoundTransformException
 */
private Note newNote(final SimpleNoteInfo noteInfo,final Sound sound,final Channel channel1,final Map<String,Object> noteInfoValues) throws SoundTransformException {
  final ComputeMagnitudeSoundTransform soundTransform=new ComputeMagnitudeSoundTransform(DefaultSoundToNoteService.ACCURATE_STEP);
  final double[] magnitudeArray=soundTransform.transform(channel1);
  noteInfoValues.put(SimpleNoteInfo.ATTACK_KEY,0);
  noteInfoValues.put(SimpleNoteInfo.DECAY_KEY,this.adsrHelper.findDecay(magnitudeArray,((Integer)noteInfoValues.get(SimpleNoteInfo.ATTACK_KEY)).intValue()) * DefaultSoundToNoteService.ACCURATE_STEP);
  noteInfoValues.put(SimpleNoteInfo.SUSTAIN_KEY,this.adsrHelper.findSustain(magnitudeArray,((Integer)noteInfoValues.get(SimpleNoteInfo.DECAY_KEY)).intValue()) * DefaultSoundToNoteService.ACCURATE_STEP);
  noteInfoValues.put(SimpleNoteInfo.RELEASE_KEY,this.adsrHelper.findRelease(magnitudeArray) * DefaultSoundToNoteService.ACCURATE_STEP);
  noteInfoValues.put(SimpleNoteInfo.FREQUENCY_KEY,noteInfo.hasFrequency() ? noteInfo.getFrequency() : this.frequencyHelper.findFrequency(sound));
  noteInfoValues.put(SimpleNoteInfo.NAME_KEY,noteInfo.getName());
  return new SimpleNote(new SimpleNoteInfo(noteInfoValues),sound.getChannels());
}

Fixed version (ground truth):
/** 
 * @param noteInfo
 * @param sound
 * @param channel1
 * @param noteInfoValues
 * @return
 * @throws SoundTransformException
 */
private Note newNote(final SimpleNoteInfo noteInfo,final Sound sound,final Channel channel1,final Map<String,Object> noteInfoValues) throws SoundTransformException {
  final ComputeMagnitudeSoundTransform soundTransform=new ComputeMagnitudeSoundTransform(DefaultSoundToNoteService.ACCURATE_STEP);
  final double[] magnitudeArray=soundTransform.transform(channel1);
  noteInfoValues.put(SimpleNoteInfo.ATTACK_KEY,0);
  noteInfoValues.put(SimpleNoteInfo.DECAY_KEY,this.adsrHelper.findDecay(magnitudeArray,(int)((Integer)noteInfoValues.get(SimpleNoteInfo.ATTACK_KEY)).intValue() / DefaultSoundToNoteService.ACCURATE_STEP) * DefaultSoundToNoteService.ACCURATE_STEP);
  noteInfoValues.put(SimpleNoteInfo.SUSTAIN_KEY,this.adsrHelper.findSustain(magnitudeArray,(int)((Integer)noteInfoValues.get(SimpleNoteInfo.DECAY_KEY)).intValue() / DefaultSoundToNoteService.ACCURATE_STEP) * DefaultSoundToNoteService.ACCURATE_STEP);
  noteInfoValues.put(SimpleNoteInfo.RELEASE_KEY,this.adsrHelper.findRelease(magnitudeArray) * DefaultSoundToNoteService.ACCURATE_STEP);
  noteInfoValues.put(SimpleNoteInfo.FREQUENCY_KEY,noteInfo.hasFrequency() ? noteInfo.getFrequency() : this.frequencyHelper.findFrequency(sound));
  noteInfoValues.put(SimpleNoteInfo.NAME_KEY,noteInfo.getName());
  return new SimpleNote(new SimpleNoteInfo(noteInfoValues),sound.getChannels());
}
Program: 81275
Project: 81275
Buggy source:
@Override public int findSustain(final Channel channel1,final int decay) throws SoundTransformException {
  int sustainIndex=decay;
  this.ensureComputedMagnitudeArray(channel1,MagnitudeADSRHelper.ACCURATE_STEP_FOR_ADSR_HELPER);
  final int start=decay / MagnitudeADSRHelper.ACCURATE_STEP_FOR_ADSR_HELPER;
  final double[] sustainArray=new double[this.magnitude.length - start];
  System.arraycopy(this.magnitude,start,sustainArray,0,this.magnitude.length - start);
  try {
    MathArrays.checkOrder(sustainArray,MathArrays.OrderDirection.DECREASING,true);
  }
 catch (  final NonMonotonicSequenceException nmse) {
    this.log(new LogEvent(MagnitudeADSRHelperEventCode.FOUND_EDGE,nmse));
    sustainIndex=(nmse.getIndex() - 1) * MagnitudeADSRHelper.ACCURATE_STEP_FOR_ADSR_HELPER;
  }
  return sustainIndex;
}

Fixed version (ground truth):
@Override public int findSustain(final double[] magnitudeArray,final int decay) throws SoundTransformException {
  int sustainIndex=decay;
  final int start=decay / MagnitudeADSRHelper.ACCURATE_STEP_FOR_ADSR_HELPER;
  final double[] sustainArray=new double[magnitudeArray.length - start];
  System.arraycopy(magnitudeArray,start,sustainArray,0,magnitudeArray.length - start);
  try {
    MathArrays.checkOrder(sustainArray,MathArrays.OrderDirection.DECREASING,true);
  }
 catch (  final NonMonotonicSequenceException nmse) {
    this.log(new LogEvent(MagnitudeADSRHelperEventCode.FOUND_EDGE,nmse));
    sustainIndex=(nmse.getIndex() - 1) * MagnitudeADSRHelper.ACCURATE_STEP_FOR_ADSR_HELPER;
  }
  return sustainIndex;
}
Program: 81276
Project: 81276
Buggy source:
@Override public int findRelease(final Channel channel1) throws SoundTransformException {
  int releaseIndexFromReversed=0;
  this.ensureComputedMagnitudeArray(channel1,MagnitudeADSRHelper.ACCURATE_STEP_FOR_ADSR_HELPER);
  final double[] reversed=new double[this.magnitude.length];
  System.arraycopy(this.magnitude,0,reversed,0,reversed.length);
  Collections.reverse(Arrays.asList(reversed));
  try {
    MathArrays.checkOrder(this.magnitude,MathArrays.OrderDirection.INCREASING,true);
  }
 catch (  final NonMonotonicSequenceException nmse) {
    this.log(new LogEvent(MagnitudeADSRHelperEventCode.FOUND_EDGE,nmse));
    releaseIndexFromReversed=(nmse.getIndex() - 1) * MagnitudeADSRHelper.ACCURATE_STEP_FOR_ADSR_HELPER;
  }
  return channel1.getSamplesLength() - releaseIndexFromReversed;
}

Fixed version (ground truth):
@Override public int findRelease(final double[] magnitudeArray,final int samplesLength) throws SoundTransformException {
  int releaseIndexFromReversed=0;
  final double[] reversed=new double[magnitudeArray.length];
  System.arraycopy(magnitudeArray,0,reversed,0,reversed.length);
  Collections.reverse(Arrays.asList(reversed));
  try {
    MathArrays.checkOrder(magnitudeArray,MathArrays.OrderDirection.INCREASING,true);
  }
 catch (  final NonMonotonicSequenceException nmse) {
    this.log(new LogEvent(MagnitudeADSRHelperEventCode.FOUND_EDGE,nmse));
    releaseIndexFromReversed=(nmse.getIndex() - 1) * MagnitudeADSRHelper.ACCURATE_STEP_FOR_ADSR_HELPER;
  }
  return samplesLength - releaseIndexFromReversed;
}
Program: 81277
Project: 81277
Buggy source:
@Override public int findDecay(final Channel channel1,final int attack) throws SoundTransformException {
  int decayIndex=attack;
  this.ensureComputedMagnitudeArray(channel1,MagnitudeADSRHelper.ACCURATE_STEP_FOR_ADSR_HELPER);
  final double[] decayArray=new double[this.magnitude.length - attack];
  System.arraycopy(this.magnitude,attack,decayArray,0,this.magnitude.length - attack);
  try {
    MathArrays.checkOrder(decayArray,MathArrays.OrderDirection.INCREASING,true);
  }
 catch (  final NonMonotonicSequenceException nmse) {
    this.log(new LogEvent(MagnitudeADSRHelperEventCode.FOUND_EDGE,nmse));
    decayIndex=(nmse.getIndex() - 1) * MagnitudeADSRHelper.ACCURATE_STEP_FOR_ADSR_HELPER;
  }
  return decayIndex;
}

Fixed version (ground truth):
@Override public int findDecay(final double[] magnitudeArray,final int attack) throws SoundTransformException {
  int decayIndex=attack;
  final double[] decayArray=new double[magnitudeArray.length - attack];
  System.arraycopy(magnitudeArray,attack,decayArray,0,magnitudeArray.length - attack);
  try {
    MathArrays.checkOrder(decayArray,MathArrays.OrderDirection.INCREASING,true);
  }
 catch (  final NonMonotonicSequenceException nmse) {
    this.log(new LogEvent(MagnitudeADSRHelperEventCode.FOUND_EDGE,nmse));
    decayIndex=(nmse.getIndex() - 1) * MagnitudeADSRHelper.ACCURATE_STEP_FOR_ADSR_HELPER;
  }
  return decayIndex;
}
Program: 81278
Project: 81278
Buggy source:
int findSustain(Channel channel1,int decay) throws SoundTransformException ;

Fixed version (ground truth):
int findSustain(final double[] magnitudeArray,int decay) throws SoundTransformException ;
Program: 81279
Project: 81279
Buggy source:
int findRelease(Channel channel1) throws SoundTransformException ;

Fixed version (ground truth):
int findRelease(final double[] magnitudeArray,int samplesLength) throws SoundTransformException ;
Program: 81280
Project: 81280
Buggy source:
int findDecay(Channel channel1,int attack) throws SoundTransformException ;

Fixed version (ground truth):
int findDecay(final double[] magnitudeArray,int attack) throws SoundTransformException ;
Program: 81281
Project: 81281
Buggy source:
@Override public Note convert(final SimpleNoteInfo noteInfo,final Sound sound) throws SoundTransformException {
  final Channel channel1=sound.getChannels()[0];
  final Map<String,Object> noteInfoValues=new HashMap<String,Object>();
  noteInfoValues.put(SimpleNoteInfo.ATTACK_KEY,noteInfo.hasAttack() ? noteInfo.getAttack() : 0);
  noteInfoValues.put(SimpleNoteInfo.DECAY_KEY,noteInfo.hasDecay() ? noteInfo.getDecay() : this.adsrHelper.findDecay(channel1,((Integer)noteInfoValues.get(SimpleNoteInfo.ATTACK_KEY)).intValue()));
  noteInfoValues.put(SimpleNoteInfo.SUSTAIN_KEY,noteInfo.hasSustain() ? noteInfo.getSustain() : this.adsrHelper.findSustain(channel1,((Integer)noteInfoValues.get(SimpleNoteInfo.DECAY_KEY)).intValue()));
  noteInfoValues.put(SimpleNoteInfo.RELEASE_KEY,noteInfo.hasRelease() ? noteInfo.getRelease() : this.adsrHelper.findRelease(channel1));
  noteInfoValues.put(SimpleNoteInfo.FREQUENCY_KEY,noteInfo.hasFrequency() ? noteInfo.getFrequency() : this.frequencyHelper.findFrequency(sound));
  noteInfoValues.put(SimpleNoteInfo.NAME_KEY,noteInfo.getName());
  return new SimpleNote(new SimpleNoteInfo(noteInfoValues),sound.getChannels());
}

Fixed version (ground truth):
@Override public Note convert(final SimpleNoteInfo noteInfo,final Sound sound) throws SoundTransformException {
  final Channel channel1=sound.getChannels()[0];
  final Map<String,Object> noteInfoValues=new HashMap<String,Object>();
  final ComputeMagnitudeSoundTransform soundTransform=new ComputeMagnitudeSoundTransform(DefaultSoundToNoteService.ACCURATE_STEP);
  final double[] magnitudeArray=soundTransform.transform(channel1);
  noteInfoValues.put(SimpleNoteInfo.ATTACK_KEY,noteInfo.hasAttack() ? noteInfo.getAttack() : 0);
  noteInfoValues.put(SimpleNoteInfo.DECAY_KEY,noteInfo.hasDecay() ? noteInfo.getDecay() : this.adsrHelper.findDecay(magnitudeArray,((Integer)noteInfoValues.get(SimpleNoteInfo.ATTACK_KEY)).intValue()));
  noteInfoValues.put(SimpleNoteInfo.SUSTAIN_KEY,noteInfo.hasSustain() ? noteInfo.getSustain() : this.adsrHelper.findSustain(magnitudeArray,((Integer)noteInfoValues.get(SimpleNoteInfo.DECAY_KEY)).intValue()));
  noteInfoValues.put(SimpleNoteInfo.RELEASE_KEY,noteInfo.hasRelease() ? noteInfo.getRelease() : this.adsrHelper.findRelease(magnitudeArray,channel1.getSamplesLength()));
  noteInfoValues.put(SimpleNoteInfo.FREQUENCY_KEY,noteInfo.hasFrequency() ? noteInfo.getFrequency() : this.frequencyHelper.findFrequency(sound));
  noteInfoValues.put(SimpleNoteInfo.NAME_KEY,noteInfo.getName());
  return new SimpleNote(new SimpleNoteInfo(noteInfoValues),sound.getChannels());
}
Program: 81282
Project: 81282
Buggy source:
@Override public Note convert(final SimpleNoteInfo noteInfo,final Sound sound) throws SoundTransformException {
  final Channel channel1=sound.getChannels()[0];
  final Map<String,Object> noteInfoValues=new HashMap<String,Object>();
  final ComputeMagnitudeSoundTransform soundTransform=new ComputeMagnitudeSoundTransform(DefaultSoundToNoteService.ACCURATE_STEP);
  final double[] magnitudeArray=soundTransform.transform(channel1);
  noteInfoValues.put(SimpleNoteInfo.ATTACK_KEY,noteInfo.hasAttack() ? noteInfo.getAttack() : 0);
  noteInfoValues.put(SimpleNoteInfo.DECAY_KEY,noteInfo.hasDecay() ? noteInfo.getDecay() : this.adsrHelper.findDecay(magnitudeArray,((Integer)noteInfoValues.get(SimpleNoteInfo.ATTACK_KEY)).intValue()) * DefaultSoundToNoteService.ACCURATE_STEP);
  noteInfoValues.put(SimpleNoteInfo.SUSTAIN_KEY,noteInfo.hasSustain() ? noteInfo.getSustain() : this.adsrHelper.findSustain(magnitudeArray,((Integer)noteInfoValues.get(SimpleNoteInfo.DECAY_KEY)).intValue()) * DefaultSoundToNoteService.ACCURATE_STEP);
  noteInfoValues.put(SimpleNoteInfo.RELEASE_KEY,noteInfo.hasRelease() ? noteInfo.getRelease() : this.adsrHelper.findRelease(magnitudeArray) * DefaultSoundToNoteService.ACCURATE_STEP);
  noteInfoValues.put(SimpleNoteInfo.FREQUENCY_KEY,noteInfo.hasFrequency() ? noteInfo.getFrequency() : this.frequencyHelper.findFrequency(sound));
  noteInfoValues.put(SimpleNoteInfo.NAME_KEY,noteInfo.getName());
  return new SimpleNote(new SimpleNoteInfo(noteInfoValues),sound.getChannels());
}

Fixed version (ground truth):
@Override public Note convert(final SimpleNoteInfo noteInfo,final Sound sound) throws SoundTransformException {
  final Channel channel1=sound.getChannels()[0];
  final Map<String,Object> noteInfoValues=new HashMap<String,Object>();
  final ComputeMagnitudeSoundTransform soundTransform=new ComputeMagnitudeSoundTransform(DefaultSoundToNoteService.ACCURATE_STEP);
  final double[] magnitudeArray=soundTransform.transform(channel1);
  noteInfoValues.put(SimpleNoteInfo.ATTACK_KEY,noteInfo.hasAttack() ? noteInfo.getAttack() : 0);
  noteInfoValues.put(SimpleNoteInfo.DECAY_KEY,noteInfo.hasDecay() ? noteInfo.getDecay() : this.adsrHelper.findDecay(magnitudeArray,((Integer)noteInfoValues.get(SimpleNoteInfo.ATTACK_KEY)).intValue()) * DefaultSoundToNoteService.ACCURATE_STEP);
  noteInfoValues.put(SimpleNoteInfo.SUSTAIN_KEY,noteInfo.hasSustain() ? noteInfo.getSustain() : this.adsrHelper.findSustain(magnitudeArray,((Integer)noteInfoValues.get(SimpleNoteInfo.DECAY_KEY)).intValue() / DefaultSoundToNoteService.ACCURATE_STEP) * DefaultSoundToNoteService.ACCURATE_STEP);
  noteInfoValues.put(SimpleNoteInfo.RELEASE_KEY,noteInfo.hasRelease() ? noteInfo.getRelease() : this.adsrHelper.findRelease(magnitudeArray) * DefaultSoundToNoteService.ACCURATE_STEP);
  noteInfoValues.put(SimpleNoteInfo.FREQUENCY_KEY,noteInfo.hasFrequency() ? noteInfo.getFrequency() : this.frequencyHelper.findFrequency(sound));
  noteInfoValues.put(SimpleNoteInfo.NAME_KEY,noteInfo.getName());
  return new SimpleNote(new SimpleNoteInfo(noteInfoValues),sound.getChannels());
}
Program: 81283
Project: 81283
Buggy source:
private Channel soundToSubSound(final Channel input,final int beginning,final int end){
  long[] newsamples=new long[0];
  if (beginning < end) {
    newsamples=new long[end - beginning];
    input.copyTo(newsamples,beginning,0,end - beginning);
  }
  return new Channel(newsamples,input.getFormatInfo(),input.getChannelNum());
}

Fixed version (ground truth):
private Channel soundToSubSound(final Channel input,final int beginning,final int end){
  long[] newsamples=new long[0];
  if (beginning < end) {
    final int size=Math.min(end - beginning,input.getSamplesLength() - beginning);
    newsamples=new long[size];
    input.copyTo(newsamples,beginning,0,size);
  }
  return new Channel(newsamples,input.getFormatInfo(),input.getChannelNum());
}
Program: 81284
Project: 81284
Buggy source:
private void stopRecording(){
  if (this.recorder != null) {
    this.recorder.stop();
    this.recorder.release();
  }
}

Fixed version (ground truth):
private void stopRecording(){
  if (this.recorder != null) {
    this.recorder.stop();
    this.recorder.release();
  }
  this.recordingThread.stop();
}
Program: 81286
Project: 81286
Buggy source:
@Override public void run(){
  try {
    Thread.sleep(4000);
  }
 catch (  final InterruptedException e) {
    throw new RuntimeException(e);
  }
  boolean notified=false;
synchronized (stop) {
    while (!notified) {
      stop.notify();
      notified=true;
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  try {
    Thread.sleep(4000);
  }
 catch (  final InterruptedException e) {
    throw new RuntimeException(e);
  }
  boolean notified=false;
synchronized (stop) {
    while (!notified) {
      stop.notifyAll();
      notified=true;
    }
  }
}
Program: 81288
Project: 81288
Buggy source:
private int getSamplesIndex(final int index){
  int realIndex=index;
  int channelPartIndex=0;
  while (channelPartIndex < this.channelParts.size() && realIndex > this.channelParts.get(channelPartIndex).getSamplesLength()) {
    realIndex-=this.channelParts.get(channelPartIndex).getSamplesLength();
    channelPartIndex++;
  }
  return realIndex;
}

Fixed version (ground truth):
private int getSamplesIndex(final int index){
  int realIndex=index;
  int channelPartIndex=0;
  while (channelPartIndex < this.channelParts.size() && realIndex >= this.channelParts.get(channelPartIndex).getSamplesLength()) {
    realIndex-=this.channelParts.get(channelPartIndex).getSamplesLength();
    channelPartIndex++;
  }
  return realIndex;
}
Program: 81289
Project: 81289
Buggy source:
private int getChannelPartIndex(final int index){
  int realIndex=index;
  int channelPartIndex=0;
  while (channelPartIndex < this.channelParts.size() && realIndex > this.channelParts.get(channelPartIndex).getSamplesLength()) {
    realIndex-=this.channelParts.get(channelPartIndex).getSamplesLength();
    channelPartIndex++;
  }
  if (channelPartIndex == this.channelParts.size()) {
    throw new SoundTransformRuntimeException(new SoundTransformException(SegmentedChannelErrorCode.ARRAY_INDEX_OUT_OF_BOUNDS,new ArrayIndexOutOfBoundsException(),index));
  }
  return channelPartIndex;
}

Fixed version (ground truth):
private int getChannelPartIndex(final int index){
  int realIndex=index;
  int channelPartIndex=0;
  while (channelPartIndex < this.channelParts.size() && realIndex >= this.channelParts.get(channelPartIndex).getSamplesLength()) {
    realIndex-=this.channelParts.get(channelPartIndex).getSamplesLength();
    channelPartIndex++;
  }
  if (channelPartIndex == this.channelParts.size()) {
    throw new SoundTransformRuntimeException(new SoundTransformException(SegmentedChannelErrorCode.ARRAY_INDEX_OUT_OF_BOUNDS,new ArrayIndexOutOfBoundsException(),index));
  }
  return channelPartIndex;
}
Program: 81290
Project: 81290
Buggy source:
@Override public Channel initSound(final Channel input){
  if (this.note) {
    this.step=input.getSamplesLength();
    this.fsLimit=input.getSamplesLength();
    this.loudestfreqs=new float[1];
  }
 else {
    this.loudestfreqs=new float[(int)(input.getSamplesLength() / this.step) + 1];
    this.fsLimit=input.getSampleRate();
  }
  this.soundLength=input.getSamplesLength();
  return super.initSound(input);
}

Fixed version (ground truth):
@Override public Channel initSound(final Channel input1){
  this.input=input1;
  if (this.note) {
    this.step=input1.getSamplesLength();
    this.fsLimit=input1.getSamplesLength();
    this.loudestfreqs=new float[1];
  }
 else {
    this.loudestfreqs=new float[(int)(input1.getSamplesLength() / this.step) + 1];
    this.fsLimit=input1.getSampleRate();
  }
  return super.initSound(input1);
}
Program: 81291
Project: 81291
Buggy source:
public void transformFrequencies(final Object spectrum,final float sampleRate,final int offset,final int powOf2NearestLength,final int length,final float soundLevelInDB){
  final int percent=(int)Math.floor(100.0 * (offset / this.step) / (this.soundLength / this.step));
  if (percent > Math.floor(100.0 * ((offset - this.step) / this.step) / (this.soundLength / this.step))) {
    this.log(new LogEvent(PeakFindSoundTransformEventCode.ITERATION_IN_PROGRESS,(int)(offset / this.step),(int)Math.ceil(this.soundLength / this.step),percent));
  }
  float f0=0;
  if (soundLevelInDB > 30 || this.note) {
    final float[] peaks=new float[10];
    for (int i=1; i <= 10; i++) {
      peaks[i - 1]=this.f0(spectrum,sampleRate,i);
    }
    Arrays.sort(peaks);
    f0=this.bestCandidate(peaks);
  }
  if (this.note) {
    this.detectedNoteVolume=soundLevelInDB;
  }
  this.loudestfreqs[(int)(offset / this.step)]=f0;
}

Fixed version (ground truth):
public void transformFrequencies(final Object spectrum,final float sampleRate,final int offset,final int powOf2NearestLength,final int length,final float soundLevelInDB){
  final int percent=(int)Math.floor(100.0 * (offset / this.step) / (this.input.getSamplesLength() / this.step));
  if (percent > Math.floor(100.0 * ((offset - this.step) / this.step) / (this.input.getSamplesLength() / this.step))) {
    this.log(new LogEvent(PeakFindSoundTransformEventCode.ITERATION_IN_PROGRESS,(int)(offset / this.step),(int)Math.ceil(this.input.getSamplesLength() / this.step),percent));
  }
  float f0=0;
  if (soundLevelInDB > 30 || this.note) {
    final float[] peaks=new float[10];
    for (int i=1; i <= 10; i++) {
      peaks[i - 1]=this.f0(spectrum,sampleRate,i);
    }
    Arrays.sort(peaks);
    f0=this.bestCandidate(peaks);
  }
  if (this.note) {
    this.detectedNoteVolume=soundLevelInDB;
  }
  this.ensureArrayLengthIsCorrect(offset);
  this.loudestfreqs[(int)(offset / this.step)]=f0;
}
Program: 81292
Project: 81292
Buggy source:
private <O>Thread getStreamReader(final StreamInfo streamInfo,final RunnableWithInputStream runnable,final Class<O> returnType,final ByteBuffer targetByteBuffer,final List<InputStream> streamsFromBuffer,final List<O> results){
  return new Thread(){
    @Override public void run(){
      try {
        DefaultRecordSoundService.this.waitForNewBytes(targetByteBuffer);
        final InputStream inputStream=DefaultRecordSoundService.this.audioFileService.streamFromRawStream(new ByteArrayInputStream(targetByteBuffer.array()),streamInfo);
        if (inputStream.available() > 0) {
          streamsFromBuffer.add(inputStream);
          results.add(runnable.runWithInputStreamAndGetResult(inputStream,streamInfo,returnType));
        }
      }
 catch (      final IOException e) {
        throw new SoundTransformRuntimeException(new SoundTransformException(DefaultRecordSoundServiceErrorCode.PROBLEM_WHILE_READING_THE_BUFFER_IN_A_CONTINUOUS_RECORDING,e));
      }
catch (      final SoundTransformException e) {
        throw new SoundTransformRuntimeException(e);
      }
    }
  }
;
}

Fixed version (ground truth):
private <O>Thread getStreamReader(final StreamInfo streamInfo,final RunnableWithInputStream runnable,final Class<O> returnType,final ByteBuffer targetByteBuffer,final List<InputStream> streamsFromBuffer,final List<O> results){
  return new Thread(){
    @Override public void run(){
      while (true) {
        try {
          DefaultRecordSoundService.this.waitForNewBytes(targetByteBuffer);
          final InputStream inputStream=DefaultRecordSoundService.this.audioFileService.streamFromRawStream(new ByteArrayInputStream(targetByteBuffer.array()),streamInfo);
          if (inputStream.available() > 0) {
            streamsFromBuffer.add(inputStream);
            results.add(runnable.runWithInputStreamAndGetResult(inputStream,streamInfo,returnType));
          }
        }
 catch (        final IOException e) {
          throw new SoundTransformRuntimeException(new SoundTransformException(DefaultRecordSoundServiceErrorCode.PROBLEM_WHILE_READING_THE_BUFFER_IN_A_CONTINUOUS_RECORDING,e));
        }
catch (        final SoundTransformException e) {
          throw new SoundTransformRuntimeException(e);
        }
      }
    }
  }
;
}
Program: 81293
Project: 81293
Buggy source:
private void waitForNewBytes(final ByteBuffer targetByteBuffer) throws SoundTransformException {
  boolean waited=false;
synchronized (targetByteBuffer) {
    try {
      while (!waited) {
        targetByteBuffer.wait();
        waited=true;
      }
    }
 catch (    final InterruptedException e) {
      throw new SoundTransformRuntimeException(new SoundTransformException(DefaultRecordSoundServiceErrorCode.NOT_ABLE,e));
    }
  }
}

Fixed version (ground truth):
private void waitForNewBytes(final ByteBuffer targetByteBuffer) throws SoundTransformException {
  boolean waited=false;
synchronized (targetByteBuffer) {
    try {
      while (!waited) {
        targetByteBuffer.wait();
        waited=true;
      }
    }
 catch (    final InterruptedException e) {
      this.log(new LogEvent(DefaultRecordSoundServiceEventCode.STREAM_READER_STOPPED,e));
    }
  }
}
Program: 81294
Project: 81294
Buggy source:
@Override public InputStream recordLimitedTimeRawInputStream(final StreamInfo streamInfo) throws SoundTransformException {
  final long millis=(long)(streamInfo.getFrameLength() / streamInfo.getSampleRate() * DefaultRecordSoundService.MS_PER_SECOND);
  final Object stop=new Object();
  new Thread(){
    @Override public void run(){
      try {
        Thread.sleep(millis);
      }
 catch (      final InterruptedException e) {
        throw new SoundTransformRuntimeException(DefaultRecordSoundServiceErrorCode.NOT_ABLE,e);
      }
synchronized (stop) {
        stop.notify();
      }
    }
  }
.start();
  return this.recordRawInputStream(streamInfo,stop);
}

Fixed version (ground truth):
@Override public InputStream recordLimitedTimeRawInputStream(final StreamInfo streamInfo) throws SoundTransformException {
  final long millis=(long)(streamInfo.getFrameLength() / streamInfo.getSampleRate() * DefaultRecordSoundService.MS_PER_SECOND);
  final Object stop=new Object();
  new Thread(){
    @Override public void run(){
      try {
        Thread.sleep(millis);
      }
 catch (      final InterruptedException e) {
        throw new SoundTransformRuntimeException(DefaultRecordSoundServiceErrorCode.NOT_ABLE,e,e.getMessage());
      }
synchronized (stop) {
        stop.notify();
      }
    }
  }
.start();
  return this.recordRawInputStream(streamInfo,stop);
}
Program: 81295
Project: 81295
Buggy source:
@Override public <O>List<O> recordAndProcess(final StreamInfo streamInfo,final Object stop,final RunnableWithInputStream runnable,final Class<O> returnType) throws SoundTransformException {
  final ByteBuffer targetByteBuffer=this.startRecordingAndReturnByteBuffer(streamInfo,stop);
  final List<InputStream> streamsFromBuffer=new ArrayList<InputStream>();
  final List<O> results=new ArrayList<O>();
  final Thread streamReader=this.getStreamReader(streamInfo,runnable,returnType,targetByteBuffer,streamsFromBuffer,results);
  streamReader.start();
  try {
    Thread.sleep(DefaultRecordSoundService.ARBITRARY_SLEEP_TIME_TO_ENSURE_THE_STREAMING_IS_INITIALIZED);
  }
 catch (  final InterruptedException e) {
    throw new SoundTransformRuntimeException(new SoundTransformException(DefaultRecordSoundServiceErrorCode.NOT_ABLE,e));
  }
  this.stopDetector(stop,streamReader).start();
  return results;
}

Fixed version (ground truth):
@Override public <O>List<O> recordAndProcess(final StreamInfo streamInfo,final Object stop,final RunnableWithInputStream runnable,final Class<O> returnType) throws SoundTransformException {
  final ByteBuffer targetByteBuffer=this.startRecordingAndReturnByteBuffer(streamInfo,stop);
  final List<InputStream> streamsFromBuffer=new ArrayList<InputStream>();
  final List<O> results=new ArrayList<O>();
  final Thread streamReader=this.getStreamReader(streamInfo,runnable,returnType,targetByteBuffer,streamsFromBuffer,results);
  streamReader.start();
  try {
    Thread.sleep(DefaultRecordSoundService.ARBITRARY_SLEEP_TIME_TO_ENSURE_THE_STREAMING_IS_INITIALIZED);
  }
 catch (  final InterruptedException e) {
    throw new SoundTransformRuntimeException(new SoundTransformException(DefaultRecordSoundServiceErrorCode.NOT_ABLE,e,e.getMessage()));
  }
  this.stopDetector(stop,streamReader).start();
  return results;
}
Program: 81296
Project: 81296
Buggy source:
private void stopRecording(){
  if (this.recorder != null) {
    this.recorder.stop();
    this.recorder.release();
  }
  this.recordingThread.stop();
}

Fixed version (ground truth):
private void stopRecording(){
  if (this.recorder != null) {
    this.recorder.stop();
    this.recorder.release();
  }
  this.recordingThread.stopRecording();
}
Program: 81297
Project: 81297
Buggy source:
@Override public ByteBuffer startRecordingAndReturnByteBuffer(final Object audioFormat,final Object stop) throws SoundTransformException {
  final RecordSoundProcessor processor=this;
  if (!(audioFormat instanceof StreamInfo)) {
    throw new SoundTransformException(AndroidRecordSoundProcessorErrorCode.STREAM_INFO_EXPECTED,new IllegalArgumentException());
  }
  final StreamInfo streamInfo=(StreamInfo)audioFormat;
  this.recorder=this.findAudioRecorder(streamInfo);
  this.bytesExporter=$.select(OutputAsByteBuffer.class);
  this.bytesExporter.init(this.bufferSize);
  this.recordingThread=new AndroidRecorderThread(this.recorder,bytesExporter);
  this.recorder.startRecording();
  this.recordingThread.start();
  new Thread(){
    @Override public void run(){
      try {
        processor.stopProperly(stop);
      }
 catch (      final SoundTransformException soundTransformException) {
        throw new SoundTransformRuntimeException(soundTransformException);
      }
    }
  }
.start();
  return (ByteBuffer)this.bytesExporter.getOutput();
}

Fixed version (ground truth):
@Override public ByteBuffer startRecordingAndReturnByteBuffer(final Object audioFormat,final Object stop) throws SoundTransformException {
  final RecordSoundProcessor processor=this;
  if (!(audioFormat instanceof StreamInfo)) {
    throw new SoundTransformException(AndroidRecordSoundProcessorErrorCode.STREAM_INFO_EXPECTED,new IllegalArgumentException());
  }
  final StreamInfo streamInfo=(StreamInfo)audioFormat;
  this.recorder=this.findAudioRecorder(streamInfo);
  this.bytesExporter=$.select(OutputAsByteBuffer.class);
  this.bytesExporter.init(this.bufferSize);
  this.recordingThread=new AndroidRecorderThread(this.recorder,bytesExporter);
  this.recorder.startRecording();
  this.recordingThread.start();
  new StopProperlyThread(processor,stop).start();
  return (ByteBuffer)this.bytesExporter.getOutput();
}
Program: 81298
Project: 81298
Buggy source:
/** 
 * @param bufferSize
 * @param androidRecordSoundProcessor
 * @param bytesExporter1
 */
AndroidRecorderThread(final AudioRecord audioRecord1,final BytesExporterFromThread<?> bytesExporter1){
  this.audioRecord=audioRecord1;
  this.bytesExporter=bytesExporter1;
}

Fixed version (ground truth):
/** 
 * @param bufferSize
 * @param androidRecordSoundProcessor
 * @param bytesExporter1
 */
AndroidRecorderThread(final AudioRecord audioRecord1,final BytesExporterFromThread<?> bytesExporter1){
  this.audioRecord=audioRecord1;
  this.bytesExporter=bytesExporter1;
  this.setName(this.getClass().getSimpleName());
}
Program: 81299
Project: 81299
Buggy source:
/** 
 * @param dataLine1
 */
TargetDataLineReaderThread(final TargetDataLine dataLine1,final BytesExporterFromThread<?> exporter1){
  this.dataLine=dataLine1;
  this.exporter=exporter1;
}

Fixed version (ground truth):
/** 
 * @param dataLine1
 */
TargetDataLineReaderThread(final TargetDataLine dataLine1,final BytesExporterFromThread<?> exporter1){
  this.dataLine=dataLine1;
  this.exporter=exporter1;
  this.setName(this.getClass().getSimpleName());
}
Program: 81300
Project: 81300
Buggy source:
@Override public ByteBuffer startRecordingAndReturnByteBuffer(final Object audioFormat1,final Object stop) throws SoundTransformException {
  final RecordSoundProcessor processor=this;
  if (!(audioFormat1 instanceof AudioFormat)) {
    throw new SoundTransformException(TargetDataLineRecordSoundProcessorErrorCode.AUDIO_FORMAT_EXPECTED,new IllegalArgumentException());
  }
  final AudioFormat audioFormat=(AudioFormat)audioFormat1;
  final OutputAsByteBuffer bytesExporter=$.select(OutputAsByteBuffer.class);
  bytesExporter.init(TargetDataLineRecordSoundProcessor.DEFAULT_BYTE_BUFFER_SIZE);
  this.startRecording(audioFormat,bytesExporter);
  new Thread(){
    @Override public void run(){
      try {
        processor.stopProperly(stop);
      }
 catch (      final SoundTransformException soundTransformException) {
        throw new SoundTransformRuntimeException(soundTransformException);
      }
    }
  }
.start();
  return bytesExporter.getOutput();
}

Fixed version (ground truth):
@Override public ByteBuffer startRecordingAndReturnByteBuffer(final Object audioFormat1,final Object stop) throws SoundTransformException {
  final RecordSoundProcessor processor=this;
  if (!(audioFormat1 instanceof AudioFormat)) {
    throw new SoundTransformException(TargetDataLineRecordSoundProcessorErrorCode.AUDIO_FORMAT_EXPECTED,new IllegalArgumentException());
  }
  final AudioFormat audioFormat=(AudioFormat)audioFormat1;
  final OutputAsByteBuffer bytesExporter=$.select(OutputAsByteBuffer.class);
  bytesExporter.init(TargetDataLineRecordSoundProcessor.DEFAULT_BYTE_BUFFER_SIZE);
  this.startRecording(audioFormat,bytesExporter);
  new StopProperlyThread(stop,processor).start();
  return bytesExporter.getOutput();
}
Program: 81301
Project: 81301
Buggy source:
private Thread getStreamReader(final StreamInfo streamInfo,final ByteBuffer targetByteBuffer,final List<Sound> results){
  final AudioFileService<?> audioFileService1=this.audioFileService;
  final InputStreamToSoundService<?> isToSoundService1=this.isToSoundService;
  return new Thread(){
    private void waitForNewBytes(    final ByteBuffer targetByteBuffer) throws SoundTransformException {
      boolean waited=false;
synchronized (targetByteBuffer) {
        try {
          while (!waited) {
            targetByteBuffer.wait();
            waited=true;
          }
        }
 catch (        final InterruptedException e) {
          new LogEvent(DefaultRecordSoundServiceEventCode.STREAM_READER_STOPPED,e);
        }
      }
    }
    @Override public void run(){
      while (true) {
        try {
          this.waitForNewBytes(targetByteBuffer);
          final InputStream inputStream=audioFileService1.streamFromRawStream(new ByteArrayInputStream(targetByteBuffer.array()),streamInfo);
          if (inputStream.available() > 0) {
            results.add(isToSoundService1.fromInputStream(inputStream,streamInfo));
          }
        }
 catch (        final IOException e) {
          throw new SoundTransformRuntimeException(new SoundTransformException(DefaultRecordSoundServiceErrorCode.PROBLEM_WHILE_READING_THE_BUFFER_IN_A_CONTINUOUS_RECORDING,e));
        }
catch (        final SoundTransformException e) {
          throw new SoundTransformRuntimeException(e);
        }
      }
    }
  }
;
}

Fixed version (ground truth):
private StreamReaderThread getStreamReader(final StreamInfo streamInfo,final ByteBuffer targetByteBuffer,final List<Sound> results){
  final AudioFileService<?> audioFileService1=this.audioFileService;
  final InputStreamToSoundService<?> isToSoundService1=this.isToSoundService;
  return new StreamReaderThread(results,streamInfo,targetByteBuffer,audioFileService1,isToSoundService1);
}
Program: 81302
Project: 81302
Buggy source:
private List<Sound> recordInBackgroundTask(final StreamInfo streamInfo,final Object stop) throws SoundTransformException {
  final ByteBuffer targetByteBuffer=this.startRecordingAndReturnByteBuffer(streamInfo,stop);
  final List<Sound> results=new ArrayList<Sound>();
  final Thread streamReader=this.getStreamReader(streamInfo,targetByteBuffer,results);
  streamReader.start();
  try {
    Thread.sleep(DefaultRecordSoundService.ARBITRARY_SLEEP_TIME_TO_ENSURE_THE_STREAMING_IS_INITIALIZED);
  }
 catch (  final InterruptedException e) {
    throw new SoundTransformRuntimeException(new SoundTransformException(DefaultRecordSoundServiceErrorCode.NOT_ABLE,e,e.getMessage()));
  }
  this.stopDetector(stop,streamReader,targetByteBuffer).start();
  return results;
}

Fixed version (ground truth):
private List<Sound> recordInBackgroundTask(final StreamInfo streamInfo,final Object stop) throws SoundTransformException {
  final ByteBuffer targetByteBuffer=this.startRecordingAndReturnByteBuffer(streamInfo,stop);
  final List<Sound> results=new ArrayList<Sound>();
  final StreamReaderThread streamReader=this.getStreamReader(streamInfo,targetByteBuffer,results);
  streamReader.start();
  try {
    Thread.sleep(DefaultRecordSoundService.ARBITRARY_SLEEP_TIME_TO_ENSURE_THE_STREAMING_IS_INITIALIZED);
  }
 catch (  final InterruptedException e) {
    throw new SoundTransformRuntimeException(new SoundTransformException(DefaultRecordSoundServiceErrorCode.NOT_ABLE,e,e.getMessage()));
  }
  this.stopDetector(stop,streamReader,targetByteBuffer).start();
  return results;
}
Program: 81303
Project: 81303
Buggy source:
private Thread stopDetector(final Object stop,final Thread streamReader,final ByteBuffer targetByteBuffer){
  return new Thread(){
    @Override public void run(){
synchronized (stop) {
        try {
          boolean waited=false;
          while (!waited) {
            stop.wait();
            waited=true;
          }
synchronized (targetByteBuffer) {
            if (waited) {
              targetByteBuffer.notifyAll();
            }
          }
          streamReader.interrupt();
        }
 catch (        final InterruptedException e) {
          targetByteBuffer.notify();
          streamReader.interrupt();
        }
      }
      streamReader.interrupt();
    }
  }
;
}

Fixed version (ground truth):
private Thread stopDetector(final Object stop,final StreamReaderThread streamReader,final ByteBuffer targetByteBuffer){
  return new StopDetectorThread(targetByteBuffer,stop,streamReader);
}
Program: 81304
Project: 81304
Buggy source:
@Override public InputStream recordLimitedTimeRawInputStream(final StreamInfo streamInfo) throws SoundTransformException {
  final long millis=(long)(streamInfo.getFrameLength() / streamInfo.getSampleRate() * DefaultRecordSoundService.MS_PER_SECOND);
  final Object stop=new Object();
  new Thread(){
    @Override public void run(){
      try {
        Thread.sleep(millis);
      }
 catch (      final InterruptedException e) {
        throw new SoundTransformRuntimeException(DefaultRecordSoundServiceErrorCode.NOT_ABLE,e,e.getMessage());
      }
synchronized (stop) {
        stop.notify();
      }
    }
  }
.start();
  return this.recordRawInputStream(streamInfo,stop);
}

Fixed version (ground truth):
@Override public InputStream recordLimitedTimeRawInputStream(final StreamInfo streamInfo) throws SoundTransformException {
  final long millis=(long)(streamInfo.getFrameLength() / streamInfo.getSampleRate() * DefaultRecordSoundService.MS_PER_SECOND);
  final Object stop=new Object();
  new SleepThread(stop,millis).start();
  return this.recordRawInputStream(streamInfo,stop);
}
Program: 81305
Project: 81305
Buggy source:
@Override public void run(){
  while (true) {
    try {
      this.waitForNewBytes(targetByteBuffer);
      final InputStream inputStream=audioFileService1.streamFromRawStream(new ByteArrayInputStream(targetByteBuffer.array()),streamInfo);
      if (inputStream.available() > 0) {
        results.add(isToSoundService1.fromInputStream(inputStream,streamInfo));
      }
    }
 catch (    final IOException e) {
      throw new SoundTransformRuntimeException(new SoundTransformException(DefaultRecordSoundServiceErrorCode.PROBLEM_WHILE_READING_THE_BUFFER_IN_A_CONTINUOUS_RECORDING,e));
    }
catch (    final SoundTransformException e) {
      throw new SoundTransformRuntimeException(e);
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  try {
    Thread.sleep(millis);
  }
 catch (  final InterruptedException e) {
    throw new SoundTransformRuntimeException(DefaultRecordSoundServiceErrorCode.NOT_ABLE,e,e.getMessage());
  }
synchronized (stop) {
    stop.notify();
  }
}
Program: 81307
Project: 81307
Buggy source:
@Test public void shapeAndMockRecordedSoundInParallel() throws Exception {
  this.rule.hashCode();
  final byte[][] buffers=new byte[15][1024];
  for (int i=0; i < 14; i++) {
    new Random().nextBytes(buffers[i]);
  }
  buffers[14]=new byte[0];
  this.mockRecordSoundProcessor(buffers);
  final Object stop=new Object();
  new Thread(){
    @Override public void run(){
      try {
        Thread.sleep(4000);
      }
 catch (      final InterruptedException e) {
        throw new RuntimeException(e);
      }
      boolean notified=false;
synchronized (stop) {
        while (!notified) {
          stop.notifyAll();
          notified=true;
        }
      }
    }
  }
.start();
  final Sound resultSound=FluentClient.start().withAPack("String_Node_Str",Thread.currentThread().getContextClassLoader().getResourceAsStream("String_Node_Str")).whileRecordingASound(new StreamInfo(2,10000,2,44100.0f,false,true,null),stop).findLoudestFrequencies().shapeIntoSound("String_Node_Str","String_Node_Str",new FormatInfo(2,44100f)).stopWithSound();
  Assert.assertThat(resultSound,new IsNot<Sound>(new IsNull<Sound>()));
  Assert.assertNotNull(resultSound.getChannels());
  Assert.assertEquals(resultSound.getChannels().length,1);
  Assert.assertNotEquals(resultSound.getChannels()[0].getSamplesLength(),0);
}

Fixed version (ground truth):
@Test public void shapeAndMockRecordedSoundInParallel() throws Exception {
  this.rule.hashCode();
  final byte[][] buffers=new byte[15][1024];
  for (int i=0; i < 14; i++) {
    new Random().nextBytes(buffers[i]);
  }
  buffers[14]=new byte[0];
  this.mockRecordSoundProcessor(buffers);
  FluentClient.start().withAPack("String_Node_Str",Thread.currentThread().getContextClassLoader().getResourceAsStream("String_Node_Str"));
  final Object stop=new Object();
  new Thread("String_Node_Str"){
    @Override public void run(){
      try {
        Thread.sleep(300);
      }
 catch (      final InterruptedException e) {
        throw new RuntimeException(e);
      }
      boolean notified=false;
synchronized (stop) {
        while (!notified) {
          stop.notifyAll();
          notified=true;
        }
      }
    }
  }
.start();
  final Sound resultSound=FluentClient.start().whileRecordingASound(new StreamInfo(2,1024,2,8000.0f,false,true,null),stop).findLoudestFrequencies().shapeIntoSound("String_Node_Str","String_Node_Str",new FormatInfo(2,8000f)).stopWithSound();
  Assert.assertThat(resultSound,new IsNot<Sound>(new IsNull<Sound>()));
  Assert.assertNotNull(resultSound.getChannels());
  Assert.assertEquals(resultSound.getChannels().length,1);
  Assert.assertNotEquals(resultSound.getChannels()[0].getSamplesLength(),0);
}
Program: 81308
Project: 81308
Buggy source:
@Override public void run(){
  try {
    Thread.sleep(4000);
  }
 catch (  final InterruptedException e) {
    throw new RuntimeException(e);
  }
  boolean notified=false;
synchronized (stop) {
    while (!notified) {
      stop.notifyAll();
      notified=true;
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  try {
    Thread.sleep(300);
  }
 catch (  final InterruptedException e) {
    throw new RuntimeException(e);
  }
  boolean notified=false;
synchronized (stop) {
    while (!notified) {
      stop.notifyAll();
      notified=true;
    }
  }
}
Program: 81309
Project: 81309
Buggy source:
private float surroundFreqInRange(final float inputValue,final float low,final float high){
  float result=inputValue;
  while (result < low) {
    result*=SimpleSurroundInOctaveProcessor.TWO;
  }
  while (result > high) {
    result/=SimpleSurroundInOctaveProcessor.TWO;
  }
  while (result < low && result * SimpleSurroundInOctaveProcessor.TWO > high) {
    result*=SimpleSurroundInOctaveProcessor.OCTAVE_HALF;
  }
  return result;
}

Fixed version (ground truth):
private float surroundFreqInRange(final float inputValue,final float low,final float high){
  float result=inputValue;
  if (result == 0) {
    return 0;
  }
  while (result < low) {
    result*=SimpleSurroundInOctaveProcessor.TWO;
  }
  while (result > high) {
    result/=SimpleSurroundInOctaveProcessor.TWO;
  }
  while (result < low && result * SimpleSurroundInOctaveProcessor.TWO > high) {
    result*=SimpleSurroundInOctaveProcessor.OCTAVE_HALF;
  }
  return result;
}