示例#1
0
        public void ExpandDrumRoll(NoteChart chart, NoteChart.Difficulty difficulty, NoteChart.Note note, int gem)
        {
            if (note.Duration >= (ulong)chart.Division.TicksPerBeat)
            {
                ulong rolllen = 0;
                switch (difficulty)
                {
                case NoteChart.Difficulty.Expert:
                    rolllen = (ulong)chart.Division.TicksPerBeat / 2;                             // 8th note rolls
                    break;

                case NoteChart.Difficulty.Hard:
                case NoteChart.Difficulty.Medium:
                    rolllen = (ulong)chart.Division.TicksPerBeat;                             // 4th note rolls
                    break;

                case NoteChart.Difficulty.Easy:
                    rolllen = 0;                             // Single hit
                    break;
                }
                if (rolllen > 0)
                {
                    for (ulong pos = rolllen; pos < note.Duration; pos += rolllen)
                    {
                        NoteChart.Note newnote = new NoteChart.Note(note.Time + pos, (ulong)chart.Division.TicksPerBeat / 8);
                        chart.PartDrums.Gems[difficulty][gem].Add(newnote);
                    }
                }
            }

            note.Duration = (ulong)chart.Division.TicksPerBeat / 8;
        }
示例#2
0
        private void DecodeChartVocalPhrases(SongData song, QbFile qbchart, Notes notes, NoteChart chart)
        {
            uint[]         values     = GetChartValues(notes, qbchart, QbKey.Create(0x032292A7), QbKey.Create(song.ID + "_vocals_phrases"), 4, 1);
            NoteChart.Note lastvnote  = null;
            bool           altvphrase = false;
            int            odcounter  = 1;
            ulong          lastvtime  = 0;

            for (int k = 0; k < values.Length; k += 2)
            {
                if (lastvnote != null)
                {
                    lastvnote.Duration = chart.GetTicksDuration(lastvtime, values[k] - lastvtime) - 1;
                }

                lastvtime = values[k];
                lastvnote = new NoteChart.Note(chart.GetTicks(lastvtime));

                odcounter++;
                odcounter %= 4;
                if (odcounter == 0)
                {
                    chart.PartVocals.Overdrive.Add(lastvnote);
                }

                if (altvphrase)
                {
                    chart.PartVocals.Player2.Add(lastvnote);
                }
                else
                {
                    chart.PartVocals.Player1.Add(lastvnote);
                }
                altvphrase = !altvphrase;
            }
            if (lastvnote != null)
            {
                lastvnote.Duration = chart.FindLastNote() - lastvnote.Time;
            }

            uint[][] jaggedvalues = GetJaggedChartValues(notes, qbchart, QbKey.Create("vocalstarpower"), QbKey.Create("vocalstarpower"), 4, 2);
            if (jaggedvalues != null)
            {
                foreach (uint[] star in jaggedvalues)
                {
                    chart.PartVocals.Overdrive.Add(new NoteChart.Note(chart.GetTicks(star[0]), chart.GetTicksDuration(star[0], star[1])));
                }
            }
        }
示例#3
0
        public static void FillSections(NoteChart chart, int length, int gap, int start, List <NoteChart.Note> notes, List <NoteChart.Note> overlap)
        {
            Midi.TimeSignatureEvent previous = new Midi.TimeSignatureEvent(0, 4, 0, 0, 0);
            Midi.TimeSignatureEvent next;
            int   index = -1;
            ulong time  = chart.FindLastNote();
            long  t2;

            while (time > 0)
            {
                try {
                    next = chart.Signature[++index];
                } catch (ArgumentOutOfRangeException) {
                    next = new Midi.TimeSignatureEvent(ulong.MaxValue, 4, 0, 0, 0);
                }

                long measuresize = chart.Division.TicksPerBeat * (long)previous.Numerator;

                t2 = (long)Math.Min(next.Time - previous.Time, time);
                for (long t1 = measuresize * start; t2 - t1 >= measuresize * length; t1 += measuresize * gap)
                {
                    bool           collide = false;
                    NoteChart.Note note    = new NoteChart.Note(previous.Time + (ulong)t1, (ulong)measuresize * (ulong)length);
                    if (overlap != null)
                    {
                        foreach (NoteChart.Note n in overlap)
                        {
                            if (note.IsUnderNote(n, true))
                            {
                                collide = true;
                                break;
                            }
                        }
                    }
                    if (!collide)
                    {
                        notes.Add(note);
                    }
                }
                time -= (ulong)t2;

                previous = next;
            }
        }
