twilio/twilio-video-app-react

Using WebAudio - AudioWorkletProcessors to process Audio Data

arvind-iyer-2001 opened this issue · 0 comments

Question
I'm tryin to use WebAudioAPIs to add my custom audio processor, (for now it just outputs the input value, I'll need it later to perform some Audio Analysis, not needed to modify the output).
I have been trying to use the below code to process the audioTrack data but have not been able to see any results of its working.
How can I make this work.

AddAudioProcessor Callback
image

const addAudioProcessor = useCallback(async () => { if (audioTrack) { const mediaStream = new MediaStream(); mediaStream.addTrack(audioTrack.mediaStreamTrack); const audioContext = new AudioContext(); audioContext.createMediaStreamSource(mediaStream); await audioContext.audioWorklet.addModule("Test-Processor.js"); const testNode= new AudioWorkletNode( audioContext, 'test-processor' ); testNode.connect(audioContext.destination); } }, [audioTrack])

Test-Processor.js
image

I have been refering to the WebAudio Documentation to implement this.
https://developer.mozilla.org/en-US/docs/Web/API/AudioWorkletProcessor