forked from node-webrtc/node-webrtc
-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Labels
enhancementNew feature or requestNew feature or requestwontfixThis will not be worked onThis will not be worked on
Description
I'm trying to have my nodejs backend act as a peer that streams pcm audio to the browser. (let's assume it's the only way to achieve what I need)
I'm creating an RTCAudioSource, and adding to it an array of chunked buffers - PCM 24k sample rate signed 16-bit little-endian.
RTCAudioSource/onData only accepts an Int16Array in samples, so I tried converting the buffers:
import { nonstandard } from '@roamhq/wrtc';
const source = new nonstandard.RTCAudioSource();
const samples = new Int16Array(
buffer.buffer,
buffer.byteOffset,
buffer.byteLength / Int16Array.BYTES_PER_ELEMENT,
);
// adding a single chunk. in practice I'm adding many more chunks
// throws "Expected a .byteLength of 480, not x"
source.onData({
samples,
sampleRate: 24000,
bitsPerSample: 16,
channelCount: 1,
});source.onData() throws the following error, with x being anywhere from 17 to 2770 depending on the chunk size:
Expected a .byteLength of 480, not x
It's worth noting that the PCM buffers play fine when writing them to a wav file or when emitting and playing them in the browser via web sockets.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestwontfixThis will not be worked onThis will not be worked on