public void StopRecord() { if (!IsRecording || !ReadyToRecord()) { return; } IsRecording = false; CustomMicrophone.End(MicrophoneDevice); if (!DetectVoice) { LastRecordedRaw = _currentRecordingVoice.ToArray(); LastRecordedClip = AudioConvert.Convert(LastRecordedRaw, _microphoneWorkingAudioClip.channels); } if (_currentRecordingVoice != null) { _currentRecordingVoice.Clear(); } _currentAudioSamples = null; _currentRecordingVoice = null; #if NET_2_0 || NET_2_0_SUBSET if (RecordEndedEvent != null) { RecordEndedEvent(LatestVoiceAudioClip, LastRecordedRaw); } #else RecordEndedEvent?.Invoke(LastRecordedClip, LastRecordedRaw); #endif }
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(); }
public void StopRecording() { if (_recordingRoutine != 0) { CustomMicrophone.End(_microphoneID); Runnable.Stop(_recordingRoutine); _recordingRoutine = 0; } }
private void StopRecord() { if (!CustomMicrophone.HasConnectedMicrophoneDevices()) { return; } if (!CustomMicrophone.IsRecording(CustomMicrophone.devices[0])) { return; } CustomMicrophone.End(CustomMicrophone.devices[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); }
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 }
public IEnumerator OneTimeRecord(int durationSec, Action <AudioClip> callback, int sampleRate = 16000) { AudioClip clip = CustomMicrophone.Start(MicrophoneDevice, false, durationSec, sampleRate); yield return(new WaitForSeconds(durationSec)); CustomMicrophone.End(MicrophoneDevice); #if !NET_2_0 && !NET_2_0_SUBSET callback?.Invoke(clip); #else if (callback != null) { callback(clip); } #endif }
public IEnumerator OneTimeRecord(int durationSec, Action <float[]> callback, int sampleRate = 16000) { AudioClip clip = CustomMicrophone.Start(MicrophoneDevice, false, durationSec, sampleRate); yield return(new WaitForSeconds(durationSec)); CustomMicrophone.End(MicrophoneDevice); float[] array = new float[clip.samples * clip.channels]; CustomMicrophone.GetRawData(ref array, clip); #if !NET_2_0 && !NET_2_0_SUBSET callback?.Invoke(array); #else if (callback != null) { callback(array); } #endif }
/// <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(); }