/**
* 将 32 位的数据转为 16 位
* @param {ByteArray} chunk
*/
static bit32to16(chunk) {
const b16 = new Int16Array(chunk.byteLength / 4);
const dv = new DataView(chunk.buffer);
for (let i = 0, offset = 0; offset < chunk.byteLength; i++, offset += 4){
const v = dv.getFloat32(offset, true);
b16[i] = v > 0 ? v * 32767 : v * 32768;
}
return b16.buffer
}
相关分类