private void RecordFailedEventHandler() { #if !NET_2_0 && !NET_2_0_SUBSET RecordFailedEvent?.Invoke(); #else if (RecordFailedEvent != null) { RecordFailedEvent(error); } #endif }
public void StartRecord(bool withVoiceDetection = false) { if (IsRecording) { return; } if (!ReadyToRecord()) { #if NET_2_0 || NET_2_0_SUBSET if (RecordFailedEvent != null) { RecordFailedEvent(); } #else RecordFailedEvent?.Invoke(); #endif return; } DetectVoice = withVoiceDetection; _maxVoiceFrame = 0; _currentRecordingVoice = new List <float>(); if (_microphoneWorkingAudioClip != null) { MonoBehaviour.Destroy(_microphoneWorkingAudioClip); } if (LastRecordedClip != null) { MonoBehaviour.Destroy(LastRecordedClip); } _microphoneWorkingAudioClip = CustomMicrophone.Start(MicrophoneDevice, true, 1, 16000); _currentAudioSamples = new float[_microphoneWorkingAudioClip.samples * _microphoneWorkingAudioClip.channels]; IsRecording = true; #if NET_2_0 || NET_2_0_SUBSET if (RecordStartedEvent != null) { RecordStartedEvent(); } #else RecordStartedEvent?.Invoke(); #endif }
/// <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(); }