示例#4
0
        private static void DecodeChartDrums(SongData song, QbFile qbchart, NoteChart chart)
        {
            QbItemArray drumsitems = qbchart.FindItem(QbKey.Create(song.ID + "_drums_notes"), false) as QbItemArray;

            if (drumsitems != null)
            {
                drumsitems = drumsitems.Items[0] as QbItemArray;
            }
            if (drumsitems != null)
            {
                chart.PartDrums = new NoteChart.Drums(chart);
                Dictionary <uint, int> drumnotes = new Dictionary <uint, int>()                 // Garbage: 65, 70, 48, 64
                {
                    { 60, 0 },
                    { 40, 1 }, { 64, 1 },
                    { 55, 2 }, { 67, 2 }, { 53, 2 },
                    { 39, 3 }, { 38, 3 }, { 63, 3 }, { 62, 3 },
                    { 68, 4 }, { 56, 4 }, { 66, 4 }, { 54, 4 }, { 69, 4 }, { 57, 4 }, { 37, 4 }, { 61, 4 },
                };
                Dictionary <uint, NoteChart.Drums.Animation> drumanimnotes = new Dictionary <uint, NoteChart.Drums.Animation>()
                {
                };

                foreach (QbItemInteger drums in drumsitems.Items)
                {
                    NoteChart.Note note    = new NoteChart.Note(chart.GetTicks(drums.Values[0]), (ulong)chart.Division.TicksPerBeat / 8);
                    uint           notenum = drums.Values[1];
                    if (drumnotes.ContainsKey(notenum))
                    {
                        int notevalue = drumnotes[notenum];
                        chart.PartDrums.Gems[NoteChart.Difficulty.Expert][notevalue].Add(note);
                    }
                    if (drumanimnotes.ContainsKey(notenum))
                    {
                        chart.PartDrums.Animations.Add(new Pair <NoteChart.Note, NoteChart.Drums.Animation>(note, drumanimnotes[notenum]));
                    }
                }
            }

            ChartFormatGH5.FillSections(chart, 1, 8, 1, chart.PartDrums.Overdrive, null);
            ChartFormatGH5.FillSections(chart, 1, 4, 3, chart.PartDrums.DrumFills, null);
        }
