Unity SDK - Oculus - Issues on microphone

87 views
Skip to first unread message

Michele Castelletti

unread,
Jul 19, 2021, 11:28:21 AM7/19/21
to Ant Media Server
Hello everyone,

we're trying to put the AntMedia Unity SDK into an Oculus project.

We made it working for audio-chat only, but we're currently having troubles on getting the microphone to communicate with the server.

After a lot of debugging we found out that the problem seems to be the AudioRenderer.

We tried working around it by using the default Microphone API from Unity, but with no result (the app crashes as it should start communicating with the server).

The code we tried is the following:
In the Render() functions
if (sora != null && !Recvonly && Microphone.IsRecording(audioRecordingDevice)) {
                if (!audioSourceInput.isPlaying) audioSourceInput.Play();
                //var samples = AudioRenderer.GetSampleCountForCaptureFrame();
                if (AudioSettings.speakerMode == AudioSpeakerMode.Stereo) {
                    //var buf = new Unity.Collections.NativeArray<float>(samples * 2, Unity.Collections.Allocator.Temp);
                    int samples = audioSourceInput.clip.samples * audioSourceInput.clip.channels;
                    int pos = 0;// Microphone.GetPosition(audioRecordingDevice);
                    float[] buf = new float[samples];
                    //audioSourceInput.clip.GetData(buf, 0);
                    print("mic pos: "+pos+" | clip samples: "+audioSourceInput.clip.samples+" | samples: "+samples+" | channels: "+audioSourceInput.clip.channels+" | buffer size: "+buf.Length);

                    //sora.ProcessAudio(buf, 0, samples);
                }
            }

In the Init() function:
audioSourceInput.clip = Microphone.Start(null, true, 5, maxFreq);
audioSourceInput.Play();

If we was to use the AudioRenderer (as in the base file provided) what happens is that the microphones "disappear" from the system and therefore cannot be used by the app to send audio.
Has anyone actually made it?

Thank you in advance

Enes Kuluk

unread,
Jul 20, 2021, 3:00:00 AM7/20/21
to Ant Media Server
Some of our users managed to do that. Hope one of them will notice this thread and can guide you better. I'm unable to test it on the oculus since I don't have one sadly.

Enes.
Reply all
Reply to author
Forward
0 new messages