nus-yam/ex-repair huggingface dataset:
Program: 20021
Project: 20021
Buggy source:
/** 
 * Constructs a CepstrumFileDumper.
 * @param propsFile the Sphinx properties file
 * @param inputAudioFile the input audio file
 */
public CepstrumFileDumper(String propsFile,String inputAudioFile) throws FileNotFoundException, IOException {
  try {
    String context="String_Node_Str";
    SphinxProperties.initContext(context,new URL("String_Node_Str" + propsFile));
    SphinxProperties props=SphinxProperties.getSphinxProperties(context);
    featureLength=props.getInt(FeatureExtractor.PROP_FEATURE_LENGTH,13);
    AudioSource audioSource=new StreamAudioSource("String_Node_Str",context,(new FileInputStream(inputAudioFile)),inputAudioFile);
    frontend=new FrontEnd("String_Node_Str",context,audioSource);
    allFeatures=new LinkedList();
    getAllFeatures();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
/** 
 * Constructs a CepstrumFileDumper.
 * @param propsFile the Sphinx properties file
 * @param inputAudioFile the input audio file
 */
public CepstrumFileDumper(String propsFile,String inputAudioFile) throws FileNotFoundException, IOException {
  try {
    String context="String_Node_Str";
    String pwd=System.getProperty("String_Node_Str");
    SphinxProperties.initContext(context,new URL("String_Node_Str" + pwd + File.separatorChar+ propsFile));
    SphinxProperties props=SphinxProperties.getSphinxProperties(context);
    featureLength=props.getInt(FeatureExtractor.PROP_FEATURE_LENGTH,13);
    AudioSource audioSource=new StreamAudioSource("String_Node_Str",context,(new FileInputStream(inputAudioFile)),inputAudioFile);
    frontend=new FrontEnd("String_Node_Str",context,audioSource);
    allFeatures=new LinkedList();
    getAllFeatures();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}
Program: 20022
Project: 20022
Buggy source:
/** 
 * Function used by add() internally. It returns the difference between the highest number and the total summation of two numbers. Considering the expression (in which we assume natural log) <p><b>log(a + b) = log(a) + log(1 + exp(log(b) - log(a)))</b></p> the current function returns the second term of the right hand side of the equality above, generalized for the case of any log base. This function is contructed as a table lookup.
 * @param index the index into the addTable
 * @return the value pointed to by index
 */
private final double addTable(double index){
  return theAddTable[(int)(index)];
}

Fixed version (ground truth):
/** 
 * Function used by add() internally. It returns the difference between the highest number and the total summation of two numbers. Considering the expression (in which we assume natural log) <p><b>log(a + b) = log(a) + log(1 + exp(log(b) - log(a)))</b></p> the current function returns the second term of the right hand side of the equality above, generalized for the case of any log base. This function is contructed as a table lookup.
 * @param index the index into the addTable
 * @return the value pointed to by index
 */
private final double addTable(double index){
  if (OLD_AND_SLOW_ADD) {
    return addTableActualComputation(index);
  }
 else {
    return theAddTable[(int)(index)];
  }
}
Program: 20023
Project: 20023
Buggy source:
/** 
 * Create a log math class. Also create the addTable table, which depends on the log base.
 * @param base the log base
 */
private LogMath(double base){
  logBase=base;
  naturalLogBase=Math.log(logBase);
  inverseNaturalLogBase=1.0 / naturalLogBase;
  logZero=-Double.MAX_VALUE;
  double innerSummation;
  int entriesInTheAddTable;
  final int veryLargeNumberOfEntries=150000;
  entriesInTheAddTable=linearToLog(Math.power(logbase,0.5) - 1);
  if (entriesInTheTable > veryLargeNumberOfEntries) {
    entriesInTheAddTable=veryLargeNumberOfEntries;
  }
  theAddTable=new double[entriesInTheAddTable];
  for (int index=0; index < entriesInTheAddTable; index++) {
    innerSummation=logToLinear(-index);
    innerSummation+=1.0f;
    theAddTable[index]=linearToLog(innerSummation);
  }
}

Fixed version (ground truth):
/** 
 * Create a log math class. Also create the addTable table, which depends on the log base.
 * @param base the log base
 */
private LogMath(double base){
  logBase=base;
  naturalLogBase=Math.log(logBase);
  inverseNaturalLogBase=1.0 / naturalLogBase;
  logZero=-Double.MAX_VALUE;
  double innerSummation;
  int entriesInTheAddTable;
  final int veryLargeNumberOfEntries=150000;
  entriesInTheAddTable=(int)-Math.rint(linearToLog(Math.pow(logBase,0.5) - 1));
  if (entriesInTheAddTable > veryLargeNumberOfEntries) {
    entriesInTheAddTable=veryLargeNumberOfEntries;
  }
  if (true) {
    System.out.println("String_Node_Str" + entriesInTheAddTable + "String_Node_Str");
  }
  theAddTable=new double[entriesInTheAddTable];
  for (int index=0; index < entriesInTheAddTable; index++) {
    innerSummation=logToLinear(-index);
    innerSummation+=1.0f;
    theAddTable[index]=linearToLog(innerSummation);
  }
}
Program: 20024
Project: 20024
Buggy source:
/** 
 * Constructs an EnergyEndpointer with the given name, context, and CepstrumSource predecessor.
 * @param name the name of this EnergyEndpointer
 * @param context the context of the SphinxProperties thisEnergyEndpointer uses
 * @param predecessor the CepstrumSource where this EnergyEndpointergets Cepstrum from
 */
public EnergyEndpointer(String name,String context,CepstrumSource predecessor) throws IOException {
  super(name,context);
  initSphinxProperties();
  this.predecessor=predecessor;
  this.inputBuffer=new LinkedList();
  reset();
}

Fixed version (ground truth):
/** 
 * Constructs an EnergyEndpointer with the given name, context, and CepstrumSource predecessor.
 * @param name the name of this EnergyEndpointer
 * @param context the context of the SphinxProperties thisEnergyEndpointer uses
 * @param predecessor the CepstrumSource where this EnergyEndpointergets Cepstrum from
 */
public EnergyEndpointer(String name,String context,CepstrumSource predecessor) throws IOException {
  super(name,context);
  initSphinxProperties();
  this.predecessor=predecessor;
  this.outputQueue=new LinkedList();
  reset();
}
Program: 20025
Project: 20025
Buggy source:
/** 
 * Reads a Cepstrum from the predecessor, and use it to do endpointing.
 * @return the Cepstrum read from the predecessor
 */
private Cepstrum readCepstrum() throws IOException {
  Cepstrum cepstrum=predecessor.getCepstrum();
  if (cepstrum != null) {
    numCepstra++;
    if (cepstrum.hasContent()) {
      if (cepstrum.getEnergy() < startLow || cepstrum.getEnergy() < endLow) {
        processLowEnergyCepstrum(cepstrum);
      }
 else       if (startLow < cepstrum.getEnergy() && cepstrum.getEnergy() <= startHigh) {
        processMediumEnergyCepstrum(cepstrum);
      }
 else       if (cepstrum.getEnergy() > startHigh) {
        processHighEnergyCepstrum(cepstrum);
      }
    }
  }
  return cepstrum;
}

Fixed version (ground truth):
/** 
 * Reads a Cepstrum from the predecessor, and use it to do endpointing.
 * @return the Cepstrum read from the predecessor
 */
private Cepstrum readCepstrum() throws IOException {
  Cepstrum cepstrum=predecessor.getCepstrum();
  if (cepstrum != null) {
    numCepstra++;
    if (cepstrum.hasContent()) {
      System.out.println("String_Node_Str" + cepstrum.getEnergy());
      if (cepstrum.getEnergy() < startLow || cepstrum.getEnergy() < endLow) {
        processLowEnergyCepstrum(cepstrum);
      }
 else       if (startLow < cepstrum.getEnergy() && cepstrum.getEnergy() <= startHigh) {
        processMediumEnergyCepstrum(cepstrum);
      }
 else       if (cepstrum.getEnergy() > startHigh) {
        processHighEnergyCepstrum(cepstrum);
      }
    }
  }
  return cepstrum;
}
Program: 20026
Project: 20026
Buggy source:
/** 
 * Inserts a SPEECH_END at the appropriate place.
 */
private void insertSpeechEnd(){
  int index=inputBuffer.indexOf(endOffsetFrame);
  endOffsetFrame=null;
  if (index < 0) {
    index=0;
  }
  lastSpeechEndFrame=new Cepstrum(Signal.SPEECH_END);
  inputBuffer.add(index,lastSpeechEndFrame);
}

Fixed version (ground truth):
/** 
 * Inserts a SPEECH_END at the appropriate place.
 */
private void insertSpeechEnd(){
  int index=outputQueue.indexOf(endOffsetFrame);
  endOffsetFrame=null;
  if (index < 0) {
    index=0;
  }
  lastSpeechEndFrame=new Cepstrum(Signal.SPEECH_END);
  outputQueue.add(index,lastSpeechEndFrame);
}
Program: 20027
Project: 20027
Buggy source:
/** 
 * Process the given high energy Cepstrum.
 * @param cepstrum the high energy Cepstrum to process
 */
private void processHighEnergyCepstrum(Cepstrum cepstrum){
  if (location == BELOW_START_LOW) {
    if (inputBuffer.size() > 0) {
      setLastStartLowFrame((Cepstrum)inputBuffer.getFirst());
    }
  }
  if (startHighFrames > startWindow) {
    if (!inSpeech) {
      speechStart();
    }
 else {
      endLowFrames=0;
      endOffsetFrame=null;
    }
  }
 else {
    startHighFrames++;
  }
  location=ABOVE_START_HIGH;
}

Fixed version (ground truth):
/** 
 * Process the given high energy Cepstrum.
 * @param cepstrum the high energy Cepstrum to process
 */
private void processHighEnergyCepstrum(Cepstrum cepstrum){
  if (location == BELOW_START_LOW) {
    if (outputQueue.size() > 0) {
      setLastStartLowFrame((Cepstrum)outputQueue.getFirst());
    }
  }
  if (startHighFrames > startWindow) {
    if (!inSpeech) {
      speechStart();
    }
 else {
      endLowFrames=0;
      endOffsetFrame=null;
    }
  }
 else {
    startHighFrames++;
  }
  location=ABOVE_START_HIGH;
}
Program: 20028
Project: 20028
Buggy source:
/** 
 * Inserts a SPEECH_START at the appropriate place.
 */
private void insertSpeechStart(){
  int index=inputBuffer.indexOf(lastStartLowFrame);
  if (index > -1) {
    int i=0;
    for (ListIterator iterator=inputBuffer.listIterator(index); i < startOffset && iterator.hasNext(); i++) {
      Cepstrum cepstrum=(Cepstrum)iterator.next();
      if (cepstrum.getSignal().equals(Signal.UTTERANCE_START)) {
        break;
      }
    }
    index+=i;
  }
  if (index >= inputBuffer.size()) {
    index=inputBuffer.size();
  }
 else   if (index < 0) {
    index=0;
    System.out.println("String_Node_Str");
    for (ListIterator i=inputBuffer.listIterator(); i.hasNext(); ) {
      Cepstrum cepstrum=(Cepstrum)i.next();
      if (cepstrum.getSignal().equals(Signal.UTTERANCE_START)) {
        index=inputBuffer.indexOf(cepstrum);
      }
    }
  }
  inputBuffer.add(index,(new Cepstrum(Signal.SPEECH_START)));
}

Fixed version (ground truth):
/** 
 * Inserts a SPEECH_START at the appropriate place.
 */
private void insertSpeechStart(){
  int index=outputQueue.indexOf(lastStartLowFrame);
  if (index > -1) {
    int i=0;
    for (ListIterator iterator=outputQueue.listIterator(index); i < startOffset && iterator.hasNext(); i++) {
      Cepstrum cepstrum=(Cepstrum)iterator.next();
      if (cepstrum.getSignal().equals(Signal.UTTERANCE_START)) {
        break;
      }
    }
    index+=i;
  }
  if (index >= outputQueue.size()) {
    index=outputQueue.size();
  }
 else   if (index < 0) {
    index=0;
    System.out.println("String_Node_Str");
    for (ListIterator i=outputQueue.listIterator(); i.hasNext(); ) {
      Cepstrum cepstrum=(Cepstrum)i.next();
      if (cepstrum.getSignal().equals(Signal.UTTERANCE_START)) {
        index=outputQueue.indexOf(cepstrum);
      }
    }
  }
  outputQueue.add(index,(new Cepstrum(Signal.SPEECH_START)));
}
Program: 20029
Project: 20029
Buggy source:
/** 
 * Process the given medium energy Cepstrum.
 * @param cepstrum the medium energy Cepstrum to process
 */
private void processMediumEnergyCepstrum(Cepstrum cepstrum){
  if (location == BELOW_START_LOW) {
    if (lastStartLowFrame != null) {
      if (maxDropout < startLowFrames && inputBuffer.size() > 0) {
        setLastStartLowFrame((Cepstrum)inputBuffer.getFirst());
      }
    }
 else {
      if (numCepstra == 1) {
        setLastStartLowFrame(cepstrum);
      }
 else       if (numCepstra > 1) {
        setLastStartLowFrame((Cepstrum)inputBuffer.getFirst());
      }
    }
  }
  startLowFrames=0;
  endLowFrames=0;
  location=BETWEEN_START_LOW_HIGH;
}

Fixed version (ground truth):
/** 
 * Process the given medium energy Cepstrum.
 * @param cepstrum the medium energy Cepstrum to process
 */
private void processMediumEnergyCepstrum(Cepstrum cepstrum){
  if (location == BELOW_START_LOW) {
    if (lastStartLowFrame != null) {
      if (maxDropout < startLowFrames && outputQueue.size() > 0) {
        setLastStartLowFrame((Cepstrum)outputQueue.getFirst());
      }
    }
 else {
      if (numCepstra == 1) {
        setLastStartLowFrame(cepstrum);
      }
 else       if (numCepstra > 1) {
        setLastStartLowFrame((Cepstrum)outputQueue.getFirst());
      }
    }
  }
  startLowFrames=0;
  endLowFrames=0;
  location=BETWEEN_START_LOW_HIGH;
}
Program: 20030
Project: 20030
Buggy source:
/** 
 * Returns the next Cepstrum, which can be either Cepstrum with data, or Cepstrum with a SPEECH_START or SPEECH_END signal.
 * @return the next Cepstrum, or null if no Cepstrum is available
 * @throws java.io.IOException if there is error reading theCepstrum object
 * @see Cepstrum
 */
public Cepstrum getCepstrum() throws IOException {
  Cepstrum cepstrum=readCepstrum();
  getTimer().start();
  if (cepstrum != null) {
    Signal signal=cepstrum.getSignal();
    if (signal != null && signal.equals(Signal.UTTERANCE_START)) {
      utteranceStart();
      inputBuffer.addFirst(cepstrum);
      while (cepstrum.getEnergy() < startHigh || startHighFrames <= startWindow) {
        cepstrum=readCepstrum();
        if (cepstrum != null) {
          inputBuffer.addFirst(cepstrum);
        }
      }
    }
 else     if (signal != null && signal.equals(Signal.UTTERANCE_END)) {
      if (inSpeech) {
        speechEnd();
      }
      inputBuffer.addFirst(cepstrum);
    }
 else {
      inputBuffer.addFirst(cepstrum);
    }
  }
  cepstrum=(Cepstrum)inputBuffer.removeLast();
  getTimer().stop();
  return cepstrum;
}

Fixed version (ground truth):
/** 
 * Returns the next Cepstrum, which can be either Cepstrum with data, or Cepstrum with a SPEECH_START or SPEECH_END signal.
 * @return the next Cepstrum, or null if no Cepstrum is available
 * @throws java.io.IOException if there is error reading theCepstrum object
 * @see Cepstrum
 */
public Cepstrum getCepstrum() throws IOException {
  Cepstrum cepstrum=readCepstrum();
  getTimer().start();
  if (cepstrum != null) {
    Signal signal=cepstrum.getSignal();
    if (signal != null && signal.equals(Signal.UTTERANCE_START)) {
      utteranceStart();
      outputQueue.addFirst(cepstrum);
      while (cepstrum.getEnergy() < startHigh || startHighFrames <= startWindow) {
        cepstrum=readCepstrum();
        if (cepstrum != null) {
          outputQueue.addFirst(cepstrum);
        }
 else {
          break;
        }
      }
    }
 else     if (signal != null && signal.equals(Signal.UTTERANCE_END)) {
      if (inSpeech) {
        speechEnd();
      }
      outputQueue.addFirst(cepstrum);
    }
 else {
      outputQueue.addFirst(cepstrum);
    }
  }
  if (outputQueue.size() > 0) {
    cepstrum=(Cepstrum)outputQueue.removeLast();
  }
 else {
    cepstrum=null;
  }
  getTimer().stop();
  return cepstrum;
}
Program: 20031
Project: 20031
Buggy source:
/** 
 * Removes the previous SPEECH_END Cepstrum.
 */
private void removeLastSpeechEnd(){
  if (lastSpeechEndFrame != null) {
    inputBuffer.remove(lastSpeechEndFrame);
  }
}

Fixed version (ground truth):
/** 
 * Removes the previous SPEECH_END Cepstrum.
 */
private void removeLastSpeechEnd(){
  if (lastSpeechEndFrame != null) {
    outputQueue.remove(lastSpeechEndFrame);
  }
}
Program: 20032
Project: 20032
Buggy source:
/** 
 * Returns the next Audio object from the current Utterance,  or null if there is none available.
 * @return an Audio object or null
 * @throws java.io.IOException
 */
private Audio readNextFrame() throws IOException {
  byte[] audioFrame=null;
  do {
    audioFrame=currentUtterance.getNext();
  }
 while (audioFrame == null && isRecording());
  if (audioFrame == null) {
    return null;
  }
  Audio audio=null;
  if (keepAudioReference) {
    audio=new Audio(Util.byteToDoubleArray(audioFrame,0,audioFrame.length),currentUtterance);
  }
 else {
    audio=new Audio(Util.byteToDoubleArray(audioFrame,0,audioFrame.length));
  }
  if (getDump()) {
    System.out.println("String_Node_Str" + audio.toString());
  }
  return audio;
}

Fixed version (ground truth):
/** 
 * Returns the next Audio object from the current Utterance,  or null if there is none available.
 * @return an Audio object or null
 * @throws java.io.IOException
 */
private Audio readNextFrame() throws IOException {
  byte[] audioFrame=null;
  do {
    audioFrame=currentUtterance.getNext();
  }
 while (audioFrame == null && getRecording());
  if (audioFrame == null) {
    return null;
  }
  Audio audio=null;
  if (keepAudioReference) {
    audio=new Audio(Util.byteToDoubleArray(audioFrame,0,audioFrame.length),currentUtterance);
  }
 else {
    audio=new Audio(Util.byteToDoubleArray(audioFrame,0,audioFrame.length));
  }
  if (getDump()) {
    System.out.println("String_Node_Str" + audio.toString());
  }
  return audio;
}
Program: 20033
Project: 20033
Buggy source:
/** 
 * Constructs a Microphone with the given InputStream.
 * @param name the name of this Microphone
 * @param context the context of this Microphone
 */
public Microphone(String name,String context) throws LineUnavailableException, IOException {
  super(name,context);
  initSphinxProperties();
  audioFormat=new AudioFormat(sampleRate,sampleSizeInBits,channels,signed,bigEndian);
  utteranceList=new UtteranceList();
  open();
}

Fixed version (ground truth):
/** 
 * Constructs a Microphone with the given InputStream.
 * @param name the name of this Microphone
 * @param context the context of this Microphone
 */
public Microphone(String name,String context) throws IOException {
  super(name,context);
  initSphinxProperties();
  audioFormat=new AudioFormat(sampleRate,sampleSizeInBits,channels,signed,bigEndian);
  utteranceList=new UtteranceList();
}
Program: 20034
Project: 20034
Buggy source:
/** 
 * Reads the parameters needed from the static SphinxProperties object.
 */
private void initSphinxProperties() throws IOException {
  sampleRate=(float)getIntAcousticProperty(FrontEnd.PROP_SAMPLE_RATE,8000);
  SphinxProperties properties=getSphinxProperties();
  frameSizeInBytes=properties.getInt(FrontEnd.PROP_BYTES_PER_AUDIO_FRAME,4096);
  if (frameSizeInBytes % 2 == 1) {
    frameSizeInBytes++;
  }
  keepAudioReference=properties.getBoolean(FrontEnd.PROP_KEEP_AUDIO_REFERENCE,true);
}

Fixed version (ground truth):
/** 
 * Reads the parameters needed from the static SphinxProperties object.
 */
private void initSphinxProperties() throws IOException {
  sampleRate=getIntAcousticProperty(FrontEnd.PROP_SAMPLE_RATE,16000);
  SphinxProperties properties=getSphinxProperties();
  frameSizeInBytes=properties.getInt(FrontEnd.PROP_BYTES_PER_AUDIO_FRAME,4096);
  if (frameSizeInBytes % 2 == 1) {
    frameSizeInBytes++;
  }
  keepAudioReference=properties.getBoolean(FrontEnd.PROP_KEEP_AUDIO_REFERENCE,true);
}
Program: 20035
Project: 20035
Buggy source:
/** 
 * Removes all the utterances in this UtteranceList.
 */
public void clear(){
  utterances.clear();
}

Fixed version (ground truth):
/** 
 * Remove all the Utterances in this UtteranceList.
 */
public void clear(){
  utterances.clear();
}
Program: 20036
Project: 20036
Buggy source:
/** 
 * Implements update() method of LineListener interface. Responds to the START line event by waking up all the threads that are waiting on the Microphone's monitor.
 * @param event the LineEvent to handle
 */
public void update(LineEvent event){
  if (event.getType().equals(LineEvent.Type.START)) {
    setStarted(true);
synchronized (Microphone.this) {
      Microphone.this.notifyAll();
    }
  }
 else   if (event.getType().equals(LineEvent.Type.CLOSE)) {
    printMessage("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Implements update() method of LineListener interface. Responds to the START line event by waking up all the threads that are waiting on the Microphone's monitor.
 * @param event the LineEvent to handle
 */
public void update(LineEvent event){
  if (event.getType().equals(LineEvent.Type.START)) {
    setStarted(true);
synchronized (Microphone.this) {
      Microphone.this.notifyAll();
    }
  }
}
Program: 20037
Project: 20037
Buggy source:
/** 
 * Implements the <code>run()</code> method of Runnable. It waits for instructions to record audio. The method <code>startRecording()</code> will cause it to start recording from the system audio capturing device. Once it starts recording, it will keep recording until it receives instruction to stop recording. The method <code>stopRecording()</code> will cause it to stop recording.
 */
public void run(){
  while (!isClosed()) {
    waitToRecord();
    if (!isClosed()) {
      record();
    }
  }
  printMessage("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Implements the run() method of the Thread class. Records audio, and cache them in the audio buffer.
 */
public void run(){
  if (audioLine != null && audioLine.isOpen()) {
    Utterance currentUtterance=new Utterance("String_Node_Str",getContext());
    utteranceList.add(currentUtterance);
    audioLine.start();
    printMessage("String_Node_Str");
    while (getRecording() && !getClosed()) {
      byte[] data=new byte[frameSizeInBytes];
      int numBytesRead=audioLine.read(data,0,data.length);
      if (numBytesRead == frameSizeInBytes) {
        currentUtterance.add(data);
      }
 else {
        numBytesRead=(numBytesRead % 2 == 0) ? numBytesRead + 2 : numBytesRead + 3;
        byte[] shrinked=new byte[numBytesRead];
        System.arraycopy(data,0,shrinked,0,numBytesRead);
        currentUtterance.add(shrinked);
      }
      printMessage("String_Node_Str" + numBytesRead + "String_Node_Str");
    }
    audioLine.stop();
    audioLine.close();
    printMessage("String_Node_Str");
  }
 else {
    printMessage("String_Node_Str");
  }
}
Program: 20038
Project: 20038
Buggy source:
/** 
 * Starts recording audio
 * @return true if the recording started successfully; false otherwise
 */
public synchronized boolean startRecording(){
  if (audioLine.isOpen()) {
    setRecording(true);
    notifyAll();
    while (!isStarted()) {
      try {
        wait();
      }
 catch (      InterruptedException ie) {
        ie.printStackTrace();
      }
    }
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Starts recording audio. This method will return only when a START event is received, meaning that this Microphone has started capturing audio.
 * @return true if the recording started successfully; false otherwise
 */
public synchronized boolean startRecording(){
  if (open()) {
    setRecording(true);
    RecordingThread recorder=new RecordingThread();
    recorder.start();
    while (!getStarted()) {
      try {
        wait();
      }
 catch (      InterruptedException ie) {
        ie.printStackTrace();
      }
    }
    return true;
  }
 else {
    return false;
  }
}
Program: 20039
Project: 20039
Buggy source:
/** 
 * Set this Microphone to whether it has started capturing audio.
 * @param started true if it has started capturing audio,false otherwise
 */
private synchronized void setStarted(boolean started){
  this.started=started;
}

Fixed version (ground truth):
private synchronized void setStarted(boolean started){
  this.started=started;
}
Program: 20040
Project: 20040
Buggy source:
/** 
 * Release all the system resources used by this Microphone, terminates this Microphone, and effectively terminates this thread of execution. Calling <code>startRecording()</code> will not work after call this method.
 */
public synchronized void terminate(){
  audioLine.close();
  setClosed(true);
  notify();
}

Fixed version (ground truth):
/** 
 * Terminates this Microphone. In this version, it currently does nothing.
 */
public void terminate(){
}
Program: 20041
Project: 20041
Buggy source:
/** 
 * Opens the audio capturing device so that it will be ready for capturing audio.
 * @throws LineUnavailableException if there is an error openingthe audio device
 * @return true if the audio capturing device is opened successfully;false otherwise
 */
private boolean open() throws LineUnavailableException {
  DataLine.Info info=new DataLine.Info(TargetDataLine.class,audioFormat);
  if (!AudioSystem.isLineSupported(info)) {
    logger.severe(audioFormat + "String_Node_Str");
    throw new LineUnavailableException();
  }
  try {
    audioLine=(TargetDataLine)AudioSystem.getLine(info);
    audioLine.addLineListener(lineListener);
    audioLine.open(audioFormat);
    return true;
  }
 catch (  LineUnavailableException ex) {
    audioLine=null;
    ex.printStackTrace();
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Opens the audio capturing device so that it will be ready for capturing audio.
 * @return true if the audio capturing device is opened successfully;false otherwise
 */
private boolean open(){
  DataLine.Info info=new DataLine.Info(TargetDataLine.class,audioFormat);
  if (!AudioSystem.isLineSupported(info)) {
    logger.severe(audioFormat + "String_Node_Str");
    return false;
  }
  try {
    audioLine=(TargetDataLine)AudioSystem.getLine(info);
    audioLine.addLineListener(lineListener);
    audioLine.open(audioFormat);
    return true;
  }
 catch (  LineUnavailableException ex) {
    audioLine=null;
    ex.printStackTrace();
    return false;
  }
}
Program: 20042
Project: 20042
Buggy source:
/** 
 * Stops recording audio.
 */
public void stopRecording(){
  if (audioLine != null) {
    setRecording(false);
    setStarted(false);
  }
}

Fixed version (ground truth):
/** 
 * Stops recording audio.
 */
public synchronized void stopRecording(){
  if (audioLine != null) {
    setRecording(false);
    setStarted(false);
  }
}
Program: 20044
Project: 20044
Buggy source:
/** 
 * Implements update() method of LineListener interface. Responds to the START line event by waking up all the threads that are waiting on the Microphone's monitor.
 * @param event the LineEvent to handle
 */
public void update(LineEvent event){
  if (event.getType().equals(LineEvent.Type.START)) {
    setStarted(true);
synchronized (Microphone.this) {
      Microphone.this.notifyAll();
    }
  }
}

Fixed version (ground truth):
/** 
 * Implements update() method of LineListener interface. Responds to the START line event by waking up all the threads that are waiting on the Microphone's monitor.
 * @param event the LineEvent to handle
 */
public void update(LineEvent event){
  if (event.getType().equals(LineEvent.Type.START)) {
    setStarted(true);
synchronized (Microphone.this) {
      Microphone.this.notifyAll();
    }
  }
 else   if (event.getType().equals(LineEvent.Type.CLOSE)) {
    printMessage("String_Node_Str");
  }
}
Program: 20045
Project: 20045
Buggy source:
/** 
 * Records audio, and cache them in the audio buffer.
 */
private void record(){
  if (audioLine != null && audioLine.isOpen()) {
    Utterance currentUtterance=new Utterance(getContext());
    utteranceList.add(currentUtterance);
    printMessage("String_Node_Str");
    audioLine.start();
    while (getRecording() && !getClosed()) {
      byte[] data=new byte[frameSizeInBytes];
      int numBytesRead=audioLine.read(data,0,data.length);
      if (numBytesRead == frameSizeInBytes) {
        currentUtterance.add(data);
      }
 else {
        numBytesRead=(numBytesRead % 2 == 0) ? numBytesRead + 2 : numBytesRead + 3;
        byte[] shrinked=new byte[numBytesRead];
        System.arraycopy(data,0,shrinked,0,numBytesRead);
        currentUtterance.add(shrinked);
      }
      printMessage("String_Node_Str" + numBytesRead + "String_Node_Str");
    }
    audioLine.stop();
    audioLine.close();
    printMessage("String_Node_Str");
  }
 else {
    printMessage("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Records audio, and cache them in the audio buffer.
 */
private void record(){
  if (audioLine != null && audioLine.isOpen()) {
    Utterance currentUtterance=new Utterance(getContext());
    utteranceList.add(currentUtterance);
    printMessage("String_Node_Str");
    audioLine.start();
    while (getRecording() && !getClosed()) {
      byte[] data=new byte[frameSizeInBytes];
      int numBytesRead=audioLine.read(data,0,data.length);
      if (numBytesRead == frameSizeInBytes) {
        currentUtterance.add(data);
      }
 else {
        numBytesRead=(numBytesRead % 2 == 0) ? numBytesRead + 2 : numBytesRead + 3;
        byte[] shrinked=new byte[numBytesRead];
        System.arraycopy(data,0,shrinked,0,numBytesRead);
        currentUtterance.add(shrinked);
      }
      printMessage("String_Node_Str" + numBytesRead + "String_Node_Str");
    }
    audioLine.drain();
    audioLine.stop();
    audioLine.close();
    printMessage("String_Node_Str");
  }
 else {
    printMessage("String_Node_Str");
  }
}
Program: 20046
Project: 20046
Buggy source:
/** 
 * Constructs a default Spectrum Analyzer with the given  SphinxProperties context.
 * @param name the name of this SpectrumAnalyzer
 * @param context the context of the SphinxProperties to use
 * @param predecessor the AudioSource from which to get Audio objects
 */
public SpectrumAnalyzer(String name,String context,AudioSource predecessor){
  super(name,context);
  initSphinxProperties();
  this.predecessor=predecessor;
  computeLogBase2(this.numberFftPoints);
  createWeightFft(numberFftPoints,false);
  initComplexArrays();
  weightFftTimesFrom2=new Complex();
}

Fixed version (ground truth):
/** 
 * Constructs a default Spectrum Analyzer with the given  SphinxProperties context.
 * @param name the name of this SpectrumAnalyzer
 * @param context the context of the SphinxProperties to use
 * @param predecessor the AudioSource from which to get Audio objects
 */
public SpectrumAnalyzer(String name,String context,AudioSource predecessor){
  super(name,context);
  initSphinxProperties();
  this.predecessor=predecessor;
  computeLogBase2(this.numberFftPoints);
  createWeightFft(numberFftPoints,false);
  initComplexArrays();
  weightFftTimesFrom2=new Complex();
  tempComplex=new Complex();
}
Program: 20047
Project: 20047
Buggy source:
/** 
 * Returns the next Audio from the input stream, or null if there is none available
 * @return a Audio or null
 * @throws java.io.IOException
 */
private Audio readNextFrame() throws IOException {
  int read=0;
  int totalRead=0;
  final int bytesToRead=frameSizeInBytes;
  byte[] samplesBuffer=new byte[frameSizeInBytes];
  do {
    read=audioStream.read(samplesBuffer,totalRead,bytesToRead - totalRead);
    if (read > 0) {
      totalRead+=read;
    }
  }
 while (read != -1 && totalRead < bytesToRead);
  if (totalRead <= 0) {
    streamEndReached=true;
    audioStream.close();
    return null;
  }
  if (totalRead < bytesToRead) {
    totalRead=(totalRead % 2 == 0) ? totalRead + 2 : totalRead + 3;
    streamEndReached=true;
    audioStream.close();
  }
  double[] doubleAudio=Util.byteToDoubleArray(samplesBuffer,0,totalRead);
  Audio audio=null;
  if (keepAudioReference) {
    currentUtterance.add(samplesBuffer);
    audio=new Audio(doubleAudio,currentUtterance);
  }
 else {
    audio=new Audio(doubleAudio);
  }
  if (getDump()) {
    System.out.println("String_Node_Str" + audio.toString());
  }
  return audio;
}

Fixed version (ground truth):
/** 
 * Returns the next Audio from the input stream, or null if there is none available
 * @return a Audio or null
 * @throws java.io.IOException
 */
private Audio readNextFrame() throws IOException {
  int read=0;
  int totalRead=0;
  final int bytesToRead=frameSizeInBytes;
  byte[] samplesBuffer=new byte[frameSizeInBytes];
  do {
    read=audioStream.read(samplesBuffer,totalRead,bytesToRead - totalRead);
    if (read > 0) {
      totalRead+=read;
    }
  }
 while (read != -1 && totalRead < bytesToRead);
  if (totalRead <= 0) {
    streamEndReached=true;
    audioStream.close();
    return null;
  }
  if (totalRead < bytesToRead) {
    totalRead=(totalRead % 2 == 0) ? totalRead + 2 : totalRead + 3;
    byte[] shrinkedBuffer=new byte[totalRead];
    System.arraycopy(samplesBuffer,0,shrinkedBuffer,0,totalRead);
    samplesBuffer=shrinkedBuffer;
    streamEndReached=true;
    audioStream.close();
  }
  double[] doubleAudio=Util.byteToDoubleArray(samplesBuffer,0,totalRead);
  Audio audio=null;
  if (keepAudioReference) {
    currentUtterance.add(samplesBuffer);
    audio=new Audio(doubleAudio,currentUtterance);
  }
 else {
    audio=new Audio(doubleAudio);
  }
  if (getDump()) {
    System.out.println("String_Node_Str" + audio.toString());
  }
  return audio;
}
Program: 20048
Project: 20048
Buggy source:
/** 
 * Constructs a default Utterance object.
 * @param context the context this Utterance is in
 */
public Utterance(String context){
  audioBuffer=new Vector();
  SphinxProperties properties=SphinxProperties.getSphinxProperties(context);
  sampleRate=properties.getInt(FrontEnd.PROP_SAMPLE_RATE,8000);
  float windowSizeInMs=properties.getFloat(FrontEnd.PROP_WINDOW_SIZE_MS,25.625F);
  float windowShiftInMs=properties.getFloat(FrontEnd.PROP_WINDOW_SHIFT_MS,10.0F);
  windowSizeInBytes=Util.getSamplesPerWindow(sampleRate,windowSizeInMs) * 2;
  windowShiftInBytes=Util.getSamplesPerShift(sampleRate,windowShiftInMs) * 2;
}

Fixed version (ground truth):
/** 
 * Constructs a default Utterance object.
 * @param context the context this Utterance is in
 */
public Utterance(String context){
  audioBuffer=new Vector();
  SphinxProperties properties=SphinxProperties.getSphinxProperties(context);
  bitsPerSample=properties.getInt(FrontEnd.PROP_BITS_PER_SAMPLE,16);
  sampleRate=properties.getInt(FrontEnd.PROP_SAMPLE_RATE,8000);
  float windowSizeInMs=properties.getFloat(FrontEnd.PROP_WINDOW_SIZE_MS,25.625F);
  float windowShiftInMs=properties.getFloat(FrontEnd.PROP_WINDOW_SHIFT_MS,10.0F);
  windowSizeInBytes=Util.getSamplesPerWindow(sampleRate,windowSizeInMs) * 2;
  windowShiftInBytes=Util.getSamplesPerShift(sampleRate,windowShiftInMs) * 2;
}
Program: 20049
Project: 20049
Buggy source:
private synchronized boolean isFlattened(){
  return flattened;
}

Fixed version (ground truth):
/** 
 * Returns true if all the audio data is flattened to one flat audio array.
 * @return true if all the audio data is flattened to one array
 */
private synchronized boolean isFlattened(){
  return flattened;
}
Program: 20050
Project: 20050
Buggy source:
/** 
 * Returns the total amount of audio time (in seconds) represented by the first frame to given frame.
 * @param frameNumber the given frame
 * @param properties the SphinxProperties object where informationabout window shift, window size, etc., can be retrieved
 * @return the total audio time in seconds
 */
public static float getAudioTime(int frameNumber,SphinxProperties properties){
  float audioTime=0.0f;
  if (frameNumber >= 1) {
    float windowSizeInMs=properties.getFloat(FrontEnd.PROP_WINDOW_SIZE_MS,25.625F);
    float windowShiftInMs=properties.getFloat(FrontEnd.PROP_WINDOW_SHIFT_MS,10.0F);
    audioTime=(frameNumber - 1) * windowShiftInMs + windowSizeInMs;
    audioTime/=1000;
  }
  return audioTime;
}

Fixed version (ground truth):
/** 
 * Returns the total amount of audio time (in seconds) represented by the first frame to given frame. The first frame number is 0.
 * @param frameNumber the given frame
 * @param properties the SphinxProperties object where informationabout window shift, window size, etc., can be retrieved
 * @return the total audio time in seconds
 */
public static float getAudioTime(int frameNumber,SphinxProperties properties){
  float audioTime=0.0f;
  if (frameNumber >= 0) {
    float windowSizeInMs=properties.getFloat(FrontEnd.PROP_WINDOW_SIZE_MS,25.625F);
    float windowShiftInMs=properties.getFloat(FrontEnd.PROP_WINDOW_SHIFT_MS,10.0F);
    audioTime=frameNumber * windowShiftInMs + windowSizeInMs;
    audioTime/=1000;
  }
  return audioTime;
}
Program: 20051
Project: 20051
Buggy source:
/** 
 * Returns the next Feature object, which is a FeatureFrame produced by this FeatureExtractor. It can also be other Feature type objects, such as EndPointSignal.FRAME_START.
 * @return the next available Feature object, returns null if noFeature object is available
 * @throws java.io.IOException if there is an error readingthe Feature objects
 * @see Feature
 * @see FeatureFrame
 */
public Feature getFeature() throws IOException {
  if (outputQueue.size() == 0) {
    Cepstrum input=(Cepstrum)peekableQueue.peekNext();
    if (input == null) {
      return null;
    }
 else {
      if (segmentEnd) {
        segmentEnd=false;
        outputQueue.add(new Feature(Signal.SEGMENT_END,getNextFeatureID()));
      }
 else       if (input.hasContent()) {
        int numberFeatures=readCepstra(featureBlockSize);
        if (numberFeatures > 0) {
          computeFeatures(numberFeatures);
        }
      }
 else       if (input.getSignal().equals(Signal.SEGMENT_START)) {
        input=(Cepstrum)peekableQueue.removeNext();
        segmentStart=true;
        outputQueue.add(new Feature(input.getSignal(),getNextFeatureID()));
      }
    }
  }
  if (outputQueue.size() > 0) {
    return (Feature)outputQueue.remove(0);
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Returns the next Feature object, which is a FeatureFrame produced by this FeatureExtractor. It can also be other Feature type objects, such as EndPointSignal.FRAME_START.
 * @return the next available Feature object, returns null if noFeature object is available
 * @throws java.io.IOException if there is an error readingthe Feature objects
 * @see Feature
 * @see FeatureFrame
 */
public Feature getFeature() throws IOException {
  if (outputQueue.size() == 0) {
    if (segmentEnd) {
      segmentEnd=false;
      outputQueue.add(new Feature(Signal.SEGMENT_END,getNextFeatureID()));
    }
 else {
      Cepstrum input=(Cepstrum)peekableQueue.peekNext();
      if (input == null) {
        return null;
      }
 else {
        if (input.hasContent()) {
          int numberFeatures=readCepstra(featureBlockSize);
          if (numberFeatures > 0) {
            computeFeatures(numberFeatures);
          }
        }
 else         if (input.getSignal().equals(Signal.SEGMENT_START)) {
          input=(Cepstrum)peekableQueue.removeNext();
          segmentStart=true;
          outputQueue.add(new Feature(input.getSignal(),getNextFeatureID()));
        }
      }
    }
  }
  if (outputQueue.size() > 0) {
    return (Feature)outputQueue.remove(0);
  }
 else {
    return null;
  }
}
Program: 20052
Project: 20052
Buggy source:
/** 
 * Returns a string representation of this AudioFrame.
 * @return a string representation of this AudioFrame
 */
public String toString(){
  return Util.doubleArrayToString(audioSamples);
}

Fixed version (ground truth):
/** 
 * Returns a string representation of this AudioFrame. The format of the string is: <pre>audioFrameLength data0 data1 ...</pre>
 * @return a string representation of this AudioFrame
 */
public String toString(){
  return Util.doubleArrayToString(audioSamples);
}
Program: 20053
Project: 20053
Buggy source:
/** 
 * Returns the given Cepstrum, normalized.
 * @param input a Cepstrum
 * @return a normalized Cepstrum
 */
private Data process(Cepstrum cepstrumObject){
  getTimer().start();
  float[] cepstrum=cepstrumObject.getCepstrumData();
  for (int j=0; j < cepstrum.length; j++) {
    sum[j]+=cepstrum[j];
    cepstrum[j]-=currentMean[j];
  }
  numberFrame++;
  getTimer().stop();
  return cepstrumObject;
}

Fixed version (ground truth):
/** 
 * Returns the given Cepstrum, normalized.
 * @param input a Cepstrum
 * @return a normalized Cepstrum
 */
private Data process(Cepstrum cepstrumObject){
  getTimer().start();
  float[] cepstrum=cepstrumObject.getCepstrumData();
  for (int j=0; j < cepstrum.length; j++) {
    sum[j]+=cepstrum[j];
    cepstrum[j]-=currentMean[j];
  }
  numberFrame++;
  getTimer().stop();
  if (getDump()) {
    System.out.println("String_Node_Str" + cepstrumObject.toString());
  }
  return cepstrumObject;
}
Program: 20054
Project: 20054
Buggy source:
/** 
 * Returns the next Data object, which is a normalized Cepstrum produced by this class. However, it can also be other Data objects like a EndPointSignal.SEGMENT_START.
 * @return the next available Data object, returns null if noData object is available
 */
public Data read() throws IOException {
  Data input=getSource().read();
  if (input instanceof Cepstrum) {
    return process((Cepstrum)input);
  }
 else   if (input instanceof EndPointSignal) {
    EndPointSignal signal=(EndPointSignal)input;
    if (signal.equals(EndPointSignal.FRAME_END)) {
      if (numberFrame > cmnShiftWindow) {
        updateMeanSumBuffers();
      }
    }
 else     if (signal.equals(EndPointSignal.SEGMENT_END)) {
      updateMeanSumBuffers();
    }
    return input;
  }
 else {
    return input;
  }
}

Fixed version (ground truth):
/** 
 * Returns the next Data object, which is a normalized Cepstrum produced by this class. However, it can also be other Data objects like a EndPointSignal.SEGMENT_START.
 * @return the next available Data object, returns null if noData object is available
 * @throws java.io.IOException if there is an error readingthe Data objects
 */
public Data read() throws IOException {
  Data input=getSource().read();
  if (input instanceof Cepstrum) {
    return process((Cepstrum)input);
  }
 else   if (input instanceof EndPointSignal) {
    EndPointSignal signal=(EndPointSignal)input;
    if (signal.equals(EndPointSignal.FRAME_END)) {
      if (numberFrame > cmnShiftWindow) {
        updateMeanSumBuffers();
      }
    }
 else     if (signal.equals(EndPointSignal.SEGMENT_END)) {
      updateMeanSumBuffers();
    }
    return input;
  }
 else {
    return input;
  }
}
Program: 20055
Project: 20055
Buggy source:
/** 
 * Returns a string representation of this Cepstrum.
 * @return a string representation of this Cepstrum
 */
public String toString(){
  return ("String_Node_Str" + Util.floatArrayToString(cepstrumData));
}

Fixed version (ground truth):
/** 
 * Returns a string representation of this Cepstrum. The format of the string is: <pre>cepstrumLength data0 data1 ...</pre>
 * @return a string representation of this Cepstrum
 */
public String toString(){
  return (Util.floatArrayToString(cepstrumData));
}
Program: 20056
Project: 20056
Buggy source:
/** 
 * Returns the name of this DataProcessor.
 * @return the name of this DataProcessor
 */
public String getName(){
  return name;
}

Fixed version (ground truth):
/** 
 * Returns the name of this DataProcessor.
 * @return the name of this DataProcessor
 */
public final String getName(){
  return name;
}
Program: 20057
Project: 20057
Buggy source:
/** 
 * Returns the SphinxProperties used by this DataProcessor.
 * @return the SphinxProperties
 */
public SphinxProperties getSphinxProperties(){
  return sphinxProperties;
}

Fixed version (ground truth):
/** 
 * Returns the SphinxProperties used by this DataProcessor.
 * @return the SphinxProperties
 */
public final SphinxProperties getSphinxProperties(){
  return sphinxProperties;
}
Program: 20058
Project: 20058
Buggy source:
/** 
 * Returns the context of this DataProcessor.
 * @return the context of this DataProcessor
 */
public String getContext(){
  return context;
}

Fixed version (ground truth):
/** 
 * Returns the context of this DataProcessor.
 * @return the context of this DataProcessor
 */
public final String getContext(){
  return context;
}
Program: 20059
Project: 20059
Buggy source:
/** 
 * Returns a String representation of this Feature.
 * @return the String representation
 */
public String toString(){
  return "String_Node_Str" + Util.floatArrayToString(featureData);
}

Fixed version (ground truth):
/** 
 * Returns a String representation of this Feature. The format of the string is: <pre>featureLength data0 data1 ...</pre>
 * @return the String representation
 */
public String toString(){
  return Util.floatArrayToString(featureData);
}
Program: 20060
Project: 20060
Buggy source:
/** 
 * Computes the next feature. Advances the pointers as well.
 */
private Feature computeNextFeature(){
  float[] feature=new float[featureLength];
  float[] mfc3f=cepstraBuffer[jf3++];
  float[] mfc2f=cepstraBuffer[jf2++];
  float[] mfc1f=cepstraBuffer[jf1++];
  float[] current=cepstraBuffer[currentPosition++];
  float[] mfc1p=cepstraBuffer[jp1++];
  float[] mfc2p=cepstraBuffer[jp2++];
  float[] mfc3p=cepstraBuffer[jp3++];
  int j=cepstrumLength - 1;
  System.arraycopy(current,1,feature,0,j);
  for (int k=1; k < mfc2f.length; k++) {
    feature[j++]=(mfc2f[k] - mfc2p[k]);
  }
  feature[j++]=current[0];
  feature[j++]=mfc2f[0] - mfc2p[0];
  for (int k=0; k < mfc3f.length; k++) {
    feature[j++]=(mfc3f[k] - mfc1p[k]) - (mfc1f[k] - mfc3p[k]);
  }
  if (jp3 > BUFFER_EDGE) {
    jf3%=LIVEBUFBLOCKSIZE;
    jf2%=LIVEBUFBLOCKSIZE;
    jf1%=LIVEBUFBLOCKSIZE;
    currentPosition%=LIVEBUFBLOCKSIZE;
    jp1%=LIVEBUFBLOCKSIZE;
    jp2%=LIVEBUFBLOCKSIZE;
    jp3%=LIVEBUFBLOCKSIZE;
  }
  return (new Feature(feature));
}

Fixed version (ground truth):
/** 
 * Computes the next feature. Advances the pointers as well.
 */
private Feature computeNextFeature(){
  float[] feature=new float[featureLength];
  float[] mfc3f=cepstraBuffer[jf3++];
  float[] mfc2f=cepstraBuffer[jf2++];
  float[] mfc1f=cepstraBuffer[jf1++];
  float[] current=cepstraBuffer[currentPosition++];
  float[] mfc1p=cepstraBuffer[jp1++];
  float[] mfc2p=cepstraBuffer[jp2++];
  float[] mfc3p=cepstraBuffer[jp3++];
  int j=cepstrumLength - 1;
  System.arraycopy(current,1,feature,0,j);
  for (int k=1; k < mfc2f.length; k++) {
    feature[j++]=(mfc2f[k] - mfc2p[k]);
  }
  feature[j++]=current[0];
  feature[j++]=mfc2f[0] - mfc2p[0];
  for (int k=0; k < mfc3f.length; k++) {
    feature[j++]=(mfc3f[k] - mfc1p[k]) - (mfc1f[k] - mfc3p[k]);
  }
  if (jp3 > cepstraBufferEdge) {
    jf3%=cepstraBufferSize;
    jf2%=cepstraBufferSize;
    jf1%=cepstraBufferSize;
    currentPosition%=cepstraBufferSize;
    jp1%=cepstraBufferSize;
    jp2%=cepstraBufferSize;
    jp3%=cepstraBufferSize;
  }
  return (new Feature(feature));
}
Program: 20061
Project: 20061
Buggy source:
/** 
 * Replicate the last frame into the last window number of frames in the cepstraBuffer.
 */
private void replicateLastFrame(){
  if (bufferPosition >= 0) {
    float[] last=this.cepstraBuffer[bufferPosition - 1];
    if (bufferPosition + window < LIVEBUFBLOCKSIZE) {
      Arrays.fill(cepstraBuffer,bufferPosition,bufferPosition + window,last);
    }
 else {
      for (int i=0; i < window; i++) {
        this.cepstraBuffer[bufferPosition++]=last;
        bufferPosition%=LIVEBUFBLOCKSIZE;
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Replicate the last frame into the last window number of frames in the cepstraBuffer.
 */
private void replicateLastFrame(){
  if (bufferPosition >= 0) {
    float[] last=this.cepstraBuffer[bufferPosition - 1];
    if (bufferPosition + window < cepstraBufferSize) {
      Arrays.fill(cepstraBuffer,bufferPosition,bufferPosition + window,last);
    }
 else {
      for (int i=0; i < window; i++) {
        this.cepstraBuffer[bufferPosition++]=last;
        bufferPosition%=cepstraBufferSize;
      }
    }
  }
}
Program: 20062
Project: 20062
Buggy source:
/** 
 * Converts the Cepstrum data in the cepstraBuffer into a FeatureFrame.
 * @param the number of Features that will be produced
 * @return a FeatureFrame
 */
private FeatureFrame process(int totalFeatures){
  getTimer().start();
  assert(0 < totalFeatures && totalFeatures < LIVEBUFBLOCKSIZE);
  Feature[] features=new Feature[totalFeatures];
  for (int i=0; i < totalFeatures; i++) {
    features[i]=computeNextFeature();
  }
  FeatureFrame featureFrame=new FeatureFrame(features);
  getTimer().stop();
  if (getDump()) {
    System.out.println(featureFrame.toString());
  }
  return featureFrame;
}

Fixed version (ground truth):
/** 
 * Converts the Cepstrum data in the cepstraBuffer into a FeatureFrame.
 * @param the number of Features that will be produced
 * @return a FeatureFrame
 */
private FeatureFrame process(int totalFeatures){
  getTimer().start();
  assert(0 < totalFeatures && totalFeatures < cepstraBufferSize);
  Feature[] features=new Feature[totalFeatures];
  for (int i=0; i < totalFeatures; i++) {
    features[i]=computeNextFeature();
  }
  FeatureFrame featureFrame=new FeatureFrame(features);
  getTimer().stop();
  if (getDump()) {
    System.out.println(featureFrame.toString());
  }
  return featureFrame;
}