private void OnAudioRecordingFinished_(object sender, AudioRecorder.AudioRecordingFinishEventArgs e) { if (!Settings.Default.Audio_DisableSingleWavFileRecord) { if (m_RecordAndContinue_StopSingleFileRecord) { m_RecordAndContinue_StopSingleFileRecord = false; return; } } if (m_InterruptRecording) { m_RecordAndContinue = false; m_InterruptRecording = false; checkAndAddDeferredRecordingDataItems(); if (IsMonitoringAlways) { CommandStartMonitor.Execute(); } return; } if (!String.IsNullOrEmpty(e.RecordedFilePath)) { registerRecordedAudioFileForDeferredAddition(e.RecordedFilePath); ////m_RecordAndContinue && ////!Settings.Default.Audio_EnableSkippability //if (m_RecordAndContinue) //{ //} //else //{ // openFile(e.RecordedFilePath, true, true, State.Audio.PcmFormatRecordingMonitoring); //} } if (m_RecordAndContinue) { if (!Settings.Default.Audio_DisableSingleWavFileRecord) { #if DEBUG DebugFix.Assert(IsRecording); #endif } IsAutoPlay = false; Tuple <TreeNode, TreeNode> treeNodeSelection = m_UrakawaSession.GetTreeNodeSelection(); TreeNode treeNode = treeNodeSelection.Item2 ?? treeNodeSelection.Item1; if (treeNode != null) { //TreeNode next = electNextRecordableNode(treeNode); tryNext: //TreeNode nested; //TreeNode next = TreeNode.GetNextTreeNodeWithNoSignificantTextOnlySiblings(false, treeNode, out nested); TreeNode next = TreeNode.NavigatePreviousNextSignificantText(false, treeNode); if (next != null) { TreeNode math = next.GetFirstAncestorWithXmlElement("math"); if (math != null) { next = math; } else { TreeNode svg = next.GetFirstAncestorWithXmlElement("svg"); if (svg != null) { next = svg; } else { TreeNode candidate = m_UrakawaSession.AdjustTextSyncGranularity(next, treeNode); if (candidate != null) { next = candidate; } } } if (Settings.Default.Audio_EnableSkippability && m_UrakawaSession.isTreeNodeSkippable(next)) { treeNode = next; goto tryNext; } m_StateToRestore = null; m_UrakawaSession.PerformTreeNodeSelection(next, false, null); //nested); State.Selection.ClearSelection(); //must appear after tree node selection!!! m_RecordAndContinue = false; if (!Settings.Default.Audio_DisableSingleWavFileRecord) { //RaisePropertyChanged(() => State.Audio.PcmFormatRecordingMonitoring); //if (EventAggregator != null) //{ // EventAggregator.GetEvent<StatusBarMessageUpdateEvent>().Publish(Tobi_Plugin_AudioPane_Lang.Recording); //} //PCMFormatInfo pcmFormatInfo = State.Audio.GetCurrentPcmFormat(); OnStateChanged_Recorder(null, new AudioRecorder.StateChangedEventArgs(AudioRecorder.State.Stopped)); } else { State.Audio.PcmFormatRecordingMonitoring = null; } Tuple <TreeNode, TreeNode> treeNodeSelectionNew = m_UrakawaSession.GetTreeNodeSelection(); TreeNode treeNodeNew = treeNodeSelectionNew.Item2 ?? treeNodeSelectionNew.Item1; if (treeNodeNew != null) { //#if DEBUG // DebugFix.Assert(treeNodeNew == next); //#endif //DEBUG if (treeNodeNew.GetManagedAudioMedia() == null && treeNodeNew.GetFirstDescendantWithManagedAudio() == null) { if (IsWaveFormLoading && View != null) { View.CancelWaveFormLoad(true); } if (!Settings.Default.Audio_DisableSingleWavFileRecord) { // NOOP } else { CommandStartRecord.Execute(); } return; } else { if (!Settings.Default.Audio_DisableSingleWavFileRecord) { m_RecordAndContinue_StopSingleFileRecord = true; CommandStopRecord.Execute(); } if (m_DeferredRecordingDataItems != null) { checkAndAddDeferredRecordingDataItems(); if (IsWaveFormLoading && View != null) { View.CancelWaveFormLoad(true); } m_UrakawaSession.PerformTreeNodeSelection(treeNodeSelectionNew.Item1, false, treeNodeSelectionNew.Item2); } //CommandPlay.Execute(); if (Settings.Default.Audio_Record_OverwriteFollowingAudio) { CommandSelectAll.Execute(); CommandStartRecord.Execute(); } } } else { #if DEBUG Debugger.Break(); #endif } if (IsMonitoringAlways && !IsMonitoring) { CommandStartMonitor.Execute(); } return; } } if (!Settings.Default.Audio_DisableSingleWavFileRecord) { m_RecordAndContinue_StopSingleFileRecord = true; CommandStopRecord.Execute(); } } m_RecordAndContinue = false; checkAndAddDeferredRecordingDataItems(); State.Audio.PcmFormatRecordingMonitoring = null; if (IsMonitoringAlways && !IsMonitoring) { CommandStartMonitor.Execute(); } }
private void initializeCommands_Player() { CommandPlaybackRateReset = new RichDelegateCommand( Tobi_Plugin_AudioPane_Lang.CmdAudioPlayRateReset_ShortDesc, Tobi_Plugin_AudioPane_Lang.CmdAudioPlayRateReset_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) m_ShellView.LoadGnomeGionIcon("Gion_go-previous"), () => { Logger.Log("AudioPaneViewModel.CommandPlaybackRateReset", Category.Debug, Priority.Medium); PlaybackRate = PLAYBACK_RATE_MIN; }, () => true //&& !IsWaveFormLoading , Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_ResetPlaybackRate)); m_ShellView.RegisterRichCommand(CommandPlaybackRateReset); // CommandPlaybackRateDown = new RichDelegateCommand( Tobi_Plugin_AudioPane_Lang.CmdAudioPlayRateDown_ShortDesc, Tobi_Plugin_AudioPane_Lang.CmdAudioPlayRateDown_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) m_ShellView.LoadGnomeGionIcon("Gion_go-down"), () => { Logger.Log("AudioPaneViewModel.CommandPlaybackRateDown", Category.Debug, Priority.Medium); if ((PlaybackRate - PLAYBACK_RATE_STEP) >= PLAYBACK_RATE_MIN) { PlaybackRate -= PLAYBACK_RATE_STEP; } else { PlaybackRate = PLAYBACK_RATE_MIN; Debug.Fail("This should never happen !"); } }, () => (PlaybackRate - PLAYBACK_RATE_STEP) >= PLAYBACK_RATE_MIN //&& !IsWaveFormLoading , Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_PlaybackRateDown)); m_ShellView.RegisterRichCommand(CommandPlaybackRateDown); // CommandPlaybackRateUp = new RichDelegateCommand( Tobi_Plugin_AudioPane_Lang.CmdAudioPlayRateUp_ShortDesc, Tobi_Plugin_AudioPane_Lang.CmdAudioPlayRateUp_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) m_ShellView.LoadGnomeGionIcon("Gion_go-up"), () => { Logger.Log("AudioPaneViewModel.CommandPlaybackRateUp", Category.Debug, Priority.Medium); if ((PlaybackRate + PLAYBACK_RATE_STEP) <= PLAYBACK_RATE_MAX) { PlaybackRate += PLAYBACK_RATE_STEP; } else { PlaybackRate = PLAYBACK_RATE_MAX; Debug.Fail("This should never happen !"); } }, () => (PlaybackRate + PLAYBACK_RATE_STEP) <= PLAYBACK_RATE_MAX //&& !IsWaveFormLoading , Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_PlaybackRateUp)); m_ShellView.RegisterRichCommand(CommandPlaybackRateUp); // CommandAutoPlay = new RichDelegateCommand( Tobi_Plugin_AudioPane_Lang.CmdAudioAutoPlay_ShortDesc, Tobi_Plugin_AudioPane_Lang.CmdAudioAutoPlay_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) m_ShellView.LoadTangoIcon("applications-multimedia"), () => { Logger.Log("AudioPaneViewModel.CommandAutoPlay", Category.Debug, Priority.Medium); //if (IsAutoPlay) //{ // AudioCues.PlayTock(); //} //else //{ // AudioCues.PlayTockTock(); //} IsAutoPlay = !IsAutoPlay; }, () => true //&& !IsWaveFormLoading , Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_ToggleAutoPlayMode)); m_ShellView.RegisterRichCommand(CommandAutoPlay); // // CommandPause = new RichDelegateCommand( Tobi_Plugin_AudioPane_Lang.CmdAudioPause_ShortDesc, Tobi_Plugin_AudioPane_Lang.CmdAudioPause_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) m_ShellView.LoadTangoIcon("media-playback-pause"), () => { Logger.Log("AudioPaneViewModel.CommandPause", Category.Debug, Priority.Medium); m_PlayAutoAdvance = false; SetRecordAfterPlayOverwriteSelection(-1); long playBytePosition = PlayBytePosition; m_Player.Stop(); SetPlayHeadTimeBypassAutoPlay(playBytePosition); if (EventAggregator != null) { EventAggregator.GetEvent <StatusBarMessageUpdateEvent>().Publish(Tobi_Plugin_AudioPane_Lang.PlaybackStopped); } if (IsMonitoringAlways) { CommandStartMonitor.Execute(); } }, () => State.Audio.HasContent && IsPlaying //&& !IsWaveFormLoading , Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_PlayPause)); m_ShellView.RegisterRichCommand(CommandPause); // CommandPlay = new RichDelegateCommand( Tobi_Plugin_AudioPane_Lang.CmdAudioPlay_ShortDesc, Tobi_Plugin_AudioPane_Lang.CmdAudioPlay_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) m_ShellView.LoadTangoIcon("media-playback-start"), () => { Logger.Log("AudioPaneViewModel.CommandPlay", Category.Debug, Priority.Medium); CommandPause.Execute(); if (IsMonitoring) { CommandStopMonitor.Execute(); } //#if DEBUG // Logger.Log("AudioPaneViewModel.CommandPlay (called PAUSE)", Category.Debug, Priority.Medium); //#endif if (PlayBytePosition < 0) { m_LastSetPlayBytePosition = 0; } if (!IsSelectionSet) { //if (LastPlayHeadTime >= State.Audio.ConvertBytesToMilliseconds(State.Audio.DataLength)) if (PlayBytePosition >= State.Audio.DataLength) { if (Settings.Default.Audio_DisableAutoJumpToBegin_AtEndOfPlayback) { //m_LastSetPlayBytePosition = State.Audio.DataLength; //PlayBytePosition = State.Audio.DataLength; AudioCues.PlayBeep(); } else { //LastPlayHeadTime = 0; infinite loop ! AudioPlayer_PlayFromTo(0, -1); } } else { AudioPlayer_PlayFromTo(PlayBytePosition, -1); } } else { if (false && PlayBytePosition >= State.Selection.SelectionBeginBytePosition && PlayBytePosition < State.Selection.SelectionEndBytePosition) { //if (verifyBeginEndPlayerValues(byteLastPlayHeadTime, byteSelectionRight)) //{ //} AudioPlayer_PlayFromTo(PlayBytePosition, State.Selection.SelectionEndBytePosition); } else { //if (verifyBeginEndPlayerValues(byteSelectionLeft, byteSelectionRight)) //{ //} AudioPlayer_PlayFromTo(State.Selection.SelectionBeginBytePosition, State.Selection.SelectionEndBytePosition); } } }, () => State.Audio.HasContent && !IsPlaying && (!IsMonitoring || IsMonitoringAlways) && !IsRecording //&& !IsWaveFormLoading , Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_PlayPause)); m_ShellView.RegisterRichCommand(CommandPlay); // CommandPlayAutoAdvance = new RichDelegateCommand( Tobi_Plugin_AudioPane_Lang.CmdAudioPlayAutoAdvance_ShortDesc, Tobi_Plugin_AudioPane_Lang.CmdAudioPlayAutoAdvance_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) m_ShellView.LoadGnomeGionIcon("applications-multimedia"), //emblem-system () => { Logger.Log("AudioPaneViewModel.CommandPlayAutoAdvance", Category.Debug, Priority.Medium); m_PlayAutoAdvance = true; CommandPlay.Execute(); }, () => CommandPlay.CanExecute(), Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_PlayAutoAdvance)); m_ShellView.RegisterRichCommand(CommandPlayAutoAdvance); // CommandPlayPreviewLeft = new RichDelegateCommand( Tobi_Plugin_AudioPane_Lang.CmdAudioPlayPreviewLeft_ShortDesc, Tobi_Plugin_AudioPane_Lang.CmdAudioPlayPreviewLeft_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) ScalableGreyableImageProvider.ConvertIconFormat((DrawingImage)Application.Current.FindResource("Horizon_Image_Left")), () => PlayPreviewLeftRight(true), () => CommandPlay.CanExecute(), Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_PlayLeftPreview)); m_ShellView.RegisterRichCommand(CommandPlayPreviewLeft); // CommandPlayPreviewRight = new RichDelegateCommand( Tobi_Plugin_AudioPane_Lang.CmdAudioPlayPreviewRight_ShortDesc, Tobi_Plugin_AudioPane_Lang.CmdAudioPlayPreviewRight_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) ScalableGreyableImageProvider.ConvertIconFormat((DrawingImage)Application.Current.FindResource("Horizon_Image_Right")), () => PlayPreviewLeftRight(false), () => CommandPlay.CanExecute(), Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_PlayRightPreview)); m_ShellView.RegisterRichCommand(CommandPlayPreviewRight); // }
//#endif private void initializeCommands_Recorder() { Stopwatch stopWatchRecorder = null; CommandStopRecordAndContinue = new RichDelegateCommand( Tobi_Plugin_AudioPane_Lang.CmdAudioStopRecordAndContinue_ShortDesc, Tobi_Plugin_AudioPane_Lang.CmdAudioStopRecordAndContinue_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) m_ShellView.LoadTangoIcon("start-here"), //weather-clear-night -- emblem-symbolic-link () => { Logger.Log("AudioPaneViewModel.CommandStopRecordAndContinue", Category.Debug, Priority.Medium); if (stopWatchRecorder != null) { stopWatchRecorder.Stop(); if (stopWatchRecorder.ElapsedMilliseconds <= 100) { Console.WriteLine("stopWatchRecorder.ElapsedMilliseconds<=100, skipping stop record"); stopWatchRecorder.Start(); return; } Console.WriteLine("stopWatchRecorder.ElapsedMilliseconds, elapsed record :" + stopWatchRecorder.ElapsedMilliseconds); } stopWatchRecorder = null; IsAutoPlay = false; m_RecordAndContinue = true; m_InterruptRecording = false; if (!Settings.Default.Audio_DisableSingleWavFileRecord) { m_RecordAndContinue_StopBytePos = (long)m_Recorder.CurrentDurationBytePosition_BufferLookAhead; OnAudioRecordingFinished(null, new AudioRecorder.AudioRecordingFinishEventArgs( m_Recorder.RecordedFilePath)); } else { m_Recorder.StopRecording(); if (EventAggregator != null) { EventAggregator.GetEvent <StatusBarMessageUpdateEvent>().Publish(Tobi_Plugin_AudioPane_Lang.RecordingStopped); } } //ENABLE_SINGLE_RECORD_FILE }, () => { //Tuple<TreeNode, TreeNode> treeNodeSelection = m_UrakawaSession.GetTreeNodeSelection(); return(!IsWaveFormLoading && IsRecording && m_UrakawaSession.DocumentProject != null); }, Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_StopRecordAndContinue)); m_ShellView.RegisterRichCommand(CommandStopRecordAndContinue); // CommandStopRecord = new RichDelegateCommand( Tobi_Plugin_AudioPane_Lang.CmdAudioStopRecord_ShortDesc, Tobi_Plugin_AudioPane_Lang.CmdAudioStopRecord_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) m_ShellView.LoadTangoIcon("media-playback-stop"), () => { Logger.Log("AudioPaneViewModel.CommandStopRecord", Category.Debug, Priority.Medium); if (stopWatchRecorder != null) { stopWatchRecorder.Stop(); if (stopWatchRecorder.ElapsedMilliseconds <= 50) { Console.WriteLine("stopWatchRecorder.ElapsedMilliseconds<=50, skipping stop record"); stopWatchRecorder.Start(); return; } Console.WriteLine("stopWatchRecorder.ElapsedMilliseconds, elapsed record :" + stopWatchRecorder.ElapsedMilliseconds); } stopWatchRecorder = null; m_RecordAndContinue = false; m_Recorder.StopRecording(); if (EventAggregator != null) { EventAggregator.GetEvent <StatusBarMessageUpdateEvent>().Publish(Tobi_Plugin_AudioPane_Lang.RecordingStopped); } if (IsMonitoringAlways) { CommandStartMonitor.Execute(); } }, () => !IsWaveFormLoading && IsRecording, Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_StartStopRecord)); m_ShellView.RegisterRichCommand(CommandStopRecord); // CommandStartRecord = new RichDelegateCommand( Tobi_Plugin_AudioPane_Lang.CmdAudioStartRecord_ShortDesc, Tobi_Plugin_AudioPane_Lang.CmdAudioStartRecord_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) m_ShellView.LoadTangoIcon("media-record"), () => { Logger.Log("AudioPaneViewModel.CommandStartRecord", Category.Debug, Priority.Medium); m_RecordAndContinue_StopBytePos = -1; if (stopWatchRecorder != null) { Console.WriteLine("stopWatchRecorder != null, skipping start record"); return; } if (IsMonitoring) { CommandStopMonitor.Execute(); } IsAutoPlay = false; bool allowPlayPreview = false; m_punchInRecordOverSelection = false; if (IsPlaying) // Punch-in recording { SetRecordAfterPlayOverwriteSelection(-1); m_punchInRecordOverSelection = true; CommandPause.Execute(); CommandSelectRight.Execute(); } else if (Settings.Default.Audio_Record_OverwriteFollowingAudio && !IsSelectionSet) { SetRecordAfterPlayOverwriteSelection(-1); m_punchInRecordOverSelection = true; if (PlayBytePosition >= 0) { allowPlayPreview = true; CommandSelectRight.Execute(); } else { CommandSelectAll.Execute(); } } if (IsWaveFormLoading && View != null) { View.CancelWaveFormLoad(true); } m_RecordAndContinue = false; if (m_UrakawaSession.DocumentProject == null) { SetRecordAfterPlayOverwriteSelection(-1); State.ResetAll(); State.Audio.PcmFormatRecordingMonitoring = new PCMFormatInfo(); } else { Tuple <TreeNode, TreeNode> treeNodeSelection = m_UrakawaSession.GetTreeNodeSelection(); if (treeNodeSelection.Item1 == null) { SetRecordAfterPlayOverwriteSelection(-1); return; } if (!m_punchInRecordOverSelection || allowPlayPreview) // let's check auto punch in/out based on audio selection { var bytesForRequiredOffsetTime = m_UrakawaSession.DocumentProject.Presentations.Get(0).MediaDataManager.DefaultPCMFormat. Data.ConvertTimeToBytes(150 * AudioLibPCMFormat.TIME_UNIT); if (State.Selection.SelectionBeginBytePosition > 0 && PlayBytePosition >= 0 && PlayBytePosition < State.Selection.SelectionBeginBytePosition - bytesForRequiredOffsetTime) { AudioPlayer_PlayFromTo(PlayBytePosition, State.Selection.SelectionBeginBytePosition); SetRecordAfterPlayOverwriteSelection(State.Selection.SelectionBeginBytePosition); return; } else if (Settings.Default.Audio_EnablePlayPreviewBeforeRecord && m_RecordAfterPlayOverwriteSelection < 0 && PlayBytePosition > 0) { var playbackStartBytePos = m_UrakawaSession.DocumentProject.Presentations.Get(0).MediaDataManager.DefaultPCMFormat. Data.ConvertTimeToBytes((long)Settings.Default.AudioWaveForm_PlayPreviewTimeStep * 2 * AudioLibPCMFormat.TIME_UNIT); playbackStartBytePos = PlayBytePosition - playbackStartBytePos; if (playbackStartBytePos < 0) { playbackStartBytePos = 0; } SetRecordAfterPlayOverwriteSelection(State.Selection.SelectionBeginBytePosition > 0 ? State.Selection.SelectionBeginBytePosition : PlayBytePosition); AudioPlayer_PlayFromTo(playbackStartBytePos, PlayBytePosition); return; } SetRecordAfterPlayOverwriteSelection(-1); } DebugFix.Assert(m_UrakawaSession.DocumentProject.Presentations.Get(0).MediaDataManager.EnforceSinglePCMFormat); State.Audio.PcmFormatRecordingMonitoring = m_UrakawaSession.DocumentProject.Presentations.Get(0).MediaDataManager.DefaultPCMFormat; } OnSettingsPropertyChanged(this, new PropertyChangedEventArgs(GetMemberName(() => Settings.Default.Audio_InputDevice))); stopWatchRecorder = Stopwatch.StartNew(); m_Recorder.StartRecording(State.Audio.PcmFormatRecordingMonitoring.Copy().Data); RaisePropertyChanged(() => State.Audio.PcmFormatRecordingMonitoring); if (EventAggregator != null) { EventAggregator.GetEvent <StatusBarMessageUpdateEvent>().Publish(Tobi_Plugin_AudioPane_Lang.Recording); } }, () => { return((!IsMonitoring || IsMonitoringAlways) && !IsRecording && !IsWaveFormLoading && //!IsPlaying && canDeleteInsertReplaceAudio()); }, Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_StartStopRecord)); m_ShellView.RegisterRichCommand(CommandStartRecord); // // CommandStopMonitor = new RichDelegateCommand( Tobi_Plugin_AudioPane_Lang.CmdAudioStopMonitor_ShortDesc, Tobi_Plugin_AudioPane_Lang.CmdAudioStopMonitor_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) m_ShellView.LoadTangoIcon("media-playback-stop"), () => { Logger.Log("AudioPaneViewModel.CommandStopMonitor", Category.Debug, Priority.Medium); m_Recorder.StopRecording(); //AudioCues.PlayTockTock(); if (EventAggregator != null) { EventAggregator.GetEvent <StatusBarMessageUpdateEvent>().Publish(Tobi_Plugin_AudioPane_Lang.MonitoringStopped); } State.Audio.PcmFormatRecordingMonitoring = null; }, () => !IsWaveFormLoading && IsMonitoring, Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_StartStopMonitor)); m_ShellView.RegisterRichCommand(CommandStopMonitor); // CommandStartMonitor = new RichDelegateCommand( Tobi_Plugin_AudioPane_Lang.CmdAudioStartMonitor_ShortDesc, Tobi_Plugin_AudioPane_Lang.CmdAudioStartMonitor_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) m_ShellView.LoadTangoIcon("audio-input-microphone"), () => { Logger.Log("AudioPaneViewModel.CommandStartMonitor", Category.Debug, Priority.Medium); m_RecordAndContinue_StopBytePos = -1; // to avoid display of m_RecordAndContinue time stamp IsAutoPlay = false; if (m_UrakawaSession.DocumentProject == null) { State.ResetAll(); State.Audio.PcmFormatRecordingMonitoring = new PCMFormatInfo(); //m_PcmFormatOfAudioToInsert = IsAudioLoaded ? State.Audio.PcmFormat : new PCMFormatInfo(); //m_Recorder.InputDevice.Capture.Caps.Format44KhzMono16Bit } else { DebugFix.Assert(m_UrakawaSession.DocumentProject.Presentations.Get(0).MediaDataManager.EnforceSinglePCMFormat); State.Audio.PcmFormatRecordingMonitoring = m_UrakawaSession.DocumentProject.Presentations.Get(0).MediaDataManager.DefaultPCMFormat; } OnSettingsPropertyChanged(this, new PropertyChangedEventArgs(GetMemberName(() => Settings.Default.Audio_InputDevice))); //AudioCues.PlayTock(); m_Recorder.StartMonitoring(State.Audio.PcmFormatRecordingMonitoring.Copy().Data); RaisePropertyChanged(() => State.Audio.PcmFormatRecordingMonitoring); if (EventAggregator != null) { EventAggregator.GetEvent <StatusBarMessageUpdateEvent>().Publish(Tobi_Plugin_AudioPane_Lang.Monitoring); } }, () => !IsWaveFormLoading && !IsPlaying && !IsRecording && !IsMonitoring, Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_StartStopMonitor)); m_ShellView.RegisterRichCommand(CommandStartMonitor); // CommandTogglePlayPreviewBeforeRecord = new RichDelegateCommand( Tobi_Plugin_AudioPane_Lang.CmdAudioTogglePlayPreviewBeforeRecord_ShortDesc, Tobi_Plugin_AudioPane_Lang.CmdAudioTogglePlayPreviewBeforeRecord_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) m_ShellView.LoadGnomeGionIcon("Gion_music-player"), () => { Settings.Default.Audio_EnablePlayPreviewBeforeRecord = !Settings.Default.Audio_EnablePlayPreviewBeforeRecord; RaisePropertyChanged(() => RecordPlayPreviewString); if (EventAggregator != null) { EventAggregator.GetEvent <StatusBarMessageUpdateEvent>().Publish(RecordPlayPreviewString //Tobi_Plugin_AudioPane_Lang.AudioRecordPlayPreview + (Settings.Default.Audio_EnablePlayPreviewBeforeRecord ? " [ON]" : " [OFF]") ); } }, () => true, Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_TogglePlayPreviewBeforeRecord)); m_ShellView.RegisterRichCommand(CommandTogglePlayPreviewBeforeRecord); // CommandToggleRecordOverwrite = new RichDelegateCommand( Tobi_Plugin_AudioPane_Lang.CmdAudioToggleRecordOverwrite_ShortDesc, Tobi_Plugin_AudioPane_Lang.CmdAudioToggleRecordOverwrite_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) null, //m_ShellView.LoadGnomeGionIcon("Gion_music-player"), () => { Settings.Default.Audio_Record_OverwriteFollowingAudio = !Settings.Default.Audio_Record_OverwriteFollowingAudio; RaisePropertyChanged(() => RecordOverwriteString); if (EventAggregator != null) { EventAggregator.GetEvent <StatusBarMessageUpdateEvent>().Publish(RecordOverwriteString //Tobi_Plugin_AudioPane_Lang.AudioRecordOverwrite + (Settings.Default.Audio_Record_OverwriteFollowingAudio ? " [ON]" : " [OFF]") ); } }, () => true, Settings_KeyGestures.Default, null //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_TogglePlayPreviewBeforeRecord) ); m_ShellView.RegisterRichCommand(CommandToggleRecordOverwrite); // CommandToggleSelectAfterRecord = new RichDelegateCommand( Tobi_Plugin_AudioPane_Lang.CmdAudioToggleSelectAfterRecord_ShortDesc, Tobi_Plugin_AudioPane_Lang.CmdAudioToggleSelectAfterRecord_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) null, //m_ShellView.LoadGnomeGionIcon("Gion_music-player"), () => { Settings.Default.Audio_DisableAfterRecordSelection = !Settings.Default.Audio_DisableAfterRecordSelection; RaisePropertyChanged(() => SelectAfterRecordString); if (EventAggregator != null) { EventAggregator.GetEvent <StatusBarMessageUpdateEvent>().Publish(SelectAfterRecordString //Tobi_Plugin_AudioPane_Lang.AudioSelectAfterRecord + (Settings.Default.Audio_DisableSelectAfterRecord ? " [OFF]" : " [ON]") ); } }, () => true, Settings_KeyGestures.Default, null //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_TogglePlayPreviewBeforeRecord) ); m_ShellView.RegisterRichCommand(CommandToggleSelectAfterRecord); }
private void OnAudioPlaybackFinished_(object sender, AudioPlayer.AudioPlaybackFinishEventArgs e) { bool gotoNext = State.Audio.EndOffsetOfPlayStream == State.Audio.DataLength && (IsAutoPlay || m_PlayAutoAdvance) && !IsSelectionSet && m_UrakawaSession.DocumentProject != null; //Logger.Log("AudioPaneViewModel.OnAudioPlaybackFinished", Category.Debug, Priority.Medium); if (State.Audio.HasContent) { SetPlayHeadTimeBypassAutoPlay(State.Audio.EndOffsetOfPlayStream); //updateWaveFormPlayHead(time); } if (gotoNext) { OnAudioPlaybackFinished_RefreshStatus(); Tuple <TreeNode, TreeNode> treeNodeSelection = m_UrakawaSession.GetTreeNodeSelection(); TreeNode nextNode = treeNodeSelection.Item1.GetNextSiblingWithManagedAudio(); next: if (nextNode != null) { if (Settings.Default.Audio_EnableSkippability && m_UrakawaSession.isTreeNodeSkippable(nextNode)) { nextNode = nextNode.GetNextSiblingWithManagedAudio(); goto next; } if (IsWaveFormLoading) { if (View != null) { View.CancelWaveFormLoad(true); } } //Logger.Log("-- PublishEvent [TreeNodeSelectedEvent] AudioPaneViewModel.OnAudioPlaybackFinished", Category.Debug, Priority.Medium); //EventAggregator.GetEvent<TreeNodeSelectedEvent>().Publish(nextNode); m_UrakawaSession.PerformTreeNodeSelection(nextNode); } else { m_PlayAutoAdvance = false; if (IsMonitoringAlways) { CommandStartMonitor.Execute(); } } } else { m_PlayAutoAdvance = false; if (m_RecordAfterPlayOverwriteSelection > 0) // && State.Selection.SelectionBeginBytePosition == m_RecordAfterPlayOverwriteSelection) { SetRecordAfterPlayOverwriteSelection(-1); m_RecordAfterPlayOverwriteSelection = 1; // hack CommandStartRecord.Execute(); m_RecordAfterPlayOverwriteSelection = -1; // hack } else { OnAudioPlaybackFinished_RefreshStatus(); if (IsMonitoringAlways) { CommandStartMonitor.Execute(); } } } }