Ejemplo n.º 1
0
        } //END GetAudioFormat
#endif
        
#if NATMIC
        //-------------------------------------------------------//
        private void OnSampleRecieved( AudioEvent audioEvent, float[] sampleBuffer, long timestamp, Format format )
        //-------------------------------------------------------//
        {

            if( audioEvent == AudioEvent.OnInitialize )
            {
                if( RecordToFile() )
                {
                    // Create a WAV recorder to record the audio to a file
                    if( recordingFileType == RecordingFileType.WAV )
                    {
                        micRecorder = new WAVRecorder(format);
                    }
                    else
                    {
                        micRecorder = new WAVRecorder(format);
                    }
                    
                    micRecorder.StartRecording( OnRecordToFileComplete );
                }

                //if (onRecordingStart != null) { onRecordingStart.Invoke(); }
            }
            else if( audioEvent == AudioEvent.OnSampleBuffer )
            {
                if( RecordToFile() )
                {
                    // Commit the sample buffer to the WAV recorder
                    micRecorder.CommitSamples( sampleBuffer, timestamp );
                }

                //Disabled, this method runs in a coroutine so we can't call a UnityEvent method from it!
                //if (onPlaybackBufferEvent != null) { onPlaybackBufferEvent.Invoke(audioEvent, sampleBuffer, timestamp, format); }
            }
            else if( audioEvent == AudioEvent.OnFinalize )
            {
                if( RecordToFile() )
                {
                    // Stop recording the WAV file and dispose the recorder
                    micRecorder.Dispose();
                }
            }

        } //END OnSampleRecieved
Ejemplo n.º 2
0
        private void OnSampleBuffer(AudioEvent audioEvent, float[] sampleBuffer, long timestamp, Format format)
        {
            switch (audioEvent)
            {
            case AudioEvent.OnInitialize:
                // Create a WAV recorder to record the audio to a file
                recorder = new WAVRecorder(format);
                recorder.StartRecording(OnAudioRecording);
                break;

            case AudioEvent.OnSampleBuffer:
                // Commit the sample buffer to the WAV recorder
                recorder.CommitSamples(sampleBuffer, timestamp);
                break;

            case AudioEvent.OnFinalize:
                // Stop recording the WAV file and dispose the recorder
                recorder.Dispose();
                break;
            }
        }
        public void StopRecording()
        {
            _recorder.Dispose();

            Startded = false;
        }
Ejemplo n.º 4
0
 public void StopRecording()
 {
     _state = State.Idle;
     _recorder.StopCaptureToFile();
     _recorder.Dispose();
 }