Search code examples
c#unity-game-engineaudiomicrophonerecording

Recording with two microphones in Unity C#


Thanks for comming here. I have two microphones connected to a PC and I would like to record sound from them simultaneously. Is it possible to do this at all? Any methods. Maybe I need to buy some device?


Solution

  • You should be able to get a list of available recording devices using the microphone class

    // Get list of Microphone devices and print the names to the log
    void Start()
    {
        foreach (var device in Microphone.devices)
        {
            Debug.Log("Name: " + device);
        }
    }
    

    You can use this device list to create audio clips from each device

    [SerializeField]
    private AudioSource audioSource1;
    [SerializeField]
    private AudioSource audioSource2;
    
    // Start recording with built-in Microphone and play the recorded audio right away
    private IEnumerator Record()
    {
        audioSource1.clip = Microphone.Start("<audio-device-1>", true, 10, 44100);
        audioSource2.clip = Microphone.Start("<audio-device-2>", true, 10, 44100);
    }