- Home /
Mac built-in microphone stopped sending data to Unity.
I have been using the below script to get in-put from the built-in microphone to the audiosource.
Up until now it has worked perfectly, but recently when trying to clear space on my mac by deleting an old Unity4 instillation, I accidentally deleted Unity5 from my computer and tried opening on Unity4. Unity4 recompiled my project, before I realised what had happened. I deleted Unity4 and re-downloaded and installed Unity5, and again it recompiled my project.
But now, although everything seems to look exactly the same and run exactly the same way as before all this, there is no data coming in from the microphone at all, just nothing. It lists the microphone and assigns it to the audiosource fine, but its as if the mic is outputting nothing. I have tested the mic on other programs and it is functioning normally. I also tried opening my project on another instillation of Unity5 on a Windows system, and it has the same problem. I have not changed the code at all. I am not sure if the switching around between Unity versions has caused the problem or not. I have been searching for the solution, but I am stumped! Any help would be sincerely appreciated.
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(AudioSource))]
public class MicrophoneListener : MonoBehaviour {
public float sensitivity = 100;
public float loudness = 0;
void Start() {
foreach (string i in Microphone.devices) {
Debug.Log (i);
}
GetComponent<AudioSource>().clip = Microphone.Start(null, true, 10, 44100);
GetComponent<AudioSource>().loop = true; // Set the AudioClip to loop
GetComponent<AudioSource>().mute = true; // Mute the sound, we don't want the player to hear it
while (!(Microphone.GetPosition(null) > 0)){} // Wait until the recording has started
GetComponent<AudioSource>().Play(); // Play the audio source!
//Debug.Log ("microphone script entered");
}
Some extra information:
As you see in the script above, I mute the audiosource so that the mic input isn't output through the speakers. However, if I uncheck the 'mute' bool while it is running, then sure enough I get feedback and a response, I can even shout at the computer and it clearly is taking the information in. But as soon as I re-check the 'mute' button, again it goes to zero amplitude, nothing, in the audiosource. I loaded up an old backup of my project from way before all this happened, and it has the same problem, so I think it must be something to do with the latest version of Unity5.2.2? Someone please help!
Your answer
Follow this Question
Related Questions
Max amount of simultaneous, hearable sounds? 1 Answer
Audio: -3db automatic attenuation on any audio playing? 0 Answers
Intensity of sound. -1 Answers
sound too low in Android devices 0 Answers