sclass MonoSamplesForwarder extends AbstractOutputStream { int halfSample = -1; O f; // voidfunc(float[]) static bool debug; *() {} *(O *f) {} public void write(byte[] b, int ofs, int len) { int n = (len+(halfSample >= 0 ? 1 : 0))/2; float[] out = new float[n]; int iOut = 0; if (debug) print(bytesToHex(subArray(b, ofs, ofs+min(8, len)))); for (int i = ofs; i < ofs+len; i++) { if (halfSample < 0) halfSample = ((int) b[i]) & 0x255; else { out[iOut++] = (halfSample | (((int) b[i]) << 8))/32768f; halfSample = -1; } } if (n != 0) callF(f, out); } }