// Use this for initialization void Start() { GameObject go = GameObject.Find("Achtelnote"); m_achtelnote = go.GetComponent <Anfangspunkt>(); // Debug.Log("obj:" + achtelNote); // Debug.Break(); currentAudioSource = GetComponent <AudioSource>(); currentAudioSource.clip = Microphone.Start(null, true, 2, AudioSettings.outputSampleRate); currentAudioSource.loop = true; currentAudioSource.volume = 1.0f; currentAudioSource.Play(); waveForm = gameObject.AddComponent <LineRenderer>(); waveForm.widthMultiplier = 0.05f; waveForm.startColor = Color.red; waveForm.loop = false; samples = new float[lenghtOfLineRenderer]; spectrum = new float[lenghtOfLineRenderer]; points = new Vector3[lenghtOfLineRenderer]; for (int i = 0; i < lenghtOfLineRenderer; i++) { points[i] = new Vector3(0.0f, 0.0f); } audioPegel = 0.0f; }
//Start function for web player (also works on other platforms) IEnumerator Start() { yield return(Application.RequestUserAuthorization(UserAuthorization.Microphone)); if (Application.HasUserAuthorization(UserAuthorization.Microphone)) { selectedDevice = Microphone.devices[0].ToString(); micSelected = true; GetMicCaps(); //Estimates bufer len, based on pitchTimeInterval value int bufferLen = (int)Mathf.Round(AudioSettings.outputSampleRate * pitchTimeInterval / 1000f); Debug.Log("Buffer len: " + bufferLen); data = new float[bufferLen]; detectionsMade = new int[maxDetectionsAllowed]; //Allocates detection buffer setUptMic(); } GameObject go = GameObject.Find("Achtelnote"); m_achtelnote = go.GetComponent <Anfangspunkt>(); }