I'm sending audio data through audio worklet node and getting response audio as arraybuffer through same socket on socket message event how to play in my device.
info
I'm setting arraybuffer to audiocontext:
from socket audioData is coming as arraybuffer and i created decodeAudioData function to play the arraybuffer to user connected earphone.
function decodeAudioData(audioData) {
if (!audioContext) return;
audioContext.current.decodeAudioData(audioData, function (decodedData) {
const channelData = decodedData.getChannelData(0);
audioBuffer.copyToChannel(channelData, 0);
});
}
error:
Failed to execute 'decodeAudioData' on 'BaseAudioContext': parameter 1 is not of type