"unity Couldn't acquire device ID for device name Built-in Microphone" Code Answer's
You're definitely familiar with the best coding language C# that developers use to develop their projects and they get all their queries like "unity Couldn't acquire device ID for device name Built-in Microphone" answered properly. Developers are finding an appropriate answer about unity Couldn't acquire device ID for device name Built-in Microphone related to the C# coding language. By visiting this online portal developers get answers concerning C# codes question like unity Couldn't acquire device ID for device name Built-in Microphone. Enter your desired code related query in the search bar and get every piece of information about C# code related question on unity Couldn't acquire device ID for device name Built-in Microphone.
unity Couldn't acquire device ID for device name Built-in Microphone
using UnityEngine;
using System.Collections;
[RequireComponent (typeof (AudioSource))]
public class MicrophoneCapture : MonoBehaviour
{
// Boolean flags shows if the microphone is connected
private bool micConnected = false;
//The maximum and minimum available recording frequencies
private int minFreq;
private int maxFreq;
//A handle to the attached AudioSource
private AudioSource goAudioSource;
void Start()
{
//Check if there is at least one microphone connected
if(Microphone.devices.Length <= 0)
{
//Throw a warning message at the console if there isn't
Debug.LogWarning("Microphone not connected!");
}
else //At least one microphone is present
{
//Set our flag 'micConnected' to true
micConnected = true;
//Get the default microphone recording capabilities
Microphone.GetDeviceCaps(null, out minFreq, out maxFreq);
//According to the documentation, if minFreq and maxFreq are zero, the microphone supports any frequency...
if(minFreq == 0 && maxFreq == 0)
{
//...meaning 44100 Hz can be used as the recording sampling rate
maxFreq = 44100;
}
//Get the attached AudioSource component
goAudioSource = this.GetComponent<AudioSource>();
}
}
void OnGUI()
{
//If there is a microphone
if(micConnected)
{
//If the audio from any microphone isn't being captured
if(!Microphone.IsRecording(null))
{
//Case the 'Record' button gets pressed
if(GUI.Button(new Rect(Screen.width/2-100, Screen.height/2-25, 200, 50), "Record"))
{
//Start recording and store the audio captured from the microphone at the AudioClip in the AudioSource
goAudioSource.clip = Microphone.Start(null, true, 20, maxFreq);
}
}
else //Recording is in progress
{
//Case the 'Stop and Play' button gets pressed
if(GUI.Button(new Rect(Screen.width/2-100, Screen.height/2-25, 200, 50), "Stop and Play!"))
{
Microphone.End(null); //Stop the audio recording
goAudioSource.Play(); //Playback the recorded audio
}
GUI.Label(new Rect(Screen.width/2-100, Screen.height/2+25, 200, 50), "Recording in progress...");
}
}
else // No microphone
{
//Print a red "Microphone not connected!" message at the center of the screen
GUI.contentColor = Color.red;
GUI.Label(new Rect(Screen.width/2-100, Screen.height/2-25, 200, 50), "Microphone not connected!");
}
}
}
Source: www.universityofgames.net
All those coders who are working on the C# based application and are stuck on unity Couldn't acquire device ID for device name Built-in Microphone can get a collection of related answers to their query. Programmers need to enter their query on unity Couldn't acquire device ID for device name Built-in Microphone related to C# code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about unity Couldn't acquire device ID for device name Built-in Microphone for the programmers working on C# code while coding their module. Coders are also allowed to rectify already present answers of unity Couldn't acquire device ID for device name Built-in Microphone while working on the C# language code. Developers can add up suggestions if they deem fit any other answer relating to "unity Couldn't acquire device ID for device name Built-in Microphone". Visit this developer's friendly online web community, CodeProZone, and get your queries like unity Couldn't acquire device ID for device name Built-in Microphone resolved professionally and stay updated to the latest C# updates.