Example #1
0
        private void ParseChordNotes(Sng2014HSL.Chord template, Sng2014HSL.ChordNotes chordNotes = null)
        {
            var notes    = new List <SongNote2014>();
            var notSetup = unchecked ((sbyte)-1);

            for (var i = 0; i < 6; i++)
            {
                if ((chordNotes != null && chordNotes.NoteMask[i] != 0) || //notes with techniques
                    (chordNotes == null && template.Frets[i] != 255))      // Notes without techniques

                {
                    var cnote = new SongNote2014();

                    // SETUP DEFAULT VALUES
                    cnote.RightHand      = notSetup;
                    cnote.LeftHand       = notSetup;
                    cnote.SlideTo        = notSetup;
                    cnote.SlideUnpitchTo = notSetup;
                    cnote.Tap            = (byte)0;
                    cnote.Slap           = notSetup;
                    cnote.Pluck          = notSetup;

                    if ((chordNotes != null && chordNotes.NoteMask[i] != 0))
                    {
                        // SETUP FROM OWN PROPERTIES
                        cnote.parseNoteMask(chordNotes.NoteMask[i]);
                        cnote.SlideTo        = (sbyte)chordNotes.SlideTo[i];
                        cnote.SlideUnpitchTo = (sbyte)chordNotes.SlideUnpitchTo[i];
                        cnote.Vibrato        = chordNotes.Vibrato[i];
                        cnote.BendValues     = BendValue.Parse(chordNotes.BendData[i].BendData32);
                        //Fix bend status from step in bendvalues
                        if (cnote.BendValues != null && cnote.BendValues.Length > 0)
                        {
                            foreach (var bend in cnote.BendValues)
                            {
                                if (cnote.Bend < bend.Step)
                                {
                                    cnote.Bend = (byte)Math.Round(bend.Step);
                                }
                            }
                        }
                    }

                    // BASIC INFO
                    cnote.Time     = this.Time;
                    cnote.Fret     = (sbyte)template.Frets[i];
                    cnote.LeftHand = (sbyte)template.Fingers[i];
                    cnote.String   = (byte)i;

                    notes.Add(cnote);
                }
            }

            this.ChordNotes = notes.ToArray();
        }
        internal static BendValue[] Parse(Sng2014HSL.BendData32[] bendData)
        {
            var bendValues = new List<BendValue>();

            for (var i = 0; i < bendData.Length; i++) {
                if (bendData[i].Time > 0 && bendData[i].Step > 0) {
                    var bend = new BendValue();
                    bend.Time = bendData[i].Time;
                    bend.Step = bendData[i].Step;
                    bend.Unk5 = bendData[i].Unk5;
                    bendValues.Add(bend);
                }
            }

            return (bendValues.Count > 0) ? bendValues.ToArray() : null;
        }
        internal static BendValue[] Parse(Sng2014HSL.BendData32[] bendData)
        {
            var bendValues = new List <BendValue>();

            for (var i = 0; i < bendData.Length; i++)
            {
                if (bendData[i].Time > 0 && bendData[i].Step >= 0)
                {
                    var bend = new BendValue();
                    bend.Time = bendData[i].Time;
                    bend.Step = bendData[i].Step;
                    bend.Unk5 = bendData[i].Unk5;
                    bendValues.Add(bend);
                }
            }

            return((bendValues.Count > 0) ? bendValues.ToArray() : null);
        }
        internal static SongNote2014[] Parse(Sng2014HSL.NotesSection notesSection)
        {
            var notes = new List <SongNote2014>();

            for (var i = 0; i < notesSection.Count; i++)
            {
                if (notesSection.Notes[i].ChordId != -1)
                {
                    continue; //Skip chord notes (get only single notes)
                }
                var note = new SongNote2014();

                // BASIC INFO
                note.Time   = notesSection.Notes[i].Time;
                note.Fret   = (sbyte)notesSection.Notes[i].FretId;
                note.String = notesSection.Notes[i].StringIndex;

                // TECHNIQUES
                note.PickDirection = notesSection.Notes[i].PickDirection;
                note.parseNoteMask(notesSection.Notes[i].NoteMask); //NOTE MASK need to be setup previous get property values
                // Techniques with own properties
                if (notesSection.Notes[i].LeftHand != 255)
                {
                    note.LeftHand = (sbyte)notesSection.Notes[i].LeftHand;
                }
                if (notesSection.Notes[i].SlideTo != 255)
                {
                    note.SlideTo = (sbyte)notesSection.Notes[i].SlideTo;
                }
                if (notesSection.Notes[i].SlideUnpitchTo != 255)
                {
                    note.SlideUnpitchTo = (sbyte)notesSection.Notes[i].SlideUnpitchTo;
                }
                if (notesSection.Notes[i].Tap != 255)
                {
                    note.Tap = notesSection.Notes[i].Tap;
                }
                if (notesSection.Notes[i].Slap != 255)
                {
                    note.Slap = (sbyte)notesSection.Notes[i].Slap;
                }
                if (notesSection.Notes[i].Pluck != 255)
                {
                    note.Pluck = (sbyte)notesSection.Notes[i].Pluck;
                }
                if (notesSection.Notes[i].Vibrato != 0)
                {
                    note.Vibrato = notesSection.Notes[i].Vibrato;
                }
                if (notesSection.Notes[i].Sustain != 0)
                {
                    note.Sustain = notesSection.Notes[i].Sustain;
                }
                if (notesSection.Notes[i].MaxBend != 0)
                {
                    note.Bend = notesSection.Notes[i].MaxBend;
                }
                note.BendValues = BendValue.Parse(notesSection.Notes[i].BendData.BendData);

                notes.Add(note);
            }

            return(notes.ToArray());
        }