Esempio n. 1
0
        public BmsChartManaged(string BmsChartPath)
        {
            this.BmsChartPath = BmsChartPath;
            string BmsContent = File.ReadAllText(BmsChartPath);

            NativeBmsChart = new BMSChart(BmsContent);
            NativeBmsChart.Parse(ParseType.All);
            foreach (BMSEvent BmsEvent in NativeBmsChart.Events)
            {
                switch (BmsEvent.type)
                {
                case BMSEventType.BeatReset:
                    BeatResets.Add(new BmsEvent(BmsEventType.BeatReset, (float)BmsEvent.time.TotalSeconds, BmsEvent));
                    break;

                case BMSEventType.BPM:
                    Bpms.Add(new BmsEvent(BmsEventType.Bpm, (float)BmsEvent.time.TotalSeconds, BmsEvent));
                    break;

                case BMSEventType.Note:
                    Notes.Add(new BmsNote((float)BmsEvent.time.TotalSeconds, BmsEvent.data1, BmsEvent));
                    break;

                case BMSEventType.LongNoteStart:
                    LongNotes.Add(new BmsLongNote((float)BmsEvent.time.TotalSeconds, BmsEvent.data1, (float)(BmsEvent.time2.TotalSeconds - BmsEvent.time.TotalSeconds), BmsEvent));
                    break;

                case BMSEventType.STOP:
                    Stops.Add(new BmsEvent(BmsEventType.Stop, (float)BmsEvent.time.TotalSeconds, BmsEvent));
                    break;

                case BMSEventType.WAV:
                    Wavs.Add(new BmsEvent(BmsEventType.Wav, (float)BmsEvent.time.TotalSeconds, BmsEvent));
                    break;
                }
            }
        }
Esempio n. 2
0
        static void ParseFile(string path)
        {
            FileInfo fileInfo = new FileInfo(path);

            if (!fileInfo.Exists)
            {
                Console.WriteLine("{0} does not exists. ", fileInfo.Name);
                return;
            }

            Console.WriteLine("File: {0}", fileInfo.Name);
            string fileContent = LoadFileContent(fileInfo);

            Chart chart;

            switch (fileInfo.Extension.ToLower())
            {
            case ".bms":
            case ".bme":
            case ".bml":
            case ".pms":
                chart = new BMSChart(fileContent);
                break;

            case ".bmson":
                chart = new BmsonChart(fileContent);
                break;

            default:
                Console.WriteLine("Unknown file type {0}.", fileInfo.Extension);
                return;
            }
            chart.Parse(ParseType.Header | ParseType.Content | ParseType.Resources);
            LoadAllResources(chart, fileInfo);

            Console.WriteLine("BMS Meta Data:");
            Console.WriteLine("Title: {0}\n{1}", chart.Title, chart.SubTitle);
            Console.WriteLine("Artist: {0}\n{1}", chart.Artist, chart.SubArtist);
            Console.WriteLine("Genre: {0}", chart.Genre);
            Console.WriteLine("Comments: {0}", chart.Comments);
            Console.WriteLine("Level: {0} (Rank {1})", chart.PlayLevel, chart.Rank);
            Console.WriteLine("BPM: {0} (Min. {1})", chart.BPM, chart.MinBPM);
            Console.WriteLine("Maximum Combos: {0}", chart.MaxCombos);
            Console.WriteLine("Duration: {0}", GetLength(chart));
            Console.WriteLine("Randomized: {0}", chart.Randomized);

            float min, max, average, mean;

            CountDensity(chart, out min, out max, out average, out mean);
            Console.WriteLine("Note Density (Notes per second): ({0} ~ {1})\nAverage {2} Mean {3}", min, max, average, mean);

            Console.ReadKey(true);

            Console.WriteLine();

            Chart.EventDispatcher dispatcher = chart.GetEventDispatcher();
            dispatcher.BMSEvent += OnBmsEvent;
            PlayBMSChart(dispatcher);

            Console.WriteLine();
            Console.WriteLine();
        }