Aligns raw PCM16 LE bytes so each WebSocket frame is a whole number of samples.
Modulate answers odd-length s16le frames with {"type":"error","error":"Invalid input audio"}
and closes the socket. Upstream chunks are not guaranteed even (base64 ingest, RTMP flush,
buffer views), so a trailing odd byte is carried into the next frame.
Parameters
pendingOddByte: Buffer
Zero or one leftover byte from the previous chunk.
pcm: Buffer
Next PCM chunk (may be empty or odd-length).
Returns {frame:Buffer;pendingOddByte:Buffer}
Even-length frame to send (may be empty) and the new pending odd byte.
Aligns raw PCM16 LE bytes so each WebSocket frame is a whole number of samples.
Modulate answers odd-length
s16leframes with{"type":"error","error":"Invalid input audio"}and closes the socket. Upstream chunks are not guaranteed even (base64 ingest, RTMP flush, buffer views), so a trailing odd byte is carried into the next frame.