示例#5
0
        public override ChartFormat DecodeChart(FormatData data, ProgressIndicator progress)
        {
            IList <Stream> streams = GetChartStreams(data);

            float bpm = 0;

            NoteChart chart = new NoteChart();

            chart.BPM.Add(new Midi.TempoEvent(0, (uint)(Mid.MicrosecondsPerMinute / bpm)));
            chart.Signature.Add(new Midi.TimeSignatureEvent(0, 4, 2, 24, 8));

            Mub mub = null;             // TODO: Determine charts by filenames or some shit

            chart.PartGuitar = new NoteChart.Guitar(chart);
            NoteChart.Instrument instrument = chart.PartGuitar;

            NoteChart.IGems       gems = instrument as NoteChart.IGems;
            NoteChart.IForcedHopo hopo = instrument as NoteChart.IForcedHopo;

            NoteChart.Difficulty difficulty = NoteChart.Difficulty.Expert;
            int fadeposition = 0;

            foreach (Mub.Node node in mub.Nodes)
            {
                ulong          time      = (ulong)(node.Time * chart.Division.TicksPerBeat / 4);
                ulong          duration  = (ulong)(node.Duration * chart.Division.TicksPerBeat / 4);
                NoteChart.Note fullnote  = new NoteChart.Note(time, duration);
                NoteChart.Note note      = new NoteChart.Note(time, chart.Division.TicksPerBeat / 4U);
                NoteChart.Note prevnote  = new NoteChart.Note(time - chart.Division.TicksPerBeat / 2U, chart.Division.TicksPerBeat / 4U);
                int            greennote = fadeposition < 0 ? 0 : 1;
                int            bluenote  = fadeposition > 0 ? 4 : 3;

                switch (node.Type)
                {
                case 0x00:                         // Green dot
                    gems.Gems[difficulty][greennote].Add(note);
                    hopo.ForceHammeron[difficulty].Add(note);
                    break;

                case 0x01:                         // Blue dot
                    gems.Gems[difficulty][bluenote].Add(note);
                    hopo.ForceHammeron[difficulty].Add(note);
                    break;

                case 0x02:                         // Red dot
                    gems.Gems[difficulty][2].Add(note);
                    hopo.ForceHammeron[difficulty].Add(note);
                    break;

                case 0x09:                         // Blue Crossfade right
                    fadeposition = 1;
                    gems.Gems[difficulty][4].Add(note);
                    gems.Gems[difficulty][fadeposition < 0 ? 0 : 3].Add(prevnote);
                    hopo.ForceHammeron[difficulty].Add(note);
                    break;

                case 0x0A:                         // Green Crossfade left (revert to rightish normal)
                    fadeposition = 0;
                    break;

                case 0x0B:                         // Green Crossfade left
                    fadeposition = -1;
                    gems.Gems[difficulty][0].Add(note);
                    gems.Gems[difficulty][fadeposition > 0 ? 4 : 1].Add(prevnote);
                    hopo.ForceHammeron[difficulty].Add(note);
                    break;

                case 0x0C:                         // Weird whammy thing on left green
                    gems.Gems[difficulty][greennote].Add(fullnote);
                    hopo.ForceHammeron[difficulty].Add(note);
                    break;

                case 0x0D:                         // ?? Not sure, Weird whammy thing on right blue maybe
                    gems.Gems[difficulty][bluenote].Add(fullnote);
                    hopo.ForceHammeron[difficulty].Add(note);
                    break;

                default:
                    break;
                }
            }

            return(new ChartFormat(chart));
        }
