Beispiel #1
0
    public void EndRecording()
    {
        if (recording)
        {
            var position  = Microphone.GetPosition(Name);
            var soundData = new float[recording.samples * recording.channels];
            recording.GetData(soundData, 0);

            var newData = new float[position * recording.channels];

            for (int i = 0; i < newData.Length; i++)
            {
                newData[i] = soundData[i];
            }

            // Create a new trimmed clip.
            AudioClip newClip = AudioClip.Create(recording.name, position, recording.channels, recording.frequency, false);
            newClip.SetData(newData, 0);
            Object.Destroy(recording);

            if (RecordingFinished != null)
            {
                RecordingFinished.Invoke(newClip);
            }

#if UNITY_EDITOR
            Debug.Log("<b>Recording stopped...</b>");
#endif
        }
    }
        private void EndCurrentRecording()
        {
            if (!startNewRecording)
            {
                EnsureCorrectResultType();

                recordingKeyCombination   = false;
                recordingMouseCombination = false;
                startNewRecording         = true; //Save the current state, but if we start recording again, remove the current saved Modifiers
                RecordingFinished?.Invoke(this, new ActionRecorderEventArgs(Key, MouseAction, Modifiers, ResultType));
            }
        }
    /// <summary>
    /// Callback executed when the recording is stopped
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void RecordingStopped(object sender, StoppedEventArgs e)
    {
        _waveSource.DataAvailable    -= DataAvailable;
        _waveSource.RecordingStopped -= RecordingStopped;
        _waveSource?.Dispose();
        _waveWriter?.Dispose();

        /*Convert the recorded file to MP3*/
        ConvertWaveToMp3(_tempFilename, _filename);
        /*Send notification that the recording is complete*/
        RecordingFinished?.Invoke(this, null);
    }
 private void AriClient_OnRecordingFinishedEvent(IAriClient sender, RecordingFinishedEvent e)
 {
     RecordingFinished?.Invoke(this, e);
 }