ashishbajaj99 / mic

A simple stream wrapper for arecord (Linux (including Raspbian)) and sox (Mac, Windows). Returns a Passthrough stream object so that stream control like pause(), resume(), pipe(), etc. are all available.
MIT License
103 stars 61 forks source link

Stream .on('data') always passes Uint8Array to callback #43

Open jmarcosfer opened 2 years ago

jmarcosfer commented 2 years ago

Regardless of the specified encoding passed in the settings when creating the mic instance, the on 'data' listener always passes an Uint8Array to the callback.

I would expect this data to be, for example, of type Int16Array if I specify a 'signed-integer' encoding.

Looking at the source code, here the encoding argument of the transform stream's _transform method seems to be unused. I'm not sure if that's where the change would have to be made to get the right TypedArray according to the specified encoding.

If anyone here can point me in the right direction (right place in source code), I don't mind working out a potential solution and opening a PR.

Thanks!