示例#6
0
        private static void DecodeChartNotes(FormatData data, SongData song, QbFile qbchart, NoteChart chart, NoteChart.TrackType track, NoteChart.Difficulty difficulty, bool coop)
        {
            string basetrack           = string.Empty;
            string basetrackstar       = string.Empty;
            string basetrackstarbattle = string.Empty;
            string basetrackfaceoff    = string.Empty;

            NoteChart.Instrument instrument = null;
            switch (track)
            {
            case NoteChart.TrackType.Guitar:
                basetrack           = song.ID + (coop ? "_song_guitarcoop_" : "_song_") + difficulty.DifficultyToString();
                basetrackstar       = song.ID + (coop ? "_guitarcoop_" : "_") + difficulty.DifficultyToString() + "_Star";
                basetrackstarbattle = song.ID + (coop ? "_guitarcoop_" : "_") + difficulty.DifficultyToString() + "_StarBattleMode";
                basetrackfaceoff    = song.ID + "_FaceOffp";
                instrument          = chart.PartGuitar;
                break;

            case NoteChart.TrackType.Bass:
                basetrack           = song.ID + (coop ? "_song_rhythmcoop_" : "_song_rhythm_") + difficulty.DifficultyToString();
                basetrackstar       = song.ID + (coop ? "_rhythmcoop_" : "_rhythm_") + difficulty.DifficultyToString() + "_Star";
                basetrackstarbattle = song.ID + (coop ? "_rhythmcoop_" : "_rhythm_") + difficulty.DifficultyToString() + "_StarBattleMode";
                basetrackfaceoff    = song.ID + "_FaceOffP";
                instrument          = chart.PartBass;
                break;
            }

            if (instrument == null)
            {
                return;
            }

            if (difficulty == NoteChart.Difficulty.Expert)               // GH3 has SP for each difficulty; RB2 has one OD for all
            {
                QbItemArray faceoff1 = (qbchart.FindItem(QbKey.Create(basetrackfaceoff + "1"), false) as QbItemArray).Items[0] as QbItemArray;
                if (faceoff1 != null)
                {
                    foreach (QbItemInteger faceoff in faceoff1.Items)
                    {
                        NoteChart.Note fnote = new NoteChart.Note(chart.GetTicks(faceoff.Values[0]), chart.GetTicksDuration(faceoff.Values[0], faceoff.Values[1]));
                        instrument.Player1.Add(fnote);
                    }
                }
                QbItemArray faceoff2 = (qbchart.FindItem(QbKey.Create(basetrackfaceoff + "2"), false) as QbItemArray).Items[0] as QbItemArray;
                if (faceoff2 != null)
                {
                    foreach (QbItemInteger faceoff in faceoff2.Items)
                    {
                        NoteChart.Note fnote = new NoteChart.Note(chart.GetTicks(faceoff.Values[0]), chart.GetTicksDuration(faceoff.Values[0], faceoff.Values[1]));
                        instrument.Player2.Add(fnote);
                    }
                }
                QbItemArray starpower = (qbchart.FindItem(QbKey.Create(basetrackstar), false) as QbItemArray).Items[0] as QbItemArray;
                if (starpower != null)
                {
                    foreach (QbItemInteger star in starpower.Items)
                    {
                        instrument.Overdrive.Add(new NoteChart.Note(chart.GetTicks(star.Values[0]), chart.GetTicksDuration(star.Values[0], star.Values[1])));
                    }
                }
                if (instrument.Overdrive.Count == 0)
                {
                    starpower = (qbchart.FindItem(QbKey.Create(basetrackstarbattle), false) as QbItemArray).Items[0] as QbItemArray;
                    if (starpower != null)
                    {
                        foreach (QbItemInteger star in starpower.Items)
                        {
                            instrument.Overdrive.Add(new NoteChart.Note(chart.GetTicks(star.Values[0]), chart.GetTicksDuration(star.Values[0], star.Values[1])));
                        }
                    }
                }
            }

            int previouschordnum = 0;
            int previouschord    = 0;

            NoteChart.Note previousnote = new NoteChart.Note()
            {
                Time = uint.MaxValue, Duration = 0
            };
            QbItemInteger notes = (qbchart.FindItem(QbKey.Create(basetrack), false) as QbItemArray).Items[0] as QbItemInteger;

            if (notes == null)
            {
                if (track == NoteChart.TrackType.Guitar)
                {
                    chart.PartGuitar = null;
                }
                else
                {
                    chart.PartBass = null;
                }
                return;
            }

            int note32 = chart.Division.TicksPerBeat / 8;
            int note16 = chart.Division.TicksPerBeat / 4;

            for (int k = 0; k < notes.Values.Length; k += 3)
            {
                NoteChart.Note note     = new NoteChart.Note(chart.GetTicks(notes.Values[k]), chart.GetTicksDuration(notes.Values[k], notes.Values[k + 1]));
                int            chordnum = 0;
                int            chord    = 0;

                // Cut off sustains to a 32nd note before the next
                previousnote.Duration = (ulong)Math.Max(Math.Min((long)previousnote.Duration, (long)note.Time - (long)previousnote.Time - note16), note32);

                bool hopo   = note.Time - previousnote.Time <= (ulong)data.Song.HopoThreshold;
                bool ishopo = hopo;
                hopo = hopo && previouschordnum == 1;

                uint fret = notes.Values[k + 2];
                for (int l = 0; l < 6; l++)
                {
                    if ((fret & 0x01) != 0)
                    {
                        if (l < 5)
                        {
                            chord = l;
                            chordnum++;
                            (instrument as NoteChart.IGems).Gems[difficulty][l].Add(note);
                        }
                        else                           // l == 5; hopo toggle bit
                        {
                            ishopo = !ishopo;
                        }
                    }

                    fret >>= 1;
                }

                if (chordnum == 0)                   // Old TheGHOST bug, should be a green note
                {
                    chordnum = 1;
                    chord    = 0;
                    (instrument as NoteChart.IGems).Gems[difficulty][0].Add(note);
                }

                if (chord == previouschord)
                {
                    ishopo = false;
                }

                if (ishopo != hopo && chordnum == 1)
                {
                    if (ishopo)
                    {
                        (instrument as NoteChart.IForcedHopo).ForceHammeron[difficulty].Add(note);
                    }
                    else
                    {
                        (instrument as NoteChart.IForcedHopo).ForceStrum[difficulty].Add(note);
                    }
                }

                previouschord    = chord;
                previousnote     = note;
                previouschordnum = chordnum;
            }
        }
