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 }
/// <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(); }