/// ------------------------------------------------------------------------------------ public void InitializeAnnotationRecorder(PeakMeterCtrl peakMeter, RecordingDeviceIndicator recordingDeviceIndicator, Action <TimeSpan> recordingProgressAction) { try { Recorder = new OralAnnotationRecorder(peakMeter, recordingProgressAction); } catch { return; } _recordingDeviceIndicator = recordingDeviceIndicator; if (_recordingDeviceIndicator != null) { _recordingDeviceIndicator.Recorder = Recorder; } Recorder.RecordingStarted += (s, e) => InvokeUpdateDisplayAction(); Recorder.Stopped += (sender, args) => { if (args != null && RecordingErrorAction != null) { RecordingErrorAction(args.GetException()); } AnnotationRecordingFinished(args != null); InvokeUpdateDisplayAction(); }; Recorder.SelectedDeviceChanged += SelectedRecordingDeviceChanged; Recorder.BeginMonitoring(); }
/// ------------------------------------------------------------------------------------ public SessionRecorderDlg(SessionRecorderDlgViewModel viewModel) : this() { if (_moreReliableDesignMode) { return; } _viewModel = viewModel; _viewModel.UpdateAction += delegate { if (InvokeRequired) { BeginInvoke((Action)UpdateDisplay); return; } UpdateDisplay(); }; _viewModel.Recorder.PeakLevelChanged += ((s, e) => _peakMeter.PeakLevel = e.Level); _viewModel.Recorder.RecordingProgress += HandleRecorderProgress; _peakMeter = AudioUtils.CreatePeakMeterControl(_panelPeakMeter); SetupRecordingDeviceButton(); LocalizeItemDlg.StringsLocalized += HandleStringsLocalized; }
/// ------------------------------------------------------------------------------------ public OralAnnotationRecorder(PeakMeterCtrl peakMeter, Action <TimeSpan> recordingProgressAction) : base(20) { RecordingFormat = AudioUtils.GetDefaultWaveFormat(1); SelectedDevice = RecordingDevice.Devices.First(); _peakMeterCtrl = peakMeter; _recordingProgressAction = recordingProgressAction; RecordingProgress += (s, e) => _recordingProgressAction(e.RecordedLength); PeakLevelChanged += (s, e) => { if (_peakMeterCtrl != null) { _peakMeterCtrl.PeakLevel = e.Level; } }; }
/// ------------------------------------------------------------------------------------ public static PeakMeterCtrl CreatePeakMeterControl(Control owningCtrl) { var peakMeter = new PeakMeterCtrl { BandsCount = 1, LEDCount = 12, FalloffSpeed = 7, ShowGrid = false, BackColor = owningCtrl.BackColor, ColorMedium = Settings.Default.BarColorBorder, ColorNormal = Settings.Default.BarColorEnd, ColorHigh = Color.FromArgb(215, 2, 0), Dock = DockStyle.Fill, }; owningCtrl.Controls.Add(peakMeter); peakMeter.SetRange(10, 40, 50); peakMeter.Start(33); //the number here is how often it updates return(peakMeter); }