示例#7
0
        public bool PopulateChart(SongData song, NoteChart chart)
        {
            if (Root == null)
            {
                return(false);
            }

            string idprefix = string.Empty;

            bool ret = false;

            foreach (XmlElement node in Root.GetElementsByTagName("global"))
            {
                foreach (XmlElement element in node.GetElementsByTagName("idprefix"))
                {
                    idprefix = element.InnerText;
                }
            }

            string songid = song.ID;

            if (songid.StartsWith(idprefix))
            {
                songid = songid.Substring(idprefix.Length);
            }

            List <SoloInfo> solos = new List <SoloInfo>();

            foreach (XmlElement element in Root.GetElementsByTagName("song"))
            {
                if (element.Attributes["game"] != null && int.Parse(element.Attributes["game"].Value) != (int)Game)
                {
                    continue;
                }

                if (string.Compare(element.Attributes["id"].Value, songid, true) == 0)
                {
                    foreach (XmlElement soloelement in element.GetElementsByTagName("solo"))
                    {
                        string     startsection = soloelement.Attributes["start"] != null ? soloelement.Attributes["start"].Value : string.Empty;
                        string     endsection   = soloelement.Attributes["end"] != null ? soloelement.Attributes["end"].Value : startsection;
                        float      startoffset  = float.Parse(soloelement.Attributes["startoffset"] != null ? soloelement.Attributes["startoffset"].Value : "0");
                        float      endoffset    = float.Parse(soloelement.Attributes["endoffset"] != null ? soloelement.Attributes["endoffset"].Value : "0");
                        Instrument instrument   = soloelement.Attributes["instrument"] != null?Platform.InstrumentFromString(soloelement.Attributes["instrument"].Value) : Instrument.Guitar;

                        if (!startsection.HasValue())
                        {
                            continue;
                        }

                        NoteChart.Point start    = new NoteChart.Point(chart.Events.Sections.Find(e => string.Compare(e.Value, startsection, true) == 0).Key.Time);
                        int             endindex = chart.Events.Sections.FindIndex(e => string.Compare(e.Value, endsection, true) == 0);
                        NoteChart.Point end;
                        if (endindex + 1 < chart.Events.Sections.Count)
                        {
                            end = new NoteChart.Point(chart.Events.Sections[endindex + 1].Key.Time);
                        }
                        else
                        {
                            end = new NoteChart.Point(chart.Events.End.Time);
                        }

                        start.Time += (ulong)(startoffset * (float)chart.Division.TicksPerBeat);
                        end.Time   += (ulong)(endoffset * (float)chart.Division.TicksPerBeat);

                        NoteChart.Note note = new NoteChart.Note(start.Time, end.Time - start.Time);

                        if (instrument == Instrument.Guitar)
                        {
                            chart.PartGuitar.SoloSections.Add(note);
                        }
                        else if (instrument == Instrument.Bass)
                        {
                            chart.PartBass.SoloSections.Add(note);
                        }
                        else if (instrument == Instrument.Drums)
                        {
                            chart.PartDrums.SoloSections.Add(note);
                        }
                        ret = true;
                    }
                }
            }

            return(ret);
        }
