Audio artifacts (commpression noise)

Hi there,
Sometimes I am experiencing “noise” in the audio coming from mediasoup (sounds like random compressed noise). I am starting the consumer paused server-side, and then unpausing it client-side once the client’s consumer is ready. I am creating an audio element in the client, and attaching the source .

Wondering if the issue is how I setup the producer codec:

this.micProducer = await this.producerTransport.produce({
        stopTracks: false,
        track: track,
        codecOptions: {
          opusStereo: 1,
          opusDtx: 1,
        },

or how I setup the receiving audio:

const stream = new MediaStream();
stream.addTrack(consumer.track);
...
..
let elem = document.createElement('audio');
elem.srcObject = stream;
elem.id = elemID;
elem.autoplay = true;

has anybody experienced this kind of random noise? and if so, how did you solve it?

mediasoup and mediasoup-client don’t deal with encoded audio so such a noise comes from the audio source.

thanks @ibc… Understood, but the source is clean. I know that for a fact. May be the noise/compression sound I am hearing is due to the channel (i.e. packet loss, etc, or browser issue)

is codecOptions: { opusStereo: 1, opusDtx: 1 } good enough? I see other params here mediasoup :: API

I’d not confuse browser audio-enhancements with packet-loss/lag so silly question…:smiley:

Are you referencing echo acoustic cancellation that dubs background sound out (at times may muffle things)?

Try useDtx: false (it’s boolean, not number)

Also try disabling autoGainControl and echoCancellation.

Client snippet code:

async function getUserMedia() {
  let stream;
  try {
    stream = await navigator.mediaDevices.getUserMedia({ audio: {
        autoGainControl: false,
        noiseSuppression: true,
        echoCancellation: false
      },
      video: false })
  } catch (err) {
    console.error('getUserMedia() failed:', err.message);
    throw err;
  }
  return stream;
}

Also test disabling noiseSuppression.
Be careful, I use no video, only audio.

THANKS!!! I think DTX was the culprit here (the compression noise) and also the autoGain on the getUserMedia seems to make the audio much cleaner

The echo cancellation in WebRTC may not be ideal in some cases, and it requires client-side optimization for certain specific scenarios. Where can we start to solve similar issues?