Microphone Audio is Silent

Hi all.

For some reason Unity’s Microphone API is producing dead silent audio. You can use this script and monitor the VU meter in the editor:

using UnityEngine;

public class Mic : MonoBehaviour {

    void Start () {
        // Create audio source
        var audioSource = gameObject.AddComponent<AudioSource>();
        audioSource.loop = true;
        audioSource.bypassEffects =
        audioSource.bypassListenerEffects = false;
        // Start microphone
        audioSource.clip = Microphone.Start(null, true, 10, AudioSettings.outputSampleRate);
        audioSource.Play();
    }

    void OnAudioFilterRead (float[] data, int channels) { } // This will display a VU meter in the editor
}

Any ideas? Also, I should note that I am the developer of NatMic API which is an alternative for Unity’s Microphone API. But I still would like Unity’s mic API to work.

If you are on a Mac running OS 10.14 (or above), it is likely that Unity (and Unity Hub) have not been given microphone access permission. In theory, Unity Hub should ask for permission (once), but it does not appear to do this. I am running Unity 2019.3f1 and encountering this issue. Continuing to look for a solution… Requesting Authorization for Media Capture on macOS | Apple Developer Documentation

See also Reddit - Dive into anything

1 Like

I don’t think it’s a permissions issue. I’m running Unity 2018.3 on macOS 10.14.4. Unity is given microphone permissions and camera permissions. WebCamTexture works. And I just tested with NatMic, my microphone API, and that works too.

you have to yield until microphone position is > 0 before calling Play()
it's how their API works with some hw+drivers combination

2 Likes

Looks like you’re right. Thanks!

I was able to fix my “silent microphone” problem by editing the tcc.db system file to add Unity Hub’s permissions. For some reason, they were not appearing at all in the “System Preferences/Security & Privacy/Privacy/Microphone” access list.
To edit tcc.db, I followed these instructions: Reddit - Dive into anything, but substituted the following line in for Unity Hub (line 10 of the instructions):
INSERT INTO access VALUES(‘kTCCServiceMicrophone’,‘com.unity3d.unityhub’,0,1,1,NULL,NULL,NULL,‘UNUSED’,NULL,0,1541440109);

2 Likes

I can confirm that the solution by TimeWalk-org works.

Wow thanks TimeWalk-org! can’t believe that worked!

Also confirmed as the issue and potential resolution. And since this is modifying system resources, everyone must determine their own course of action. Thanks @TimeWalk-org

Issue exists with Unity Hub v2.3.0 with Catalina 10.15.3.

1 Like

I can confirm I was able to workaround this issue following the below steps.
I'm using Mac OS Mojave 10.14.5.
Unity 2019.02.0f1 , Unity Hub 2.3.0.

Link : https://issuetracker.unity3d.com/issues/osx-unity-fails-to-ask-camera-permission-and-crashes-on-privacy-violation?page=2#comments (LAUNZONE 30, 2020 04:10)

Comment:

Hey everyone, I know that this is not ideal and unity or apple should come up with a better solution eventually but here is what works for me and is pretty sure to work for everyone that can't add microphone or camera permission to unity hub. It is kind of weird and you have to disable SIP (system integrity protection) for a couple of minutes to do it, so maybe read up on that first if you are worried (I was not).

1) Disable SIP: Go into recovery mode (hold CMD+R when you restart your Mac) Don't be afraid, we are not doing anything crazy.

2) After that open Terminal (it should be accessible from one of the Menus at the Top) Type in "csrutil disable" and hit enter. Then reboot your Mac normally.

3) Open Terminal and type in: "sqlite3 ~/Library/Application\ Support/com.apple.TCC/TCC.db" and hit enter

4) For microphone access, type in: "INSERT INTO access VALUES('kTCCServiceMicrophone','com.unity3d.unityhub',0,1,1,NULL,NULL,NULL,'UNUSED',NULL,0,1541440109);" and hit enter

For camera, type in: "INSERT INTO access VALUES('kTCCServiceCamera','com.unity3d.unityhub',0,1,1,NULL,NULL,NULL,'UNUSED',NULL,0,1541440109);" and hit enter

6) check in your SystemPreferences/Security&Privacy > unity hub should now show up in both mic and cam

7) reboot in recovery mode again (CMD+R), open terminal again, type in: "csrutil enable" and hit enter, to enable SIP again

8) reboot normally and enjoy!

That's it! I hope it works for you. Don't forget the step 7, I think it is important for Security.

Is Unity working to fix this at all? The solution above works beautifully but…

This is a problem with MacOS apps exported from Unity as well. And I cannot ask the people who download my app to do this if they are on MacOS, it simply does not work.

Any thoughts?

2 Likes

I saw in the latest Hub release notes https://unity3d.com/hub/whats-new

New Fixes
* For Mac Catalina OS, Hub permissions are now passed for camera and other Unity Editor related features

Don't know if that addressed the issue for the Editor and mic or not. Haven't tested it.

Having the exact same issue on Windows.

2 Likes

Doesn't seem like it was fixed, just had to still do it manually with 2.3.2 / Unity 2019.3.14f1.
Also in case it's useful for someone, permissions for Unity Editor instead of Hub can be set like this.

INSERT INTO access VALUES('kTCCServiceMicrophone','com.unity3d.UnityEditor5.x',0,1,1,NULL,NULL,NULL,'UNUSED',NULL,0,1541440109);

I resoved my issue with above code.

I've still been finding this issue to be the case with Unity 2020.3.1f1, both when building from Cloud Build or locally from a Mac.

I've also been finding slightly different behaviour across Mac OS versions. On Catalina and Big Sur, I'm finding that our built application does appear in the Camera and 'Files and Folders' sections of the Security & Privacy System Preferences, with the permission already granted (i.e. the box is ticked), but the App fails to initiate the camera or be able to access the file system.

The solution I've found here is to

  • 'uncheck' the box i.e. revoke the permission
  • open and close the App
  • 'check' the box

That seems to fix things for Catalina and Big Sur users.

Unfortunately for Mojave users, the App doesn't appear in the lists to begin with, so I'm going to attempt the fixes listed above.

Has this process changed for M1 Apple hardware?

I am not having success with Step 10.
My Hardware / Software:
Apple MacBook Air M1
Unity 2021.3.3f1

Failure occurs for me at Step 10 when entering into Terminal:
INSERT INTO access VALUES('kTCCServiceMicrophone','com.unity3d.unityhub',0,1,1,NULL,NULL,NULL,'UNUSED',NULL,0,1541440109);

I receive the following error from Terminal:
Error: in prepare, table access has 13 columns but 12 values were supplied (1) sqlite>

Is there a solution?

Old thread, but having this issue on Windows now... microphone (via Focusrite audio interface) is recognized by the system, and in Ableton, and Unity sees it as an input, but no sound seems to be read. Anyone got any solutions?

Is it set as your default recording device in you sound configuration? I’m using a Focusrite too (Scarlett 2i2) and I have no problem recording audio in Unity.