excBuf[extIdx+i] = pitch_gain*excBuf[extIdx+i-last_pitch] + fact*((float)Math.sqrt(1-pitch_gain))*3*innov_gain*((random.nextFloat())-0.5f);
excBuf[extIdx+i] = pitch_gain * (excBuf[extIdx + i - last_pitch] + VERY_SMALL) + fact * ((float)Math.sqrt(1 - pitch_gain)) * 3 * innov_gain * ((random.nextFloat()) - 0.5f);
  public int decodeLost(final float[] out)  {    int i;    float pitch_gain, fact, gain_med;    fact = (float) Math.exp(-.04*count_lost*count_lost);    // median3(a, b, c) = (a<b ? (b<c ? b : (a<c ? c : a))    //                         : (c<b ? b : (c<a ? c : a)))    gain_med = (pitch_gain_buf[0] < pitch_gain_buf[1] ? (pitch_gain_buf[1] < pitch_gain_buf[2] ? pitch_gain_buf[1] : (pitch_gain_buf[0] < pitch_gain_buf[2] ? pitch_gain_buf[2] : pitch_gain_buf[0]))                                                      : (pitch_gain_buf[2] < pitch_gain_buf[1] ? pitch_gain_buf[1] : (pitch_gain_buf[2] < pitch_gain_buf[0] ? pitch_gain_buf[2] : pitch_gain_buf[0])));    if (gain_med < last_pitch_gain)      last_pitch_gain = gain_med;    pitch_gain = last_pitch_gain;    if (pitch_gain>.95f)      pitch_gain=.95f;    pitch_gain *= fact;       /* Shift all buffers by one frame */    System.arraycopy(frmBuf, frameSize, frmBuf, 0, bufSize-frameSize);    System.arraycopy(excBuf, frameSize, excBuf, 0, bufSize-frameSize);    for (int sub=0; sub<nbSubframes; sub++)    {      int offset;      int spIdx, extIdx;      /* Offset relative to start of frame */      offset = subframeSize*sub;      /* Original signal */      spIdx  = frmIdx+offset;      /* Excitation */      extIdx = excIdx+offset;      /* Excitation after post-filter*/      /* Calculate perceptually enhanced LPC filter */      if (enhanced) {        float r=.9f;           float k1,k2,k3;        if (submodes[submodeID] != null) {          k1=submodes[submodeID].lpc_enh_k1;          k2=submodes[submodeID].lpc_enh_k2;        }        else {          k1 = k2 = 0.7f;        }        k3=(1-(1-r*k1)/(1-r*k2))/r;        Filters.bw_lpc(k1, interp_qlpc, awk1, lpcSize);        Filters.bw_lpc(k2, interp_qlpc, awk2, lpcSize);        Filters.bw_lpc(k3, interp_qlpc, awk3, lpcSize);      }      /* Make up a plausible excitation */      /* THIS CAN BE IMPROVED */      /*if (pitch_gain>.95)        pitch_gain=.95;*/      {        float innov_gain=0;        for (i=0; i<frameSize; i++)          innov_gain += innov[i]*innov[i];        innov_gain = (float) Math.sqrt(innov_gain/frameSize);        for (i=0; i<subframeSize; i++)        {//#if 0//          excBuf[extIdx+i] = pitch_gain*excBuf[extIdx+i-last_pitch] + fact*((float)Math.sqrt(1-pitch_gain))*innov[i+offset];//          /*Just so it give the same lost packets as with if 0*///          /*rand();*///#else          /*excBuf[extIdx+i] = pitch_gain*excBuf[extIdx+i-last_pitch] + fact*innov[i+offset];*/          excBuf[extIdx+i] = pitch_gain*excBuf[extIdx+i-last_pitch] + fact*((float)Math.sqrt(1-pitch_gain))*3*innov_gain*((random.nextFloat())-0.5f);//#endif        }      }      for (i=0;i<subframeSize;i++)        frmBuf[spIdx+i]=excBuf[extIdx+i];      /* Signal synthesis */      if (enhanced) {        /* Use enhanced LPC filter */        Filters.filter_mem2(frmBuf, spIdx, awk2, awk1, subframeSize, lpcSize, mem_sp, lpcSize);        Filters.filter_mem2(frmBuf, spIdx, awk3, interp_qlpc, subframeSize, lpcSize, mem_sp, 0);      }      else {        /* Use regular filter */        for (i=0;i<lpcSize;i++)          mem_sp[lpcSize+i] = 0;        Filters.iir_mem2(frmBuf, spIdx, interp_qlpc, frmBuf, spIdx, subframeSize, lpcSize, mem_sp);      }    }    out[0] = frmBuf[0] + preemph*pre_mem;    for (i=1;i<frameSize;i++)      out[i] = frmBuf[i] + preemph*out[i-1];    pre_mem=out[frameSize-1];    first = 0;    count_lost++;    pitch_gain_buf[pitch_gain_buf_idx++] = pitch_gain;    if (pitch_gain_buf_idx > 2) /* rollover */      pitch_gain_buf_idx = 0;    return 0;  }