Guest User

Untitled

a guest
Apr 20th, 2013
198
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.     // we assume that each entry in data[] is an int in [0,127]
  3.     public byte[] getByteArrayRepresentation() {
  4.         byte[] result = new byte[data.length/2];
  5.         for (int i = 0; i < result.length; i++) {
  6.             tmp = ((int) (data[(i << 1)] * 2)) << 4;
  7.             tmp = (tmp | ((int) (data[(i << 1) + 1] * 2)));
  8.             result[i] = (byte) (tmp-128);
  9.         }
  10.         return result;
  11.     }    
  12.  
  13.     public void setByteArrayRepresentation(byte[] in) {
  14.         for (int i = 0; i < in.length; i++) {
  15.             tmp = in[i]+128;
  16.             data[(i << 1) +1] = ((double) (tmp & 0x000F))/2d;
  17.             data[i << 1] = ((double) (tmp >> 4))/2d;
  18.         }
  19.     }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×