public override List <ScriptAction> Load(Stream stream)
        {
            BeatCollection beats = BeatCollection.Load(stream);

            return(beats.Select(beat => new BeatScriptAction
            {
                TimeStamp = beat
            }).Cast <ScriptAction>().ToList());
        }
Example #2
0
        private void btnLoadBeatsFile_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog {
                Filter = "Text Files|*.txt"
            };

            if (dialog.ShowDialog(this) != true)
            {
                return;
            }

            Beats    = BeatCollection.Load(dialog.FileName);
            Duration = Beats.Max();
            UpdateHeatMap();
        }
Example #3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string[] paths = txtPath.Text.Split(';');

            string[] files = paths.SelectMany(path => Directory.EnumerateFiles(path, "*.txt", SearchOption.AllDirectories)).ToArray();

            List <ScriptStats> stats = new List <ScriptStats>();

            foreach (string textFile in files)
            {
                try
                {
                    BeatCollection collection = BeatCollection.Load(textFile);

                    var chapters = GetChapters(collection);
                    if (chapters == null || chapters.Count < 1)
                    {
                        continue;
                    }

                    TimeSpan duration = chapters.Aggregate(TimeSpan.Zero, (total, current) => total + (current.Last() - current.First()));
                    double   bpm      = chapters.Sum(c => c.Count - 1) / duration.TotalMinutes;

                    stats.Add(new ScriptStats
                    {
                        Beats           = collection.ToList(),
                        Bpm             = bpm,
                        ContentDuration = duration,
                        File            = textFile
                    });
                }
                catch
                {
                }
            }

            stats = stats.OrderByDescending(s => s.Bpm).ToList();

            int pos = 0;

            foreach (var stat in stats)
            {
                pos++;
                Debug.WriteLine($"{pos.ToString().PadRight(2)}.: {stat.Bpm:f0} BMP, {stat.ContentDuration:h\\:mm\\:ss}, {System.IO.Path.GetFileNameWithoutExtension(stat.File)}");
            }
        }
Example #4
0
 private void LoadBeatsFile(string filename)
 {
     SetAllBeats(BeatCollection.Load(filename));
 }