private SongNote GetNote(Chord chord, Chord nextChord)
 {
     SongNote note = new SongNote();
     Note zNote = chord.Notes[0];
     note.Fret = (sbyte)zNote.Fret;
     note.String = (byte)zNote.StringNo;
     note.Bend = 0;
     note.HammerOn = (zNote.IsTapNote || chord.IsHammerOn) ? (byte)1 : (byte)0;
     note.Harmonic = 0;
     note.Hopo = note.HammerOn;
     note.Ignore = 0;
     note.PalmMute = (zNote.IsXNote || chord.IsMute) ? (byte)1 : (byte)0;
     note.Sustain = (chord.EndTime - chord.StartTime > .5) ? chord.EndTime - chord.StartTime : 0;
     note.Time = (float)chord.StartTime;
     note.Tremolo = 0;
     if (chord.IsSlide && nextChord != null)
     {
         note.SlideTo = (sbyte)Math.Max(nextChord.Notes[0].Fret, 1);
         note.Sustain = chord.EndTime - chord.StartTime;
         note.HammerOn = note.Hopo = note.PalmMute = 0;
     }
     else
     {
         note.SlideTo = -1;
     }
     return note;
 }
 string HashChord(Chord chord)
 {
     string hash = "";
     chord.Notes.OrderBy(n => n.StringNo).ToList().ForEach(ch => hash += ch.StringNo + "." + ch.Fret + ".");
     return hash;
 }
 private Tuple<int, SongChordTemplate> GetChordTemplate(Chord zChord, Dictionary<string, Tuple<int, SongChordTemplate>> chordTemps)
 {
     Tuple<int, SongChordTemplate> val;
     if (!chordTemps.TryGetValue(HashChord(zChord), out val))
     {
         SongChordTemplate templ = new SongChordTemplate() { ChordName = "" };
         val = new Tuple<int, SongChordTemplate>(chordTemps.Count == 0 ? 0 : chordTemps.Values.Select(v => v.Item1).Max() + 1, templ);
         templ.Finger0 = templ.Finger1 = templ.Finger2 = templ.Finger3 = templ.Finger4 = templ.Finger5 = -1;
         templ.Fret0 = templ.Fret1 = templ.Fret2 = templ.Fret3 = templ.Fret4 = templ.Fret5 = -1;
         zChord.Notes.Where(n => n.StringNo == 0).ToList().ForEach(note => templ.Fret0 = (sbyte)note.Fret);
         zChord.Notes.Where(n => n.StringNo == 1).ToList().ForEach(note => templ.Fret1 = (sbyte)note.Fret);
         zChord.Notes.Where(n => n.StringNo == 2).ToList().ForEach(note => templ.Fret2 = (sbyte)note.Fret);
         zChord.Notes.Where(n => n.StringNo == 3).ToList().ForEach(note => templ.Fret3 = (sbyte)note.Fret);
         zChord.Notes.Where(n => n.StringNo == 4).ToList().ForEach(note => templ.Fret4 = (sbyte)note.Fret);
         zChord.Notes.Where(n => n.StringNo == 5).ToList().ForEach(note => templ.Fret5 = (sbyte)note.Fret);
         chordTemps[HashChord(zChord)] = val;
     }
     return val;
 }