private void Awake()
    {
        // Create and initialize the chorus filter.
        if (UseChorus)
        {
            chorusFilter         = gameObject.AddComponent <AudioChorusFilter>();
            chorusFilter.enabled = true;
            UpdateChorusFilter();
        }

        // Create and initialize the echo filter.
        if (UseEcho)
        {
            echoFilter         = gameObject.AddComponent <AudioEchoFilter>();
            echoFilter.enabled = true;
            UpdateEchoFilter();
        }

        // Confgure the microphone stream to use the high quality voice source
        // at the application's output sample rate.
        MicStream.MicInitializeCustomRate(
            (int)MicStream.StreamCategory.HIGH_QUALITY_VOICE,
            AudioSettings.outputSampleRate);

        // Set the initial microphone gain.
        MicStream.MicSetGain(InputGain);

        // Start the stream.
        // Do not keep the data and do not preview.
        MicStream.MicStartStream(false, false);
        MicStream.MicPause();
    }
    private void EnableMicrophone()
    {
        bool enable = false;

        // Check to see if the user is within MaxDistance.
        float distance = Mathf.Abs(
            Vector3.Distance(
                ParentObject.transform.position,
                Camera.main.transform.position));

        if (distance <= MaxDistance)
        {
            RaycastHit hitInfo;

            // Check to see if the user is facing the object.
            // We raycast in the direction of the user's gaze and check for collision with the Echo layer.
            enable = Physics.Raycast(Camera.main.transform.position,
                                     Camera.main.transform.forward,
                                     out hitInfo,
                                     20f,
                                     LayerMask.GetMask("Echoer"),
                                     QueryTriggerInteraction.Collide);
        }

        if (enable)
        {
            // Resume the microphone stream.
            MicStream.MicResume();
        }
        else
        {
            // Pause the microphone stream.
            MicStream.MicPause();
        }
    }
 // on device, deal with all the ways that we could suspend our program in as few lines as possible
 private void OnApplicationPause(bool pause)
 {
     if (pause)
     {
         CheckForErrorOnCall(MicStream.MicPause());
     }
     else
     {
         CheckForErrorOnCall(MicStream.MicResume());
     }
 }