Search code examples
c#unity-game-engineaudioaudio-recordingmicrophone

Microphone start function freezes unity app


Starting microphone completely freezes the entire application for 5 seconds (always 5 seconds). Unity 5.6.0f3

code:

public void StartRecording()
    {
        System.Diagnostics.Stopwatch sw1 = new System.Diagnostics.Stopwatch();
        sw1.Start();
        if (!Microphone.IsRecording(null))
        {
            m_ForcedStopRecording = false;
            m_RecordingStartTime = Time.time;
            Debug.Log("ms before start microphone 2: " + sw1.ElapsedMilliseconds);
            m_RecordedAudio = Microphone.Start(null, false, m_MaxRecordingLengthInSeconds, m_RecordingFrequency);
            Debug.Log("ms after start microphone: " + sw1.ElapsedMilliseconds);
            StartCoroutine(WaitForRecordingTimeout());
        }
        Debug.Log("total StartRecording: " + sw1.ElapsedMilliseconds);
    }

ms before start microphone 2 result says 0 ms after start microphone says 5011 Any suggestions?


Solution

  • You should try connecting your microphone to different port, it may be a problem of your computer having troubles finding your microphone if it's USB