Пример #1
0
 public void startRecording()
 {
     if (recorder.State != IRecorderState.Paused)
     {
         xml = new XmlIlyaFrankAbook();
     }
     //startSegment();
 }
Пример #2
0
        //private List<XmlWavEvent> pendingRussian;

        public LogicShit(AudioRecManager recMan)
        {
            this.recMan    = recMan;
            FilenameFormat = DumpFolder + "/segment_{0}.wav";

            #region FSM with XML

            fsmWithXml = new FSM <Keys>()
                         .addNode_0_(LogicState.Ready)
                         .addEdge___(Keys.Enter, LogicState.DeqedLang1, (args) => {
                IlyaXml = new XmlIlyaFrankAbook()
                {
                    Lang1Mp3Filename = Lang1Mp3,
                    Lang1Prefix      = AudioBooker.classes.UtilsCore.GetFullPathWithoutExtension(Lang1Mp3)
                };
                new_paragraph();
                nextLang1Phrase();
                readCurLang1Phrase();
                FireHandler(CurParagraphUpdated);
            })
                         .addNode_0_(LogicState.DeqedLang1)
                         .addEdge___(Keys.R, LogicState.DeqedLang1, (args) => readCurLang1Phrase())
                         .addEdge___(Keys.P, LogicState.DeqedLang1, (args) => {
                purgeParaAllExceptLast();
                FireHandler(CurParagraphUpdated);
            })
                         .addEdge___(Keys.Space, LogicState.Recording1st, (args) => {
                startSegment();
                FireHandler(CurSegmentUpdated);
                FireHandler(CurParagraphUpdated);
            })
                         .addNode_0_(LogicState.Recording1st)
                         .addEdge___(Keys.R, LogicState.Recording1st, (args) => readCurLang1Phrase())
                         .addEdge___(Keys.P, LogicState.DeqedLang1, (args) => {
                purgeParaAllExceptLast();
                stopAndDeleteSegment();
                FireHandler(CurSegmentUpdated);
                FireHandler(CurParagraphUpdated);
            })
                         .addEdge___(Keys.Back, LogicState.Recording1st, (args) => {
                stopAndDeleteSegment();
                startSegment();
                FireHandler(CurSegmentUpdated);
            })
                         .addEdge___(Keys.Space, LogicState.RecordingMore, (args) => {
                commitSegment();
                startSegment();
                FireHandler(CurParagraphUpdated);
                FireHandler(CurSegmentUpdated);
            })
                         .addNode_0_(LogicState.RecordingMore)
                         .addEdge___(Keys.R, LogicState.RecordingMore, (args) => readCurLang1Phrase())
                         .addEdge___(Keys.Back, LogicState.RecordingMore, (args) => {
                stopAndDeleteSegment();
                startSegment();
                FireHandler(CurSegmentUpdated);
            })
                         .addEdge___(Keys.Space, LogicState.RecordingMore, (args) => {
                commitSegment();
                startSegment();
                FireHandler(CurParagraphUpdated);
                FireHandler(CurSegmentUpdated);
            })
                         .addEdge___(Keys.D1, LogicState.RecordingMore, (args) => {
                stopAndDeleteSegment();
                RecordedSegments = CurIlyaSentence.Lang1Segments;
                startSegment();
                FireHandler(CurParagraphUpdated);
                FireHandler(CurSegmentUpdated);
            })
                         .addEdge___(Keys.D2, LogicState.RecordingMore, (args) => {
                stopAndDeleteSegment();
                RecordedSegments = CurIlyaSentence.Lang2Segments;
                startSegment();
                FireHandler(CurParagraphUpdated);
                FireHandler(CurSegmentUpdated);
            })
                         .addEdge___(Keys.Enter, LogicState.DeqedLang1, (args) => {
                stopAndDeleteSegment();
                nextLang1Phrase();
                readCurLang1Phrase();
                FireHandler(CurSegmentUpdated);
                FireHandler(CurParagraphUpdated);
            })
                         .addEdge___(Keys.P, LogicState.CommitedParagraph, (args) => {
                stopAndDeleteSegment();
                new_paragraph();
                FireHandler(CurSegmentUpdated);
                FireHandler(CurParagraphUpdated);
            })
                         .addNode_0_(LogicState.CommitedParagraph)
                         .addEdge___(Keys.Enter, LogicState.DeqedLang1, (args) => {
                nextLang1Phrase();
                readCurLang1Phrase();
                FireHandler(CurSegmentUpdated);
                FireHandler(CurParagraphUpdated);
            })
            ;
            fsmWithXml.Reset();

            #endregion

            #region FSM manual split

            fsmManualSplit = new FSM <Keys>()
                             .addNode_0_(LogicState.Ready)
                             .addEdge___(Keys.Enter, LogicState.DeqingLang1, (args) => {
                IlyaXml = new XmlIlyaFrankAbook()
                {
                    Lang1Mp3Filename = Path.GetFileName(Lang1Mp3),
                    Lang1Prefix      = Path.GetDirectoryName(Lang1Mp3)
                };
                new_paragraph();
                AudioPlaya = new AudioPlaya(Lang1Mp3);
                AudioPlaya.Play();
            })
                             .addNode_0_(LogicState.DeqingLang1)
                             .addEdge___(Keys.OemPeriod, LogicState.DeqingLang1, (args) => {
                AudioPlaya.Pause();
                AudioPlaya.Position += TimeSpan.FromSeconds(5);
                AudioPlaya.Play();
            })
                             .addEdge___(Keys.Oemcomma, LogicState.DeqingLang1, (args) => {
                AudioPlaya.Pause();
                AudioPlaya.Position -= TimeSpan.FromSeconds(5);
                AudioPlaya.Play();
            })
                             .addEdge___(Keys.Space, LogicState.DeqingLang1, (args) => {
                ManualSegmentA = AudioPlaya.Position;
            })
                             .addEdge___(Keys.Enter, LogicState.DeqedLang1, (args) => {
                ManualSegmentB = AudioPlaya.Position;
                AudioPlaya.Pause();
                nextLang1Phrase_manual();
                readCurLang1Phrase();
                FireHandler(CurParagraphUpdated);
            })
                             .addNode_0_(LogicState.DeqedLang1)
                             .addEdge___(Keys.R, LogicState.DeqedLang1, (args) => readCurLang1Phrase())
                             .addEdge___(Keys.P, LogicState.DeqedLang1, (args) => {
                purgeParaAllExceptLast();
                FireHandler(CurParagraphUpdated);
            })
                             .addEdge___(Keys.Space, LogicState.Recording1st, (args) => {
                startSegment();
                FireHandler(CurSegmentUpdated);
                FireHandler(CurParagraphUpdated);
            })
                             .addNode_0_(LogicState.Recording1st)
                             .addEdge___(Keys.R, LogicState.Recording1st, (args) => readCurLang1Phrase())
                             .addEdge___(Keys.P, LogicState.DeqedLang1, (args) => {
                purgeParaAllExceptLast();
                stopAndDeleteSegment();
                FireHandler(CurSegmentUpdated);
                FireHandler(CurParagraphUpdated);
            })
                             .addEdge___(Keys.Back, LogicState.Recording1st, (args) => {
                stopAndDeleteSegment();
                startSegment();
                FireHandler(CurSegmentUpdated);
            })
                             .addEdge___(Keys.Space, LogicState.RecordingMore, (args) => {
                commitSegment();
                startSegment();
                FireHandler(CurParagraphUpdated);
                FireHandler(CurSegmentUpdated);
            })
                             .addNode_0_(LogicState.RecordingMore)
                             .addEdge___(Keys.R, LogicState.RecordingMore, (args) => readCurLang1Phrase())
                             .addEdge___(Keys.Back, LogicState.RecordingMore, (args) => {
                stopAndDeleteSegment();
                startSegment();
                FireHandler(CurSegmentUpdated);
            })
                             .addEdge___(Keys.Space, LogicState.RecordingMore, (args) => {
                commitSegment();
                startSegment();
                FireHandler(CurParagraphUpdated);
                FireHandler(CurSegmentUpdated);
            })
                             .addEdge___(Keys.D1, LogicState.RecordingMore, (args) => {
                stopAndDeleteSegment();
                RecordedSegments = CurIlyaSentence.Lang1Segments;
                startSegment();
                FireHandler(CurParagraphUpdated);
                FireHandler(CurSegmentUpdated);
            })
                             .addEdge___(Keys.D2, LogicState.RecordingMore, (args) => {
                stopAndDeleteSegment();
                RecordedSegments = CurIlyaSentence.Lang2Segments;
                startSegment();
                FireHandler(CurParagraphUpdated);
                FireHandler(CurSegmentUpdated);
            })
                             .addEdge___(Keys.Enter, LogicState.DeqingLang1, (args) => {
                stopAndDeleteSegment();
                ManualSegmentA = AudioPlaya.Position;
                AudioPlaya.Play();
                FireHandler(CurSegmentUpdated);
                FireHandler(CurParagraphUpdated);
            })
                             .addEdge___(Keys.P, LogicState.CommitedParagraph, (args) => {
                stopAndDeleteSegment();
                new_paragraph();
                FireHandler(CurSegmentUpdated);
                FireHandler(CurParagraphUpdated);
            })
                             .addNode_0_(LogicState.CommitedParagraph)
                             .addEdge___(Keys.Enter, LogicState.DeqingLang1, (args) => {
                ManualSegmentA = AudioPlaya.Position;
                AudioPlaya.Play();
                FireHandler(CurSegmentUpdated);
                FireHandler(CurParagraphUpdated);
            })
            ;
            fsmManualSplit.Reset();

            #endregion
        }