//private string EncodeToFlac(string inputFilePath) //{ // if (string.IsNullOrEmpty(inputFilePath)) // { // Log.Error(Tag, "inputFilePath was null or empty in EncodeToFlac."); // return null; // } // var flacEncoder = new FLAC_FileEncoder(); // File outputFile; // using (var inputFile = new File(inputFilePath)) // { // var outputFileName = inputFile.Name.Replace(".wav", ".flac"); // outputFile = new File(inputFile.Parent, outputFileName); // flacEncoder.Encode(inputFile, outputFile); // } // return outputFile.AbsolutePath; //} public void RequestStop() { IsStopRequested = true; if (_recorder != null) { _recorder.Stop(); _recorder.Release(); _recorder = null; } DeleteUnfinishedFiles(_storagePath, _fileName); }
public static WavRecorder Instance(int sampleRate = 0) { if (_instance != null) { if (_instance.IsRecording) _instance.Stop(); _instance.Release(); _instance = null; } _instance = sampleRate <= 0 ? new WavRecorder() : new WavRecorder(sampleRate); return _instance.State != WavRecorderState.Error ? _instance : null; }
private void RecordingTimerCallback(object state) { _recordingCountdown++; _service.UpdateRecordingCounter(_recordingCountdown); if (IsStopRequested || _recordingCountdown >= RecordingTime) { if (_recordingTimer != null) _recordingTimer.Dispose(); if (_recorder != null) { _recorder.Stop(); _recorder.Release(); _recorder = null; } IsRecording = false; _service.StoppedRecording(); } }
private void RecordAudio(string path) { //_recorder = WavRecorder.Instance(); _recorder = WavRecorder.Instance(_sampleRate); if (_recorder == null) { Log.Error(ThreadTag, "WavRecorder instance was null."); _service.RecordingFailed(); RequestStop(); return; } _recorder.Error = OnWavRecorderError; _recorder.SetOutputFile(path); _recorder.Prepare(); ResetPrepareTimer(); }
public void RequestStop() { IsStopRequested = true; if (_recorder == null) return; _recorder.Stop(); _recorder.Release(); _recorder = null; }
private void RecordingTimerCallback(object state) { _recordingCountdown++; _service.UpdateRecordingCounter(_recordingCountdown); if (!IsStopRequested && _recordingCountdown < RecordingTime) return; if (_recordingTimer != null) _recordingTimer.Dispose(); if (_recorder != null) { _recorder.Stop(); _recorder.Release(); _recorder = null; } _service.StoppedRecording(); IsRecording = false; }
public static WavRecorder Instance() { var wavRecorder = new WavRecorder(); if (wavRecorder.State != WavRecorderState.Error) return new WavRecorder(); return null; }