示例#1
0
        static Dictionary <int, ChordTemplate> GetChordTemplates(Song2014 arrangement)
        {
            var templates = new Dictionary <int, ChordTemplate>();

            for (int i = 0; i < arrangement.ChordTemplates.Length; ++i)
            {
                var rsTemplate = arrangement.ChordTemplates[i];

                var template = new ChordTemplate()
                {
                    ChordId = i,
                    Name    = rsTemplate.ChordName,
                    Frets   = new int[] { rsTemplate.Fret0, rsTemplate.Fret1, rsTemplate.Fret2,
                                          rsTemplate.Fret3, rsTemplate.Fret4, rsTemplate.Fret5 },
                    Fingers = new int[] { rsTemplate.Finger0, rsTemplate.Finger1,
                                          rsTemplate.Finger2, rsTemplate.Finger3, rsTemplate.Finger4,
                                          rsTemplate.Finger5 }
                };
                // correct for capo position. this is necessary since Rocksmith is weird when using
                // a capo: the open string is indexed as 0, but any pressed fret is given as the
                // absolute fret, not relative to the capo.
                for (int j = 0; j < 6; ++j)
                {
                    if (template.Frets[j] > 0)
                    {
                        template.Frets[j] -= arrangement.Capo;
                    }
                }

                templates.Add(template.ChordId, template);
            }

            return(templates);
        }
示例#2
0
        private void WriteChordTemplate(ChordTemplate template)
        {
            // basic default options (don't need to mess with this)
            writer.Write(new Byte[] { 1, 1, 0, 0, 0, 12, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0 });
            // chord name padded to 20 bytes
            var chordName = template.Name.Substring(0, Math.Min(20, template.Name.Length));

            writer.Write(chordName);
            for (int i = chordName.Length; i < 20; ++i)
            {
                writer.Write((Byte)0);
            }
            writer.Write((short)0); // padding
            writer.Write((short)0); // tonality of ninth/fifth
            writer.Write((Byte)0);  // tonality of eleventh

            // we need to determine at what base fret to start the chord diagram
            int minFret = 100;
            int maxFret = 0;

            for (int i = 0; i < 6; ++i)
            {
                if (template.Frets[i] > 0)
                {
                    minFret = Math.Min(template.Frets[i], minFret);
                    maxFret = Math.Max(template.Frets[i], maxFret);
                }
            }
            if (maxFret <= 5)
            {
                minFret = 1;
            }
            writer.Write((Int32)minFret);
            // write the frets for each string
            for (int i = 5; i >= 0; --i)
            {
                writer.Write((Int32)template.Frets[i]);
            }
            writer.Write((Int32)(-1));  // 7-th string, not used

            //for (int i = 0; i < 32; ++i)
            //    writer.Write((Byte)0);
            // barre definitions
            writer.Write((Byte)0);
            for (int i = 0; i < 5; ++i)
            {
                writer.Write((Byte)0);
                writer.Write((Byte)0);
                writer.Write((Byte)0);
            }

            // whether the chord contains certain intervals, irrelevant
            writer.Write((Int32)0);
            writer.Write((Int32)0);

            // finger positions
            for (int i = 5; i >= 0; --i)
            {
                writer.Write((Byte)template.Fingers[i]);
            }
            writer.Write((Byte)255); // 7-th string, not used
            writer.Write((Byte)1);   // display fingerings
        }