Пример #1
0
 public BookGapFormatModel(BookFileModel model, Book book, GapFormat gap)
     : base(gap)
 {
     this.BookFileModel = model;
     this.Book          = book;
     this.RaisePropertyChanged("BookName");
     this.RaisePropertyChanged("BookNumber");
     this.RaisePropertyChanged("VerseCount");
 }
        public void GapGen()
        {
            foreach (FileModel model in this.ImportBibleSubViewModel.SelectedFiles)
            {
                using (Stream stream = File.OpenRead(model.FullPath))
                {
                    Waveformat pcm;
                    if (DecoderServices.AudioDecoderRegisterService.TryDecode(out pcm, stream))
                    {
                        GapFormat gap  = GapFormat.CreateFrom(pcm, this.Threshold, this.MinPause);
                        Book      book = this.ImportBibleTextSubViewModel.BookList.Where(b => b.Name == model.ExpectedName).Select(b => b.Book).FirstOrDefault();

                        GapFormatModel gModel = null;
                        if (model is ChapterFileModel)
                        {
                            gModel = new ChapterGapFormatModel((ChapterFileModel)model, book, gap);
                        }
                        else if (model is BookFileModel)
                        {
                            gModel = new BookGapFormatModel((BookFileModel)model, book, gap);
                        }

                        if (gModel != null)
                        {
                            App.Current.Dispatcher.Invoke(() => this.GapList.Add(gModel));
                        }
                    }
                    stream.Close();
                }

                GC.Collect();
                GC.Collect();
            }

            GC.Collect();
            GC.Collect();
        }
Пример #3
0
 public GapFormatModel(GapFormat gap)
 {
     this.GapFormat = gap;
     this.RaisePropertyChanged("PauseCount");
 }
Пример #4
0
        static void GapTestCommand(IEnumerable <string> input)
        {
            if (input.Count() != 1)
            {
                ErrorWriteLine("Invalid arguments provided");
                return;
            }

            Console.WriteLine("\n[Gap Test]");

            string path = dir.FullName + "\\" + input.ElementAt(0);

            if (File.Exists(path))
            {
                Waveformat waveformat;
                Console.WriteLine("Opening stream");

                using (Stream stream = File.OpenRead(path))
                {
                    if (AudioDecoderService.TryDecode(out waveformat, stream, new FileInfo(path).Extension))
                    {
                        Console.WriteLine("Stream decoded");
                    }
                    else
                    {
                        waveformat = null;
                        ErrorWriteLine("Could not decode stream");
                    }

                    Console.WriteLine("Closing stream");
                    stream.Close();
                }

                Console.WriteLine("Stream closed");

                if (waveformat != null)
                {
                    Console.WriteLine("\n[Creating Gap]");

                    GapFormat gap = GapFormat.CreateFrom(waveformat);

                    foreach (Pause pause in gap.Pauses)
                    {
                        Console.WriteLine("Start: {0}, End: {1}", pause.Start.ToString(@"hh\:mm\:ss\:fff"), pause.End.ToString(@"hh\:mm\:ss\:fff"));
                    }

                    decimal highest = waveformat.Channels[0].Samples[0].Value;
                    decimal lowest  = waveformat.Channels[0].Samples[0].Value;
                    foreach (Sample sample in waveformat.Channels[0].Samples)
                    {
                        highest = sample.Value > highest ? sample.Value : highest;
                        lowest  = sample.Value < lowest ? sample.Value : lowest;
                    }

                    Console.WriteLine("Lowest Value: {0}", lowest);
                    Console.WriteLine("Highest Value: {0}", highest);

                    Console.WriteLine("Gap Count: {0}", gap.Pauses.Count());
                }
            }
            else
            {
                ErrorWriteLine("File does not exist");
            }

            GC.Collect();
            GC.Collect();
        }