コード例 #1
0
        private SongNote2014 DecodeChordTemplate(SongChord songChord, int gString, int fret)
        {
            // RS2014
            //<chord time="83.366" linkNext="0" accent="0" chordId="19" fretHandMute="0" highDensity="0" ignore="0" palmMute="0" hopo="0" strum="down">
            //  <chordNote time="83.366" linkNext="0" accent="0" bend="0" fret="3" hammerOn="0" harmonic="0" hopo="0" ignore="0" leftHand="-1" mute="0" palmMute="0" pluck="-1" pullOff="0" slap="-1" slideTo="-1" string="4" sustain="0.000" tremolo="0" harmonicPinch="0" pickDirection="0" rightHand="-1" slideUnpitchTo="-1" tap="0" vibrato="0"/>
            //  <chordNote time="83.366" linkNext="0" accent="0" bend="0" fret="3" hammerOn="0" harmonic="0" hopo="0" ignore="0" leftHand="-1" mute="0" palmMute="0" pluck="-1" pullOff="0" slap="-1" slideTo="-1" string="5" sustain="0.000" tremolo="0" harmonicPinch="0" pickDirection="0" rightHand="-1" slideUnpitchTo="-1" tap="0" vibrato="0"/>
            //</chord>

            // RS1
            //<chord time="83.366" chordId="1" highDensity="0" ignore="0" strum="down"/>
            //<chordTemplate chordName="A" finger0="-1" finger1="0" finger2="1" finger3="1" finger4="1" finger5="-1" fret0="-1" fret1="0" fret2="2" fret3="2" fret4="2" fret5="-1"/>

            // finger > -1 is actual string

            SongNote2014 songNote2014 = new SongNote2014();

            songNote2014.Time           = songChord.Time;
            songNote2014.LinkNext       = 0;
            songNote2014.Accent         = 0;
            songNote2014.Bend           = 0;
            songNote2014.Fret           = (sbyte)fret;
            songNote2014.HammerOn       = 0;
            songNote2014.Hopo           = 0;
            songNote2014.Ignore         = songChord.Ignore;
            songNote2014.LeftHand       = -1;
            songNote2014.Mute           = 0;
            songNote2014.PalmMute       = 0;
            songNote2014.Pluck          = -1;
            songNote2014.PullOff        = 0;
            songNote2014.Slap           = -1;
            songNote2014.SlideTo        = -1;
            songNote2014.String         = (byte)gString;
            songNote2014.Sustain        = 0.000f;
            songNote2014.Tremolo        = 0;
            songNote2014.HarmonicPinch  = 0;
            songNote2014.PickDirection  = 0;
            songNote2014.RightHand      = -1;
            songNote2014.SlideUnpitchTo = -1;
            songNote2014.Tap            = 0;
            songNote2014.Vibrato        = 0;

            return(songNote2014);
        }
コード例 #2
0
        private void AddNotes(RsSong rsSong, Song zigSong)
        {
            int spread     = 3;
            var notes      = new Dictionary <string, List <SongNote> >();
            var chords     = new Dictionary <string, List <SongChord> >();
            var anchors    = new Dictionary <string, List <SongAnchor> >();
            var handShapes = new Dictionary <string, List <SongHandShape> >();

            var chordTemps  = new Dictionary <string, Tuple <int, SongChordTemplate> >();
            var guitarTrack = GetTrack(zigSong);

            foreach (var group in guitarTrack.Chords.GroupBy(chord => chord.Difficulty))
            {
                var gNotes      = notes[group.Key] = new List <SongNote>();
                var gChords     = chords[group.Key] = new List <SongChord>();
                var gAnchors    = anchors[group.Key] = new List <SongAnchor>();
                var gHandShapes = handShapes[group.Key] = new List <SongHandShape>();
                var zChords     = group.OrderBy(chord => chord.StartTime).ToList();
                var lastMeasure = 0;
                int highFret    = -1;
                //bool lastWasChord = false;
                SongAnchor curAnchor = null;
                for (int i = 0; i < zChords.Count; i++)
                {
                    var zChord = zChords[i];
                    if (zChord.Notes.Count > 1)
                    {
                        Tuple <int, SongChordTemplate> val = GetChordTemplate(zChord, chordTemps);

                        int minCFret = Math.Min(DeZero(val.Item2.Fret0),
                                                Math.Min(DeZero(val.Item2.Fret1),
                                                         Math.Min(DeZero(val.Item2.Fret2),
                                                                  Math.Min(DeZero(val.Item2.Fret3),
                                                                           Math.Min(DeZero(val.Item2.Fret4), DeZero(val.Item2.Fret5))))));

                        if (minCFret != int.MaxValue)
                        {
                            if (curAnchor == null)
                            {
                                if (gAnchors.Count == 0 || gAnchors[gAnchors.Count - 1].Fret != minCFret)
                                {
                                    gAnchors.Add(new SongAnchor {
                                        Fret = Math.Min(19, minCFret), Time = zChord.StartTime
                                    });
                                }
                            }
                            else
                            {
                                if (minCFret + spread <= highFret)
                                {
                                    curAnchor.Fret = minCFret;
                                }
                                gAnchors.Add(curAnchor);
                                if (curAnchor.Fret != minCFret)
                                {
                                    gAnchors.Add(new SongAnchor {
                                        Fret = Math.Min(19, minCFret), Time = zChord.StartTime
                                    });
                                }
                                curAnchor = null;
                            }
                        }
                        SongHandShape handShape = new SongHandShape {
                            ChordId = val.Item1, StartTime = zChord.StartTime
                        };
                        do
                        {
                            SongChord chord = new SongChord();
                            chord.Time    = zChord.StartTime;
                            chord.ChordId = val.Item1;

                            var measure = rsSong.Ebeats.FirstOrDefault(ebeat => ebeat.Time >= chord.Time);
                            if (measure == null || measure.Measure > lastMeasure)
                            {
                                lastMeasure       = measure == null ? lastMeasure : measure.Measure;
                                chord.HighDensity = 0;
                            }
                            else if (gChords.Count == 0 || gChords[gChords.Count - 1].ChordId != chord.ChordId)
                            {
                                chord.HighDensity = 0;
                            }
                            else
                            {
                                chord.HighDensity = 1;
                            }
                            gChords.Add(chord);
                            if (i + 1 < zChords.Count)
                            {
                                zChord = zChords[i + 1];
                            }
                        } while (i + 1 < zChords.Count && zChord.Notes.Count > 1 && val.Item1 == GetChordTemplate(zChord, chordTemps).Item1&& ++i != -1);
                        handShape.EndTime = zChord.StartTime;
                        if (handShape.EndTime > handShape.StartTime)
                        {
                            handShape.EndTime -= (handShape.EndTime - zChords[i].EndTime) / 2;
                        }
                        gHandShapes.Add(handShape);
                    }
                    else
                    {
                        var note = GetNote(zChord, i == zChords.Count - 1 ? null : zChords[i + 1]);
                        if (note.Fret > 0)
                        {
                            if (curAnchor == null)
                            {
                                curAnchor = new SongAnchor {
                                    Fret = Math.Min(19, (int)note.Fret), Time = note.Time
                                };
                                highFret = note.Fret;
                            }
                            else if (note.Fret < curAnchor.Fret)
                            {
                                if (note.Fret + spread >= highFret)
                                {
                                    curAnchor.Fret = note.Fret;
                                }
                                else
                                {
                                    gAnchors.Add(curAnchor);
                                    curAnchor = new SongAnchor {
                                        Fret = Math.Min(19, (int)note.Fret), Time = note.Time
                                    };
                                    highFret = note.Fret;
                                }
                            }
                            else if (note.Fret > highFret)
                            {
                                if (note.Fret - spread <= curAnchor.Fret)
                                {
                                    highFret = note.Fret;
                                }
                                else
                                {
                                    gAnchors.Add(curAnchor);
                                    curAnchor = new SongAnchor {
                                        Fret = Math.Min(19, (int)note.Fret), Time = note.Time
                                    };
                                    highFret = note.Fret;
                                }
                            }
                        }
                        gNotes.Add(note);
                    }
                }
                if (curAnchor != null)
                {
                    gAnchors.Add(curAnchor);
                }
            }

            rsSong.Levels = new SongLevel[]
            {
                new SongLevel {
                    Difficulty = 0,
                    Notes      = notes["Easy"].ToArray(),
                    Chords     = chords["Easy"].ToArray(),
                    Anchors    = anchors["Easy"].ToArray(),
                    HandShapes = handShapes["Easy"].ToArray()
                },
                new SongLevel {
                    Difficulty = 1,
                    Notes      = notes["Medium"].ToArray(),
                    Chords     = chords["Medium"].ToArray(),
                    Anchors    = anchors["Medium"].ToArray(),
                    HandShapes = handShapes["Medium"].ToArray()
                },
                new SongLevel {
                    Difficulty = 2,
                    Notes      = notes["Hard"].ToArray(),
                    Chords     = chords["Hard"].ToArray(),
                    Anchors    = anchors["Hard"].ToArray(),
                    HandShapes = handShapes["Hard"].ToArray()
                },
                new SongLevel {
                    Difficulty = 3,
                    Notes      = notes["Expert"].ToArray(),
                    Chords     = chords["Expert"].ToArray(),
                    Anchors    = anchors["Expert"].ToArray(),
                    HandShapes = handShapes["Expert"].ToArray()
                }
            };
            rsSong.ChordTemplates = chordTemps.Values.OrderBy(v => v.Item1).Select(v => v.Item2).ToArray();
        }