Ejemplo n.º 1
0
        void Update()
        {
            if (microphoneDeviceSet)
            {
                if (microphoneActive)
                {
                    MicrophoneUpdate();
                }
                else if (listening) // If we're listening, but the microphone shouldn't be active
                {
                    StopListening();
                }
            }
            else if (microphoneActive) // If the microphone should be active, but it is not configured
            {
                LogMT.LogWarning("MicrophoneController: Microphone active yet no microphone device set!");
                //microphoneActive = false;
            }

            if (listening)
            {
                BufferTrackingUpdate();
            }
            else
            {
                MicrophoneConfigurationUpdate();
            }

            previousDSPTime = AudioSettings.dspTime;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Watch for changes in microphone configuration status, possibly due to user interaction, and
 /// configure appropriately
 /// </summary>
 private void MicrophoneConfigurationUpdate()
 {
     if (microphoneAvailable)
     {
         if (!microphoneChoiceSent)
         {
             if (!prewarned)
             {
                 if (!prewarningSent)
                 {
                     gameObject.SendMessage("OnSoundEvent", SoundEvent.PermissionRequired, SendMessageOptions.DontRequireReceiver);
                     prewarningSent = true;
                 }
             }
             else if (Application.HasUserAuthorization(UserAuthorization.Microphone))
             {
                 if (Microphone.devices.Length > 0)
                 {
                     if (microphoneUI != null)
                     {
                         if (microphoneUI.UseDefaultMic())
                         {
                             UseDefaultDevice();
                         }
                         else
                         {
                             microphoneUI.ChooseDevice(Microphone.devices);
                         }
                     }
                     else
                     {
                         UseDefaultDevice();
                     }
                     microphoneChoiceSent = true;
                 }
                 else
                 {
                     if (microphoneUI != null)
                     {
                         microphoneUI.NoMicrophonesFound();
                     }
                     LogMT.LogWarning("MicrophoneController: No microphones found");
                     microphoneAvailable = false;
                 }
             }
             else if (!authorizationRequestSent)
             {
                 Application.RequestUserAuthorization(UserAuthorization.Microphone);
                 LogMT.Log("MicrophoneController: User authorization requested for microphone");
                 authorizationRequestSent = true;
             }
         }
     }
 }