예제 #1
0
        private void DecodeChartFretbars(SongData song, QbFile qbchart, Notes notes, NoteChart chart)
        {
            uint[] values            = GetChartValues(notes, qbchart, Notes.KeyFretbars, QbKey.Create(song.ID + "_fretbars"));
            ulong  ticks             = 0;
            uint   previousfret      = 0;
            uint   previousMsPerBeat = 0;

            for (int k = 1; k < values.Length; k++)
            {
                uint fret      = values[k];
                uint msPerBeat = fret - previousfret;
                if (msPerBeat != previousMsPerBeat)
                {
                    chart.BPM.Add(new Midi.TempoEvent(ticks, msPerBeat * 1000));
                }

                previousfret      = fret;
                previousMsPerBeat = msPerBeat;
                ticks            += chart.Division.TicksPerBeat;
            }

            chart.Events.End = new NoteChart.Point(chart.GetTicks(values[values.Length - 1]));

            uint[][] jaggedvalues = GetJaggedChartValues(notes, qbchart, Notes.KeyTimesignature, QbKey.Create(song.ID + "_timesig"), 4, 1, 1);
            foreach (uint[] sig in jaggedvalues)
            {
                chart.Signature.Add(new Midi.TimeSignatureEvent(chart.GetTicks(sig[0]), (byte)sig[1], (byte)Math.Log(sig[2], 2), 24, 8));
            }
        }
예제 #2
0
        private static void DecodeChartFretbars(SongData song, QbFile qbchart, NoteChart chart)
        {
            QbItemInteger fretbars          = (qbchart.FindItem(QbKey.Create(song.ID + "_fretbars"), false) as QbItemArray).Items[0] as QbItemInteger;
            ulong         ticks             = 0;
            uint          previousfret      = 0;
            uint          previousMsPerBeat = 0;

            for (int k = 1; k < fretbars.Values.Length; k++)
            {
                uint fret      = fretbars.Values[k];
                uint msPerBeat = fret - previousfret;
                if (msPerBeat != previousMsPerBeat)
                {
                    chart.BPM.Add(new Midi.TempoEvent(ticks, msPerBeat * 1000));
                }

                previousfret      = fret;
                previousMsPerBeat = msPerBeat;
                ticks            += chart.Division.TicksPerBeat;
            }

            chart.Events.End = new NoteChart.Point(chart.GetTicks(fretbars.Values[fretbars.Values.Length - 1]));

            QbItemArray timesig = (qbchart.FindItem(QbKey.Create(song.ID + "_timesig"), false) as QbItemArray).Items[0] as QbItemArray;

            foreach (QbItemInteger sig in timesig.Items)
            {
                chart.Signature.Add(new Midi.TimeSignatureEvent(chart.GetTicks(sig.Values[0]), (byte)sig.Values[1], (byte)Math.Log(sig.Values[2], 2), 24, 8));
            }
        }
