d3e3e92f9b
- Implemented `BroadcasterProcessor` for audio processing in a separate audio thread. - Replaced deprecated `ScriptProcessorNode` with `AudioWorkletNode` in `startBroadcast`. - Enhanced audio performance by reducing main thread interference and improving scalability. - Added `broadcaster-processor.js` to handle custom audio processing logic. This change ensures compatibility with modern browsers and improves broadcast audio quality.
20 lines
577 B
JavaScript
20 lines
577 B
JavaScript
class BroadcasterProcessor extends AudioWorkletProcessor {
|
|
process(inputs, outputs) {
|
|
const input = inputs[0];
|
|
const output = outputs[0];
|
|
|
|
if (input && output) {
|
|
for (let channel = 0; channel < input.length; ++channel) {
|
|
const inputChannel = input[channel];
|
|
const outputChannel = output[channel];
|
|
for (let i = 0; i < inputChannel.length; ++i) {
|
|
outputChannel[i] = inputChannel[i];
|
|
}
|
|
}
|
|
}
|
|
return true; // Keep the processor alive
|
|
}
|
|
}
|
|
|
|
registerProcessor('broadcaster-processor', BroadcasterProcessor);
|