private static Boolean isZeroCross(byte[] buf,int len,int format,ByteOrder order){
  if (format == AL.AL_FORMAT_MONO8) {
    if (len < 3) {
      return false;
    }
 else {
      return (((0xFF & buf[len - 3]) < 128) && ((0xFF & buf[len - 2]) < 128) && ((0xFF & buf[len - 1]) >= 128));
    }
  }
 else   if (format == AL.AL_FORMAT_MONO16) {
    if (len < 6) {
      return false;
    }
    short[] sbuf=new short[len / 2];
    ByteBuffer bb=ByteBuffer.wrap(buf);
    bb.order(order);
    sbuf[0]=bb.getShort();
    sbuf[1]=bb.getShort();
    sbuf[2]=bb.getShort();
    return ((sbuf[0] < 0) && (sbuf[1] < 0) && (sbuf[2] >= 0));
  }
 else {
    return false;
  }
}

private static Boolean isZeroCross ( byte [ ] buf , int len , int format , ByteOrder order ) { if ( format == AL . AL_FORMAT_MONO8 ) { if ( len < 3 ) { return false ; } else { return ( ( ( 0xFF & buf [ len - 3 ] ) < 128 ) && ( ( 0xFF & buf [ len - 2 ] ) < 128 ) && ( ( 0xFF & buf [ len - 1 ] ) >= 128 ) ) ; } } else if ( format == AL . AL_FORMAT_MONO16 ) { if ( len < 6 ) { return false ; } short [ ] sbuf = new short [ len / 2 ] ; ByteBuffer bb = ByteBuffer . wrap ( buf ) ; bb . order ( order ) ; sbuf [ 0 ] = bb . getShort ( ) ; sbuf [ 1 ] = bb . getShort ( ) ; sbuf [ 2 ] = bb . getShort ( ) ; return ( ( sbuf [ 0 ] < 0 ) && ( sbuf [ 1 ] < 0 ) && ( sbuf [ 2 ] >= 0 ) ) ; } else { return false ; } }
looks at the ( last ) three samples in buf ( with sample size defined by and determines whether they represent a positive - going zerocrossing event . works only for al . al_format_mono8 or al . al_format_mono16 . returns false otherwise .
