Web and C# realtime audio via ws

13 Views Asked by At
function startCall(){
      const stream = await navigator.mediaDevices.getUserMedia({audio: true})
      const mediaStreamSource = this.audioContext.createMediaStreamSource(stream)

      const scriptProcessor = this.audioContext.createScriptProcessor(4096, 1)

      mediaStreamSource.connect(scriptProcessor)
      scriptProcessor.connect(this.audioContext.destination)

      scriptProcessor.onaudioprocess = (event) => {
        const inputBuffer = event.inputBuffer;
        const audioData = inputBuffer.getChannelData(0)
        const data = new Uint16Array(audioData.buffer)

        // Send data via ws
      }
}

How can C# parse and play the audio after receiving the data? I have tried many methods, but they all produce noise and no actual sound.

Expecting C# can play the incoming audio normally

0

There are 0 best solutions below