示例#8
0
        private void DecodeChartNotes(SongData song, QbFile qbchart, Notes notes, NoteChart chart, NoteChart.TrackType track, NoteChart.Difficulty difficulty)
        {
            bool expertplus = song.Data.GetValue <bool>("GH5ChartExpertPlus");

            uint[]   values;
            uint[][] jaggedvalues;
            QbKey    basetrack = null; QbKey basetrackstar = null; QbKey basetrackfaceoff1 = null; QbKey basetrackfaceoff2 = null; QbKey basetracktapping = null;

            NoteChart.Instrument instrument = null;
            switch (track)
            {
            case NoteChart.TrackType.Guitar:
                instrument = chart.PartGuitar;
                if (notes != null)
                {
                    basetrack        = QbKey.Create("guitar" + difficulty.DifficultyToString().ToLower() + "instrument");
                    basetracktapping = QbKey.Create("guitar" + difficulty.DifficultyToString().ToLower() + "tapping");
                    basetrackstar    = QbKey.Create("guitar" + difficulty.DifficultyToString().ToLower() + "starpower");
                }
                else
                {
                    basetrack         = QbKey.Create(song.ID + "_song_" + difficulty.DifficultyToString().ToLower());
                    basetrackstar     = QbKey.Create(song.ID + "_" + difficulty.DifficultyToString().ToLower() + "_star");
                    basetrackfaceoff1 = QbKey.Create(song.ID + "_faceoffp1");
                    basetrackfaceoff2 = QbKey.Create(song.ID + "_faceoffp2");
                    basetracktapping  = QbKey.Create(song.ID + "_" + difficulty.DifficultyToString().ToLower() + "_tapping");
                }
                break;

            case NoteChart.TrackType.Bass:
                instrument = chart.PartBass;
                if (notes != null)
                {
                    basetrack        = QbKey.Create("bass" + difficulty.DifficultyToString().ToLower() + "instrument");
                    basetracktapping = QbKey.Create("bass" + difficulty.DifficultyToString().ToLower() + "tapping");
                    basetrackstar    = QbKey.Create("bass" + difficulty.DifficultyToString().ToLower() + "starpower");
                }
                else
                {
                    basetrack         = QbKey.Create(song.ID + "_song_rhythm_" + difficulty.DifficultyToString().ToLower());
                    basetrackstar     = QbKey.Create(song.ID + "_rhythm_" + difficulty.DifficultyToString().ToLower() + "_star");
                    basetrackfaceoff1 = QbKey.Create(song.ID + "_rhythm_faceoffp1");
                    basetrackfaceoff2 = QbKey.Create(song.ID + "_rhythm_faceoffp2");
                    // basetracktapping = song.ID + "_rhythm_" + difficulty.DifficultyToString().ToLower() + "_tapping";
                }
                break;

            case NoteChart.TrackType.Drums:
                instrument = chart.PartDrums;
                if (notes != null)
                {
                    basetrack     = QbKey.Create("drums" + difficulty.DifficultyToString().ToLower() + "instrument");
                    basetrackstar = QbKey.Create("drums" + difficulty.DifficultyToString().ToLower() + "starpower");
                }
                else
                {
                    basetrack         = QbKey.Create(song.ID + "_song_drum_" + difficulty.DifficultyToString().ToLower());
                    basetrackstar     = QbKey.Create(song.ID + "_drum_" + difficulty.DifficultyToString().ToLower() + "_star");
                    basetrackfaceoff1 = QbKey.Create(song.ID + "_drum_faceoffp1");
                    basetrackfaceoff2 = QbKey.Create(song.ID + "_drum_faceoffp2");
                    // basetracktapping = song.ID + "_drum_" + difficulty.DifficultyToString().ToLower() + "_tapping";
                }
                break;
            }

            if (difficulty == NoteChart.Difficulty.Expert)               // GH has SP for each difficulty; RB2 has one OD for all
            {
                jaggedvalues = GetJaggedChartValues(notes, qbchart, basetrackstar, basetrackstar, 4, 2);
                foreach (uint[] star in jaggedvalues)
                {
                    instrument.Overdrive.Add(new NoteChart.Note(chart.GetTicks(star[0]), chart.GetTicksDuration(star[0], star[1])));
                }

                if (notes == null)
                {
                    jaggedvalues = GetJaggedChartValues(notes, qbchart, basetrackfaceoff1, basetrackfaceoff1, 1);
                    foreach (uint[] faceoff in jaggedvalues)
                    {
                        instrument.Player1.Add(new NoteChart.Note(chart.GetTicks(faceoff[0]), chart.GetTicksDuration(faceoff[0], faceoff[1])));
                    }

                    jaggedvalues = GetJaggedChartValues(notes, qbchart, basetrackfaceoff2, basetrackfaceoff2, 2);
                    foreach (uint[] faceoff in jaggedvalues)
                    {
                        instrument.Player2.Add(new NoteChart.Note(chart.GetTicks(faceoff[0]), chart.GetTicksDuration(faceoff[0], faceoff[1])));
                    }
                }
            }

            if (basetracktapping != null)
            {
                jaggedvalues = GetJaggedChartValues(notes, qbchart, basetracktapping, basetracktapping, 4, 4);
                foreach (uint[] tap in jaggedvalues)
                {
                    if (instrument is NoteChart.IForcedHopo)
                    {
                        (instrument as NoteChart.IForcedHopo).ForceHammeron[difficulty].Add(new NoteChart.Note(chart.GetTicks(tap[0]), chart.GetTicksDuration(tap[0], tap[1])));
                    }
                }
            }

            int previouschordnum            = 0;
            int previouschord = 0;

            NoteChart.Note previousnote = new NoteChart.Note(uint.MaxValue);

            int note32 = chart.Division.TicksPerBeat / 8;
            int note16 = chart.Division.TicksPerBeat / 4;

            values = GetChartValues(notes, qbchart, basetrack, basetrack, 4, 4);
            for (int k = 0; k < values.Length; k += 2)
            {
                uint fret   = values[k + 1];
                uint length = 0;
                if (notes != null)
                {
                    length = fret >> 16;
                    fret   = fret & 0x0000FFFF;
                }
                else
                {
                    length = fret & 0x0000FFFF;
                    fret >>= 16;
                }
                if (notes != null)
                {
                    fret = ((fret & 0xFF00) >> 8) | ((fret & 0x00FF) << 8);
                }

                NoteChart.Note note     = new NoteChart.Note(chart.GetTicks(values[k]), chart.GetTicksDuration(values[k], length));
                int            chordnum = 0;
                int            chord    = 0;

                // Cut off sustains to a 32nd note before the next
                previousnote.Duration = (ulong)Math.Max(Math.Min((long)previousnote.Duration, (long)note.Time - (long)previousnote.Time - note16), note32);

                uint numfrets = 5;
                if (track == NoteChart.TrackType.Drums)
                {
                    numfrets += 2;
                }

                int[] transform;
                if (notes == null)
                {
                    transform = new int[] { 4, 1, 2, 3, 3, 0, -1 }
                }
                ;
                else
                {
                    //transform = new int[] { 4, 1, 2, 3, -1, 0, 4 }; // -1 -> 4?
                    transform = new int[] { 4, 1, 2, 3, 3, 0, 4 }
                };                                                                     // TODO: Verify charts

                for (int l = 0; l < numfrets; l++)
                {
                    if (((fret >> l) & 0x01) != 0)
                    {
                        chordnum++;
                        chord = l;
                        if (track == NoteChart.TrackType.Drums)
                        {
                            chord = transform[l];

                            //if ((fret & 0x2000) != 0)
                            //	continue;
                            //if (chord == 0 && ((fret & 0x2000) == 0) && !expertplus) // TODO: Verify expert+
                            //	continue;
                        }

                        if (chord >= 0)
                        {
                            (instrument as NoteChart.IGems).Gems[difficulty][chord].Add(note);

                            if (instrument is NoteChart.Drums)
                            {
                                ExpandDrumRoll(chart, difficulty, note, chord);
                            }
                        }
                    }
                }

                if (chordnum == 0)                   // Bass open note, actually fret bit 6
                {
                    chordnum++;
                    if (!(instrument is NoteChart.Drums))
                    {
                        (instrument as NoteChart.IGems).Gems[difficulty][0].Add(note);
                    }
                    if (instrument is NoteChart.IForcedHopo)
                    {
                        (instrument as NoteChart.IForcedHopo).ForceHammeron[difficulty].Add(note);                         // Bass open notes become hopos, lulz
                    }
                }
                else if (chordnum == 1 && chord != previouschord)
                {
                    if (instrument is NoteChart.IForcedHopo)
                    {
                        if ((fret & 0x0040) != 0)
                        {
                            (instrument as NoteChart.IForcedHopo).ForceHammeron[difficulty].Add(note);
                        }
                        else
                        {
                            (instrument as NoteChart.IForcedHopo).ForceStrum[difficulty].Add(note);
                        }
                    }
                }

                previouschord    = chord;
                previousnote     = note;
                previouschordnum = chordnum;
            }
        }
