/// <summary> /// Initializes the Recorder. /// Invokes "FileFormatUpdated" and "RecordingQualityUpdated" to other application's modules. /// </summary> public void Init() { var bitrateType = AudioBitRateType.Medium; var fileFormat = FileFormatType.MP4; try { Directory.CreateDirectory(PATH_TO_RECORDINGS); var formatCodec = FILE_FORMATS_DICTIONARY[fileFormat]; _recorder = new AudioRecorder(formatCodec.Item2, formatCodec.Item1) { AudioBitRate = RECORDING_QUALITY_DICTIONARY[bitrateType], AudioChannels = (int)AudioChannelType.Stereo }; _recorder.Prepare(); } catch (Exception exception) { ErrorHandler(exception.Message); return; } FileFormatUpdated?.Invoke(this, fileFormat); RecordingQualityUpdated?.Invoke(this, bitrateType); }
/// <summary> /// Initializes the Recorder. /// Invokes "FileFormatUpdated" and "RecordingQualityUpdated" to other application's modules. /// </summary> public void Init() { try { Directory.CreateDirectory(PATH_TO_RECORDINGS); _recorder = new AudioRecorder(RecorderAudioCodec.Pcm, RecorderFileFormat.Wav) { AudioBitRate = RECORDING_QUALITY_DICTIONARY[AudioBitRateType.High], AudioChannels = (int)AudioChannelType.Stereo }; _recorder.Prepare(); } catch (Exception exception) { ErrorHandler(exception.Message); return; } FileFormatUpdated?.Invoke(this, FileFormatType.WAV); RecordingQualityUpdated?.Invoke(this, AudioBitRateType.High); }
/// <summary> /// Updates the Recorder file format and codec. /// Invokes "FileFormatUpdated" to other application's modules. /// </summary> /// <param name="item">Setting new value indicator.</param> public void UpdateRecorderFileFormat(FileFormatType item) { var oldCodec = _recorder.AudioCodec; var oldFileFormat = _recorder.FileFormat; try { _recorder.Unprepare(); _recorder.SetFormatAndCodec(FILE_FORMATS_DICTIONARY[item].Item2, FILE_FORMATS_DICTIONARY[item].Item1); _recorder.Prepare(); } catch (Exception exception) { _recorder.SetFormatAndCodec(oldCodec, oldFileFormat); _recorder.Prepare(); ErrorHandler(exception.Message); return; } FileFormatUpdated?.Invoke(this, item); }
/// <summary> /// Handles "FileFormatUpdated" of the IVoiceRecorderService object. /// Invokes "FileFormatUpdated" to other application's modules. /// </summary> /// <param name="sender">Instance of the VoiceRecorderService class.</param> /// <param name="newValue">New value of the recorder file format setting.</param> private void FileFormatUpdatedEventHandler(object sender, FileFormatType newValue) { FileFormatUpdated?.Invoke(sender, newValue); }