private void Start() { if (_microphone == null) { _microphone = FindObjectOfType <MicProxy>(); } // Read this from AvailableWords. _currentWords = AppData.Instance.SelectedWords; GenerateWordViews(_currentWords); }
// Use this for initialization IEnumerator Start() { volumeThreshold = PlayerPrefs.GetFloat("volumeThreshold", volumeThreshold); sliderVolumeThreshold.value = -volumeThreshold; _micProxy = FindObjectOfType <MicProxy>(); var aud = GetComponent <AudioSource>(); int minFreq, maxFreq; for (int i = 0; i < Microphone.devices.Length; i++) { Microphone.GetDeviceCaps(Microphone.devices[i], out minFreq, out maxFreq); Debug.Log(string.Format("Found mic[{0}] = {1} -- {2} -- {3}" , i , Microphone.devices[i] , Microphone.IsRecording(Microphone.devices[i]) ? "MIC REC" : "MIC NO REC" , "FREQ " + minFreq + "-" + maxFreq )); } Microphone.GetDeviceCaps(Microphone.devices[0], out minFreq, out maxFreq); aud.clip = Microphone.Start(Microphone.devices[0], true, 10, maxFreq); aud.loop = true; //aud.mute = true; while (Microphone.GetPosition(null) <= 0) { yield return(null); Debug.Log("Waiting mic"); } Debug.Log("Mic start " + (Microphone.IsRecording(Microphone.devices[0]) ? "MIC REC" : "MIC NO REC")); aud.Play(); _texFeedback = new Texture2D(128, 1024); rendFeedback.material.mainTexture = _texFeedback; /*for (int y = 0; y < _texFeedback.height; y++) * { * for (int x = 0; x < _texFeedback.width; x++) * { * Color color = ((x & y) != 0 ? Color.white : Color.gray); * _texFeedback.SetPixel(x, y, color); * } * } * _texFeedback.Apply();*/ }