Пример #1
0
        /// <summary>
        /// Creates a chart file from a specified chart selection.
        /// </summary>
        /// <param name="chartSelection">
        /// Information on what specific chart from what specific file
        /// to use.
        /// </param>
        public Notechart(ChartSelection chartSelection)
        {
            BPMChanges  = new List <BPMChange>();
            events      = new List <Event>();
            noteCharts  = new List <Notes>();
            chartInfo   = new Info();
            beatMarkers = new List <Beatmarker>();

            if (chartSelection.chartType == "*.chart" && File.Exists(chartSelection.chartPath))
            {
                // Read the whole file into a string
                StreamReader inputStream = new StreamReader(chartSelection.chartPath);
                string       inputFile   = inputStream.ReadToEnd();

                // Add in all the various chart information
                chartInfo  = ChartInfoManager.AddSongInfoFromChart(inputFile);
                BPMChanges = ChartBPMManager.AddBPMChangesFromChart(inputFile);
                events     = ChartEventManager.AddEventsFromChart(inputFile);

                // Adds just the expert notechart, can make a sneaky way of doing all avaliable charts later
                noteCharts.Add(ChartNotesManager.GenerateNotechartFromChart(chartSelection));

                // Close the input stream
                inputStream.Close();
            }
            else if (chartSelection.chartType == "*.mid")
            {
                chartInfo = ChartInfoManager.AddSongInfoFromMidi(chartSelection.directory);

                // Try and parse with Toub.  If an exception is thrown, parse with Sanford.
                try
                {
                    noteCharts.Add(ChartMidiManager.ParseMidiInformationToub(chartSelection, chartInfo, BPMChanges));
                    //noteCharts.Add(ChartMidiManager.ParseMidiInformationSanford(chartSelection, chartInfo, BPMChanges));
                }
                catch (Exception e)
                {
                    // Logging plz!
                    e.ToString();
                    noteCharts.Add(ChartMidiManager.ParseMidiInformationSanford(chartSelection, chartInfo, BPMChanges));
                }
            }

            for (int i = 0; i < noteCharts.Count; i++)
            {
                noteCharts[i] = TimeValueManager.GenerateTimeValues(noteCharts[i], BPMChanges,
                                                                    events, chartInfo, beatMarkers);
                if (noteCharts[i].instrument != "Drums")
                {
                    noteCharts[i] = HOPOManager.AssignHOPOS(noteCharts[i], chartInfo);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Creates a chart file from a specified chart selection.
        /// </summary>
        /// <param name="chartSelection">
        /// Information on what specific chart from what specific file
        /// to use.
        /// </param>
        public Notechart(ChartSelection chartSelection)
        {
            BPMChanges = new List<BPMChange>();
            events = new List<Event>();
            noteCharts = new List<Notes>();
            chartInfo = new Info();
            beatMarkers = new List<Beatmarker>();

            if (chartSelection.chartType == "*.chart" && File.Exists(chartSelection.chartPath))
            {
                // Read the whole file into a string
                StreamReader inputStream = new StreamReader(chartSelection.chartPath);
                string inputFile = inputStream.ReadToEnd();

                // Add in all the various chart information
                chartInfo = ChartInfoManager.AddSongInfoFromChart(inputFile);
                BPMChanges = ChartBPMManager.AddBPMChangesFromChart(inputFile);
                events = ChartEventManager.AddEventsFromChart(inputFile);

                // Adds just the expert notechart, can make a sneaky way of doing all avaliable charts later
                noteCharts.Add(ChartNotesManager.GenerateNotechartFromChart(chartSelection));

                // Close the input stream
                inputStream.Close();
            }
            else if (chartSelection.chartType == "*.mid")
            {
                chartInfo = ChartInfoManager.AddSongInfoFromMidi(chartSelection.directory);

                // Try and parse with Toub.  If an exception is thrown, parse with Sanford.
                try
                {
                    noteCharts.Add(ChartMidiManager.ParseMidiInformationToub(chartSelection, chartInfo, BPMChanges));
                    //noteCharts.Add(ChartMidiManager.ParseMidiInformationSanford(chartSelection, chartInfo, BPMChanges));
                }
                catch (Exception e)
                {
                    // Logging plz!
                    e.ToString();
                    noteCharts.Add(ChartMidiManager.ParseMidiInformationSanford(chartSelection, chartInfo, BPMChanges));
                }
            }

            for (int i = 0; i < noteCharts.Count; i++)
            {
                noteCharts[i] = TimeValueManager.GenerateTimeValues(noteCharts[i], BPMChanges,
                                                                         events, chartInfo, beatMarkers);
                if (noteCharts[i].instrument != "Drums")
                {
                    noteCharts[i] = HOPOManager.AssignHOPOS(noteCharts[i], chartInfo);
                }
            }
        }