@vidtreo/recorder 0.0.1 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +629 -142
- package/dist/audio-capture-processor.worklet.js +37 -0
- package/dist/index.d.ts +632 -760
- package/dist/index.js +595 -189
- package/dist/vidtreo-recorder.d.ts +55 -0
- package/package.json +15 -16
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
class AudioCaptureProcessor extends AudioWorkletProcessor {
|
|
2
|
+
process(inputs) {
|
|
3
|
+
const input = inputs[0];
|
|
4
|
+
if (!input?.length) {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const bufferLength = input[0].length;
|
|
9
|
+
const numberOfChannels = input.length;
|
|
10
|
+
const combinedBuffer = new Float32Array(bufferLength * numberOfChannels);
|
|
11
|
+
|
|
12
|
+
for (let channel = 0; channel < numberOfChannels; channel++) {
|
|
13
|
+
combinedBuffer.set(input[channel], channel * bufferLength);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const arrayBuffer = combinedBuffer.buffer.slice(
|
|
17
|
+
0,
|
|
18
|
+
combinedBuffer.length * Float32Array.BYTES_PER_ELEMENT
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
this.port.postMessage(
|
|
22
|
+
{
|
|
23
|
+
type: "audioData",
|
|
24
|
+
data: arrayBuffer,
|
|
25
|
+
sampleRate,
|
|
26
|
+
numberOfChannels,
|
|
27
|
+
duration: bufferLength / sampleRate,
|
|
28
|
+
bufferLength: combinedBuffer.length,
|
|
29
|
+
},
|
|
30
|
+
[arrayBuffer]
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
registerProcessor("audio-capture-processor", AudioCaptureProcessor);
|