Пример #1
0
        private void StopRecord()
        {
            if (!CustomMicrophone.HasConnectedMicrophoneDevices())
            {
                return;
            }

            if (!CustomMicrophone.IsRecording(selectedDevice))
            {
                return;
            }

            CustomMicrophone.End(selectedDevice);

            if (makeCopy)
            {
                recordedClips.Add(MakeCopy($"copy{recordedClips.Count}", recordingTime, frequency, _workingClip));
                audioSource.clip = recordedClips.Last();
            }
            else
            {
                audioSource.clip = _workingClip;
            }

            audioSource.Play();
        }
Пример #2
0
    void Start()
    {
        if (!photonView.IsMine)
        {
            return;
        }

        audioListener.enabled = true;

        if (!CustomMicrophone.HasConnectedMicrophoneDevices())
        {
            CustomMicrophone.RefreshMicrophoneDevices();
        }
        Debug.Log(CustomMicrophone.devices.Length + " microphone devices found");

        if (!CustomMicrophone.HasConnectedMicrophoneDevices())
        {
            Debug.Log("no microphone device connected");
        }

        _microphoneDevice = CustomMicrophone.devices[0];
        audioClip         = CustomMicrophone.Start(_microphoneDevice, true, lengthSec, frequency);

        //subscribe to events
        VoiceChat.Instance.OnStatusUpdate += OnStatusupdate;
        VoiceChat.Instance.OnIDUpdate     += OnIDUpdate;

        //initialize peer object for this client
        VoiceChat.Instance.InitializePeer();
    }
Пример #3
0
        private void StartRecord()
        {
            if (!CustomMicrophone.HasConnectedMicrophoneDevices())
            {
                return;
            }

            _workingClip = CustomMicrophone.Start(CustomMicrophone.devices[0], true, 4, 44100);
        }
Пример #4
0
        private void StartRecord()
        {
            if (!CustomMicrophone.HasConnectedMicrophoneDevices())
            {
                return;
            }

            _workingClip = CustomMicrophone.Start(selectedDevice, false, recordingTime, frequency);
        }
Пример #5
0
        /// <summary>
        /// Initializes buffer, refreshes microphones list and selects first microphone device if exists
        /// </summary>
        private void Start()
        {
            _buffer = new List <float>();

            RefreshMicrophones();

            if (CustomMicrophone.HasConnectedMicrophoneDevices())
            {
                _microphoneDevice = CustomMicrophone.devices[0];
            }
        }
Пример #6
0
        /// <summary>
        /// Starts recording of microphone
        /// </summary>
        public void StartRecord()
        {
            if (CustomMicrophone.IsRecording(_microphoneDevice) || !CustomMicrophone.HasConnectedMicrophoneDevices())
            {
                RecordFailedEvent?.Invoke("record already started or no microphone device conencted");
                return;
            }

            recording = true;

            _workingClip = CustomMicrophone.Start(_microphoneDevice, true, Constants.RecordingTime, Constants.SampleRate);

            RecordStartedEvent?.Invoke();
        }
Пример #7
0
        private void StopRecord()
        {
            if (!CustomMicrophone.HasConnectedMicrophoneDevices())
            {
                return;
            }

            if (!CustomMicrophone.IsRecording(CustomMicrophone.devices[0]))
            {
                return;
            }

            CustomMicrophone.End(CustomMicrophone.devices[0]);
        }
Пример #8
0
        private void RefreshMicrophoneDevicesButtonOnclickHandler()
        {
            RequestPermission();
            CustomMicrophone.RefreshMicrophoneDevices();

            if (!CustomMicrophone.HasConnectedMicrophoneDevices())
            {
                return;
            }

            devicesDropdown.ClearOptions();
            devicesDropdown.AddOptions(CustomMicrophone.devices.ToList());
            DevicesDropdownValueChangedHandler(0);
        }
Пример #9
0
    // Start is called before the first frame update
    void Start()
    {
        var voice = GameObject.Find("[PeerJS]VoiceChat");

        if (voice != null)
        {
            Destroy(voice);
        }

        var microphone = GameObject.Find("[FG]Microphone");

        if (microphone != null)
        {
            if (CustomMicrophone.IsRecording(CustomMicrophone.devices[0]))
            {
                CustomMicrophone.End(CustomMicrophone.devices[0]);
            }
            Destroy(microphone);
        }



        // request microphone permissions at the start of the menu
        if (!CustomMicrophone.HasMicrophonePermission())
        {
            CustomMicrophone.RequestMicrophonePermission();
        }
        if (!CustomMicrophone.HasConnectedMicrophoneDevices())
        {
            CustomMicrophone.RefreshMicrophoneDevices();
        }
        //Debug.Log(CustomMicrophone.devices.Length + " microphone devices found");

        // destroys game tracker from previous game
        if (GameObject.FindGameObjectWithTag("GameTracker") != null)
        {
            Destroy(GameObject.FindGameObjectWithTag("GameTracker"));
        }

        // disconnects the player if they were already connected
        if (PhotonNetwork.IsConnected)
        {
            PhotonNetwork.Disconnect();
            Cursor.lockState = CursorLockMode.None;
            Cursor.visible   = true;
        }
        PhotonNetwork.ConnectUsingSettings();
        //Debug.Log(PhotonNetwork.PhotonServerSettings);
    }
Пример #10
0
        private void StopRecordHandler()
        {
            if (!CustomMicrophone.HasConnectedMicrophoneDevices())
            {
                return;
            }

            CustomMicrophone.End(CustomMicrophone.devices[0]);
            _audioSource.Stop();

#if UNITY_WEBGL && !UNITY_EDITOR
            _buffer.data.Clear();
            _buffer.position = 0;
#endif
        }
Пример #11
0
        private void StartRecordHandler()
        {
            if (!CustomMicrophone.HasConnectedMicrophoneDevices())
            {
                return;
            }

#if UNITY_EDITOR
            _audioSource.clip =
#endif
            CustomMicrophone.Start(CustomMicrophone.devices[0], true, _recordingTime, _sampleRate);
#if UNITY_EDITOR
            _audioSource.loop = true;
            _audioSource.Play();
#endif
        }
Пример #12
0
        /// <summary>
        /// Stops recording of microphone
        /// </summary>
        public void StopRecord()
        {
            if (!CustomMicrophone.IsRecording(_microphoneDevice))
            {
                return;
            }

            recording = false;

            if (CustomMicrophone.HasConnectedMicrophoneDevices())
            {
                CustomMicrophone.End(_microphoneDevice);
            }

            if (_workingClip != null)
            {
                Destroy(_workingClip);
            }

            RecordEndedEvent?.Invoke();
        }
Пример #13
0
 public bool HasConnectedMicrophoneDevices()
 {
     return(CustomMicrophone.HasConnectedMicrophoneDevices());
 }