Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Audio How to record two microphones simultaneously in one scene?

Discussion in 'Audio & Video' started by agneyakerure, Nov 22, 2017.

  1. agneyakerure

    agneyakerure

    Joined:
    Nov 22, 2017
    Posts:
    1
    I want to record two different audio streams using two different microphones connected to one audio interface (if necessary 2, I have an extra one) at the same time. I am not able to do this using the Microphone class in Unity. Please let me know how to go about this. Thank you so much!


    void Start()
    {
    foreach (string device in Microphone.devices)
    {
    Debug.Log(device);
    //Debug.Log(Microphone.devices[3]);
    }
    aud1 = GetComponent<AudioSource>();
    aud1.clip = Microphone.Start(Microphone.devices[2], true, 1, 44100);
    aud1.loop = true;
    aud1.mute = false;

    aud2 = GetComponent<AudioSource>();
    aud2.clip = Microphone.Start(Microphone.devices[3], true, 1, 44100);
    aud2.loop = true;
    aud2.mute = false;
    }

    // Update is called once per frame
    void Update()
    {

    aud1.clip.GetData(_samples1, 0);
    aud2.clip.GetData(_samples2, 0);
    }


    This does not work for me. Any help is greatly appreciated. Thanks!
     
  2. UnetDev

    UnetDev

    Joined:
    Aug 28, 2017
    Posts:
    54
    Hello! Faced the same problem, and as far as I understand Microphone.Start is a call to a static instance of the Microphone class, and it means that the second function call overlaps the first call.