Search Unity

Record multiple mics simultaneously Mac issue

Discussion in 'Audio & Video' started by foyleman, Sep 24, 2015.

  1. foyleman

    foyleman

    Joined:
    Feb 19, 2009
    Posts:
    116
    I am unable to record from multiple microphones at the same time in Unity on the Mac but I can on the PC.

    I created a very simple scene for testing...
    • add two empty GameObjects
    • attach to each an AudioSource
      • Mute and bypass all (for your sanity)
      • Spatial Blend 2D
    • attach to each the following simple script
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class recMic : MonoBehaviour {
    5.    
    6.     public int micIndex = 0;
    7.     public string thisMicName = "";
    8.     private AudioSource myAS;
    9.  
    10.     void Start ()
    11.     {
    12.         myAS = GetComponent<AudioSource> ();
    13.     }
    14.  
    15.     void OnGUI ()
    16.     {
    17.         if (myAS != null) {
    18.             if (GUI.Button (new Rect (micIndex * 100, 0, 100, 30), micIndex.ToString ()))
    19.                 StartCoroutine ("listenToMic");
    20.         }
    21.     }
    22.    
    23.     IEnumerator listenToMic ()
    24.     {
    25.         if (Microphone.devices.Length < micIndex + 1) {
    26.             Debug.Log ("mic index "+micIndex+" doesn't exist");
    27.             yield break;
    28.         }
    29.  
    30.         thisMicName = Microphone.devices[micIndex];
    31.         int minf;
    32.         int maxf;
    33.         Microphone.GetDeviceCaps (thisMicName, out minf, out maxf);
    34.         Debug.Log ("listenToMic started for player " + micIndex + " : " + thisMicName +":"+minf+":"+maxf );
    35.        
    36.         int recLength = 5 * 60;
    37.         myAS.clip = Microphone.Start(thisMicName, false, recLength, 44100);
    38.         if (myAS.clip == null) {
    39.             Debug.Log ("mic start failed for: " + thisMicName);
    40.             yield break;
    41.         }
    42.        
    43.         float maxwait = Time.time + 3f;
    44.         while (!(Microphone.GetPosition(thisMicName) > 0)) { // Wait until the recording has started
    45.             if (Time.time > maxwait) {
    46.                 Debug.Log ("Mic position not found for: " + thisMicName);
    47.                 yield break;
    48.             }
    49.         }
    50.        
    51.         myAS.Play ();
    52.         float CloseTime = Time.time + recLength;
    53.         while (Microphone.IsRecording (thisMicName)) {
    54.             yield return 1;
    55.             if (Time.time >= CloseTime) {
    56.                 Debug.Log ("listenToMic 1 Microphone.End");
    57.                 Microphone.End (thisMicName);
    58.                 myAS.Stop ();
    59.                 myAS.clip = null;
    60.                
    61.                 yield break;
    62.             }
    63.         }
    64.         Debug.Log ("listenToMic 2 Microphone.End");
    65.         Microphone.End (thisMicName);
    66.         myAS.Stop ();
    67.         myAS.clip = null;
    68.     }
    69. }
    70.  
    When activating two microphones on the Mac, I receive the following error:
    I can't remember if this functionality was working a few months ago, but I believe it was.

    Either case... anyone experience this? Anyone solve this? Thoughts on possible issue?
     
  2. foyleman

    foyleman

    Joined:
    Feb 19, 2009
    Posts:
    116
    Apparent Mac CAN NOT do it. Very frustrating.
    It would seem that Mac cannot handle access to multiple USB microphones at the same time.
    An aggregate device is not the same thing (combining multiple mics into one) as I need separate access (like someone recording a live band in Garage Band).

    I cannot verify if a 4x4 USB interface such as "Presonus AUDIOBOX 44VSL" would work. Yes, I realize that this product does not accept USB inputs as a source but I might be able to sell the client on it.

    Any other ideas from anyone?
     
  3. foyleman

    foyleman

    Joined:
    Feb 19, 2009
    Posts:
    116
    Is there a product that will allow multiple audio imports and distinguish between them on a Macbook?
     
  4. Deleted User

    Deleted User

    Guest

    Hi,
    I am currently in the same situation.
    Have you found any solution to this problem?