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); } }
Began life as a copy of #1009775
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1009776 | 
| Snippet name: | MonoSamplesForwarder - 16 bit PCM stream to mono float samples (-1 to 1) | 
| Eternal ID of this version: | #1009776/7 | 
| Text MD5: | 73310466169d6e55cf72857cdeb7e250 | 
| Author: | stefan | 
| Category: | javax / audio | 
| Type: | JavaX fragment (include) | 
| Public (visible to everyone): | Yes | 
| Archived (hidden from active list): | No | 
| Created/modified: | 2017-08-16 17:55:01 | 
| Source code size: | 662 bytes / 25 lines | 
| Pitched / IR pitched: | No / No | 
| Views / Downloads: | 698 / 1316 | 
| Version history: | 6 change(s) | 
| Referenced in: | #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) |