예제 #3
0
        private static void DecodeChartVenue(SongData song, QbFile qbchart, NoteChart chart)
        {
            QbItemArray cameraitems = qbchart.FindItem(QbKey.Create(song.ID + "_cameras_notes"), false) as QbItemArray;

            if (cameraitems != null && cameraitems.Items.Count > 0)
            {
                cameraitems = cameraitems.Items[0] as QbItemArray;
            }
            if (cameraitems != null)
            {
                Random random = new Random();
                foreach (QbItemInteger camera in cameraitems.Items)
                {
                    uint            time  = camera.Values[0];
                    NoteChart.Point point = new NoteChart.Point(chart.GetTicks(camera.Values[0]));

                    if (random.Next() % 9 == 0)
                    {
                        chart.Venue.DirectedShots.Add(new Pair <NoteChart.Point, NoteChart.VenueTrack.DirectedCut>(point, NoteChart.VenueTrack.DirectedCut.None));
                    }
                    else
                    {
                        chart.Venue.CameraShots.Add(new Pair <NoteChart.Point, NoteChart.VenueTrack.CameraShot>(point, new NoteChart.VenueTrack.CameraShot()));
                    }
                }
            }

            QbItemArray crowditems = qbchart.FindItem(QbKey.Create(song.ID + "_crowd_notes"), false) as QbItemArray;

            if (crowditems != null && crowditems.Items.Count > 0)
            {
                crowditems = crowditems.Items[0] as QbItemArray;
            }
            if (crowditems != null)
            {
                foreach (QbItemInteger crowd in crowditems.Items)
                {
                    NoteChart.Point point = new NoteChart.Point(chart.GetTicks(crowd.Values[0]));
                    chart.Events.Crowd.Add(new Pair <NoteChart.Point, NoteChart.EventsTrack.CrowdType>(point, NoteChart.EventsTrack.CrowdType.None));
                }
            }

            QbItemArray lightitems = qbchart.FindItem(QbKey.Create(song.ID + "_lightshow_notes"), false) as QbItemArray;

            if (lightitems != null && lightitems.Items.Count > 0)
            {
                lightitems = lightitems.Items[0] as QbItemArray;
            }
            if (lightitems != null)
            {
                foreach (QbItemInteger light in lightitems.Items)
                {
                    NoteChart.Point point = new NoteChart.Point(chart.GetTicks(light.Values[0]));
                    chart.Venue.Lighting.Add(new Pair <NoteChart.Point, NoteChart.VenueTrack.LightingType>(point, NoteChart.VenueTrack.LightingType.None));
                }
            }
        }
예제 #4
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])));
                }
            }
        }
예제 #5
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);
        }
예제 #6
0
        private static void DecodeChartMarkers(SongData song, QbFile qbsections, QbFile qbchart, NoteChart chart)
        {
            QbItemStructArray markers = (qbchart.FindItem(QbKey.Create(song.ID + "_markers"), false) as QbItemArray).Items[0] as QbItemStructArray;

            if (markers != null)
            {
                foreach (QbItemStruct mark in markers.Items)
                {
                    QbItemString section = qbsections.FindItem((mark.Items[1] as QbItemQbKey).Values[0], false) as QbItemString;

                    chart.Events.Sections.Add(new Pair <NoteChart.Point, string>(new NoteChart.Point(chart.GetTicks((mark.Items[0] as QbItemInteger).Values[0])), section.Strings[0]));
                }
            }
        }
예제 #7
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;
            }
        }
예제 #8
0
        private void DecodeChartSections(SongData song, QbFile qbchart, StringList strings, QbFile qbsections, Notes notes, NoteChart chart)
        {
            if (notes != null)
            {
                uint[] values = GetChartValues(notes, null, QbKey.Create(0x92511D84), null, 4, 4);
                for (int k = 0; k < values.Length; k += 2)
                {
                    uint   time = values[k];
                    string text = strings.FindItem(QbKey.Create(values[k + 1]));

                    chart.Events.Sections.Add(new Pair <NoteChart.Point, string>(new NoteChart.Point(chart.GetTicks(time)), text));
                }
            }
            else
            {
                QbItemStructArray markers = (qbchart.FindItem(QbKey.Create(song.ID + "_guitar_markers"), false) as QbItemArray).Items[0] as QbItemStructArray;
                foreach (QbItemStruct mark in markers.Items)
                {
                    QbItemQbKey section = qbsections.FindItem((mark.Items[1] as QbItemQbKey).Values[0], false) as QbItemQbKey;

                    chart.Events.Sections.Add(new Pair <NoteChart.Point, string>(new NoteChart.Point(chart.GetTicks((mark.Items[0] as QbItemInteger).Values[0])), strings.FindItem(section.Values[0])));
                }
            }
        }
예제 #9
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;
            }
        }
