float e_left=0, e_right=0, e_tot=0; float balance, e_ratio; for (i=0;i<frameSize;i++) { e_left  += data[2*i]*data[2*i]; e_right += data[2*i+1]*data[2*i+1]; data[i] =  .5f*(data[2*i]+data[2*i+1]); e_tot   += data[i]*data[i];
float e_left = 0; float e_right=0; float e_tot=0; float balance; float e_ratio; for (i = 0; i < frameSize; i++) { e_left  += data[2 * i]     * data[2 * i]; e_right += data[2 * i + 1] * data[2 * i + 1]; data[i] =  .5f * (data[2 * i] + data[2 * i + 1]); e_tot   += data[i] * data[i];
  public static void encode(final Bits bits,                            final float[] data,                            final int frameSize)  {    int i, tmp;    float e_left=0, e_right=0, e_tot=0;    float balance, e_ratio;    for (i=0;i<frameSize;i++) {      e_left  += data[2*i]*data[2*i];      e_right += data[2*i+1]*data[2*i+1];      data[i] =  .5f*(data[2*i]+data[2*i+1]);      e_tot   += data[i]*data[i];    }    balance=(e_left+1)/(e_right+1);    e_ratio = e_tot/(1+e_left+e_right);    /*Quantization*/    bits.pack(14, 5);    bits.pack(SPEEX_INBAND_STEREO, 4);    balance=(float)(4*Math.log(balance));    /*Pack balance*/    if (balance>0)      bits.pack(0, 1);    else      bits.pack(1, 1);    balance=(float) Math.floor(.5f+Math.abs(balance));    if (balance>30)      balance=31;    bits.pack((int)balance, 5);        /*Quantize energy ratio*/    tmp=VQ.index(e_ratio, e_ratio_quant, 4);    bits.pack(tmp, 2);  }