示例#9
0
        public static Chart Create(Stream stream)
        {
            Chart chart = new Chart();

            StreamReader reader = new StreamReader(stream);

            string    line;
            string    section = null;
            TrackType track   = TrackType.Unknown;

            List <NoteChart.Note>[] notes      = null;
            NoteChart.Instrument    instrument = null;
            while ((line = reader.ReadLine()) != null)
            {
                if (line == "}")
                {
                    section = null;
                }
                else if (line == "{")
                {
                    continue;
                }
                Match match = Regex.Match(line, "\\[(?'section'.+)\\]");
                if (match.Success)
                {
                    section = match.Groups["section"].Value;
                    track   = GetTrackType(section);
                    BaseTrackType type = GetBaseTrackType(track);
                    instrument         = chart.CreateInstrument(GetInstrument(type));
                    chart.Tracks[type] = instrument;
                    notes = (instrument as NoteChart.IGems).Gems[GetDifficulty(track)];
                }
                else
                {
                    ulong    time;
                    string[] values = ParseLine(line);
                    switch (section)
                    {
                    case null:
                        throw new FormatException();

                    case "Song":
                        chart.Song[values[0]] = values[1];
                        break;

                    case "SyncTrack":
                        time = ulong.Parse(values[0]);
                        switch (values[1])
                        {
                        case "TS":
                            chart.NoteChart.Signature.Add(new Midi.TimeSignatureEvent(time, byte.Parse(values[2]), 2, 24, 8));
                            break;

                        case "B":
                            chart.NoteChart.BPM.Add(new Midi.TempoEvent(time, (uint)(Mid.MicrosecondsPerMinute / ((float)int.Parse(values[2]) / 1000))));
                            break;

                        default:
                            throw new FormatException();
                        }
                        break;

                    case "Events":
                        time = ulong.Parse(values[0]);
                        switch (values[1])
                        {
                        case "E":
                            chart.EventsTrack.Comments.Add(new Midi.TextEvent(time, "[" + values[2] + "]"));
                            break;

                        default:
                            throw new FormatException();
                        }
                        break;

                    default:
                        if (track == TrackType.Unknown)
                        {
                            throw new FormatException();
                        }
                        time = ulong.Parse(values[0]);
                        ulong duration = ulong.Parse(values[2]);
                        if (duration == 0)
                        {
                            duration = chart.NoteChart.Division.TicksPerBeat / 4U;
                        }
                        switch (values[1])
                        {
                        case "N":
                            int fret = int.Parse(values[1]);
                            notes[fret].Add(new NoteChart.Note(time, duration));
                            break;

                        case "S":
                            NoteChart.Note note        = new NoteChart.Note(time, duration);
                            int            sectiontype = int.Parse(values[1]);
                            switch (sectiontype)
                            {
                            case 0:
                                instrument.Player1.Add(note);
                                break;

                            case 1:
                                instrument.Player2.Add(note);
                                break;

                            case 2:
                                instrument.Overdrive.Add(note);
                                break;

                            default:
                                throw new FormatException();
                            }
                            break;
                        }
                        break;
                    }
                }
            }

            return(chart);
        }