예제 #10
0
        private bool DecodeChartVocals(SongData song, QbFile qbchart, StringList strings, Notes notes, NoteChart chart)
        {
            uint[] values = GetChartValues(notes, qbchart, QbKey.Create(0xE8E6ADCB), QbKey.Create(song.ID + "_song_vocals"), 4, 2, 1);
            for (int k = 0; k < values.Length; k += 3)
            {
                byte note = (byte)values[k + 2];
                if (note != 2)
                {
                    if (note > 84)
                    {
                        note -= 12;
                    }
                    chart.PartVocals.Gems.Add(new Midi.NoteEvent(chart.GetTicks(values[k]), 0, note, 100, chart.GetTicksDuration(values[k], values[k + 1])));
                }
            }

            List <Pair <NoteChart.Point, string> > vlyrics = new List <Pair <NoteChart.Point, string> >();

            if (notes != null)
            {
                byte[][] vdata = notes.Find(QbKey.Create(0x1DA27F4E)).Data;
                foreach (byte[] d in vdata)
                {
                    EndianReader reader = new EndianReader(new MemoryStream(d), Endianness.BigEndian);
                    uint         time   = reader.ReadUInt32();
                    string       lyric  = reader.ReadString();
                    vlyrics.Add(new Pair <NoteChart.Point, string>(
                                    new NoteChart.Point(chart.GetTicks(time)),
                                    lyric
                                    ));
                }
            }
            else
            {
                QbItemStructArray lyrics = (qbchart.FindItem(QbKey.Create(song.ID + "_lyrics"), false) as QbItemArray).Items[0] as QbItemStructArray;
                if (lyrics != null)
                {
                    foreach (QbItemBase item in lyrics.Items)
                    {
                        string lyric = strings.FindItem((item.Items[1] as QbItemQbKey).Values[0]);
                        vlyrics.Add(new Pair <NoteChart.Point, string>(
                                        new NoteChart.Point(chart.GetTicks((item.Items[0] as QbItemInteger).Values[0])),
                                        lyric
                                        ));
                    }
                }
            }

            Pair <NoteChart.Point, string> lastlyric = null;

            foreach (var item in vlyrics)
            {
                string lyric = item.Value;
                if (lyric.StartsWith("=") && lastlyric != null)
                {
                    if (lastlyric.Value.EndsWith("-"))
                    {
                        lastlyric.Value = lastlyric.Value.Substring(0, lastlyric.Value.Length - 1) + '=';
                    }
                    else
                    {
                        lastlyric.Value += "-";
                    }
                    lyric = lyric.Substring(1);
                }

                lastlyric = new Pair <NoteChart.Point, string>(
                    item.Key,
                    lyric
                    );
                chart.PartVocals.Lyrics.Add(lastlyric);
            }

            foreach (Midi.NoteEvent item in chart.PartVocals.Gems)
            {
                bool found = false;
                foreach (Pair <NoteChart.Point, string> lyric in chart.PartVocals.Lyrics)
                {
                    if (lyric.Key.Time == item.Time)
                    {
                        if (item.Note == 26)
                        {
                            lyric.Value += "#";
                            item.Note    = 36;
                        }
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    chart.PartVocals.Lyrics.Add(new Pair <NoteChart.Point, string>(new NoteChart.Point(item.Time), "+"));
                }
            }
__goddamnremovals:
            //Midi.NoteEvent lastnote = null;
            foreach (Pair <NoteChart.Point, string> lyric in chart.PartVocals.Lyrics)
            {
                bool found = false;
                foreach (Midi.NoteEvent item in chart.PartVocals.Gems)
                {
                    if (lyric.Key.Time == item.Time)
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    /*
                     * ulong duration = chart.GetTicksDuration(chart.GetTime(lyric.Key.Time) / 1000, 30);
                     * if (lastnote != null && lastnote.Time + lastnote.Duration > lyric.Key.Time)
                     *      lastnote.Duration = lyric.Key.Time - lastnote.Time - 20;
                     * lastnote = new Midi.NoteEvent(lyric.Key.Time, 0, 36, 100, duration);
                     * chart.PartVocals.Gems.Add(lastnote);
                     * lyric.Value += "^";
                     */
                    chart.PartVocals.Lyrics.Remove(lyric);
                    goto __goddamnremovals;
                }
            }

            if (chart.PartVocals.Gems.Count == 0)
            {
                chart.PartVocals = null;
                return(false);
            }

            return(true);
        }