You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It should be possible to use the underlying array buffer and cast it to an UInt8Array.
Something as simple as
var a = new UInt8Array(YourInt16Array);
should already do the trick.
However, speaking of the WebAudio API (where the data is often available as Float32Array), it might make sense to use a different intermediate representation. Personally I have made success converting the data into something like a Float16Array by using the inofficial half point floating point format where the converted bytes can be stored directly as a UInt8Array. Conversion from floating point to floating point format will better preserve the quality and suits better for audio (where the ear operates in a similar non-linear fashion as the exponential floating point format).
varudata=newUint8Array(data);// data is the pcm audio datavargzip=newZlib.Gzip(udata);varudatac=gzip.compress();data=udatac.buffer;xhr.send(data);
For the code above, I got http://wx4.sinaimg.cn/large/715d71fdgy1fhyi6x3kpkj206x062mxl.jpg this result.The compressed Uint8Array's byteLength and the buffer's byteLength not the same. Should I slice it myself? Or I done something wrong? I think if the origin data were not enough? I'll try it tomorrow.
I want to compress the pcm data produce by WebAudio API, it is Int16Array.
Can I use zlib.js?
The text was updated successfully, but these errors were encountered: