Skip to content

[BUG]: unity Webrtc AudioSource noise issue #903

@yfangel

Description

@yfangel

Package version

3.0.0-pre.1

Environment

* OS: android
* Unity version: 2019.4

Steps To Reproduce

my code:

1.Obtain local audio from the microphone and transmit it to remote users:

private IEnumerator CaptureAudioStart()
{
var deviceName = Microphone.devices[0];
var micClip = Microphone.Start(deviceName, true, 1, 48000);
// set the latency to “0” samples before the audio starts to play.
while (!(Microphone.GetPosition(deviceName) > 0)) { }
sourceAudio.clip = micClip;
sourceAudio.loop = true;
sourceAudio.reverbZoneMix = 0;
audioStreamTrack = new AudioStreamTrack(sourceAudio);
yield return null;
}

2, Obtain audio streams from remote users for real-time playback:

receiveStream = new MediaStream();
 receiveStream.OnAddTrack = e =>
 {
     if (e.Track is AudioStreamTrack track1)
     {
         Debug.LogWarning("audioTrack: " + track1.ToString());
         StartCoroutine(CaptureAudioStart(track1));
         //receiveAudio.SetTrack(track1);
         //receiveAudio.loop = true;
         //receiveAudio.Play();
     }
 };
 pc2.OnTrack = e =>
 {
     receiveStream.AddTrack(e.Track);
     Debug.LogWarning("OnTrack: ");
 };

Current Behavior

Why is there a lot of noise when using a microphone to obtain local audio and then simultaneously playing the remote audio stream?

Expected Behavior

No response

Anything else?

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingissuedThis means the ticket is already created on internal issue tracker

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions