public void UpdateMicrophoneList() { //MicrophoneList = Microphone.devices; MicrophoneList = new List <MicDevice>(); Microphone.devices.ToList().ForEach(device => { var temp = new MicDevice(); temp.name = device; Microphone.GetDeviceCaps(temp.name, out temp.MinFreq, out temp.MaxFreq); MicrophoneList.Add(temp); }); micInUse = MicrophoneList[0]; #if UNITY_EDITOR && SHOW_DEBUG foreach (var i in MicrophoneList) { Debug.Log(i.name); } #endif }
public void useMic(string deviceName) { try { if (Microphone.IsRecording(micInUse.name)) { Microphone.End(micInUse.name); } //micInUse.name = deviceName; micInUse = MicrophoneList.Where(x => x.name == deviceName).First(); //gameObject.GetComponent<AudioSource>().clip = //recording; recording = Microphone.Start(micInUse.name, false, MaxLength, micInUse.usedFreq); //recording = gameObject.GetComponent<AudioSource>().clip; #if UNITY_EDITOR && SHOW_DEBUG Debug.Log(micInUse.name + " is using frequency: " + micInUse.usedFreq); #endif currentPos = 0; } catch (Exception e) { Debug.Log(e.Message); } }
private void setMic(string mic_name) { micInUse = MicrophoneList.Where(x => x.name == mic_name).First(); }
public void RefreshMic() { micInUse = new MicDevice(); //create new micdevice to use in this recording session UpdateMicrophoneList(); //refresh the microphone hardware list and fill the micInUse with first device specifications by default //micInUse.usedFreq = 8000;//(micInUse.MaxFreq + micInUse.MinFreq) / 2; }