Need to restart recorder microphone, causing frametime spikes

edited December 2021 in Photon Voice

Hello, I have a setup in Unity where one user streams both their voice from an avatar and also audioclips from various objects in the room.

Every time I create one of the objects to stream a clip, the photon voice stream from the users microphone stops working. I have to set up the clip to stream from the object, restart it's recorder it to get it going and then restart the users voice recorder afterward as well to fix the broken microphone.

This gets the desired behavior but the frametime spike I get from restarting recording on multiple things at once is enormous. Is there a way to restart the microphone asynchronously? Or set up audio clip streams without disrupting the users voice? Thanks


  • JohnTube
    JohnTube ✭✭✭✭✭

    Hi @Poggle,

    You can use two recorders and toggle TransmitEnabled to mute and restart recording if you switch audio clips.

  • @JohnTube Hey John thanks for the response. So there is no way to change audio clips without restarting the microphone? I am on a VR app on Oculus Quest 2 and restarting the microphone has a 100% chance of giving me a big dip in framerate.

    The situation I am in requires me to have 3 objects in the scene all playing rotating through a list of clips and streaming them to other users. I am using a different recorder for each one already and I can transmit the sound from each, my problem is performance. Every time I rotate to the next clip I need to restart the recorder and also the users microphone weirdly enough. I'm trying to reduce the number of times I need to restart both the recorder components on the clip streamers and the users microphone

  • We encounter also such spikes. Is there a chance to put something in a worker thread on photon plugin side? It would be nice if record starting would take some frames, but will prevent the hickup.

  • JohnTube
    JohnTube ✭✭✭✭✭

    Hey @Poggle,

    Maybe a modified version of AudioClipWrapper (that allows swapping AudioClip on the fly) set as InputFactory could be a solution.

    Otherwise, if you or @AndreWe could provide profiling details for the performance overhead of recording starting it would help us assess the situation.

    Does this happen in all cases? AudioClip vs. Microphone, Unity type vs. Photon type.

  • Yes, all scenarios as far as I can tell. Restart recording always causes a hitch in framerate on Oculus Quest 2. I can take a look at the audioclipwrapper

  • @JohnTube, do you need the profiling details in a certain format, e.g. what do you need (sample project, function name etc. which is causing this..)?