public void ChordNameProcessor_HandlesArpAndNopNames()
        {
            var testChordTemp1 = new ChordTemplate
            {
                Name        = "D9-arp",
                DisplayName = "D9-arp"
            };

            var testChordTemp2 = new ChordTemplate
            {
                Name        = "F5(no 3)-nop",
                DisplayName = "F5(no 3)-nop"
            };

            testArrangement.ChordTemplates.Add(testChordTemp1);
            testArrangement.ChordTemplates.Add(testChordTemp2);

            new ChordNameProcessor(new List <ImproverMessage>()).Apply(testArrangement, nullLog);

            testChordTemp1.Name.Should().Be("D9");
            testChordTemp1.DisplayName.Should().Be("D9-arp");

            testChordTemp2.Name.Should().Be("F5(no 3)");
            testChordTemp2.DisplayName.Should().Be("F5(no 3)-nop");
        }
        public TabChord(TabFile tabFile, Note note, SngFile sngFile)
            : base(tabFile, note)
        {
            ChordTemplate chord = sngFile.ChordTemplates[note.ChordId];

            ChordName = chord.Name;
            Frets     = new int[TabFile.StringCount];
            Frets[0]  = chord.Fret0;
            Frets[1]  = chord.Fret1;
            Frets[2]  = chord.Fret2;
            Frets[3]  = chord.Fret3;
            Frets[4]  = chord.Fret4;
            Frets[5]  = chord.Fret5;
        }
        public void ChordNameProcessor_CorrectsMinorChordNames()
        {
            var testChordTemp = new ChordTemplate
            {
                Name        = "Amin",
                DisplayName = "Amin"
            };

            testArrangement.ChordTemplates.Add(testChordTemp);

            new ChordNameProcessor(new List <ImproverMessage>()).Apply(testArrangement, nullLog);

            testChordTemp.Name.Should().Be("Am");
            testChordTemp.DisplayName.Should().Be("Am");
        }
Esempio n. 4
0
        public static int GetChordNote(short[] tuning, Chord chord, List <ChordTemplate> handShapes, int capo, bool bass = false)
        {
            ChordTemplate chordTemplate = handShapes[chord.ChordId];

            for (int @string = 0; @string < 6; @string++)
            {
                var fret = chordTemplate.Frets[@string];
                if (fret != -1)
                {
                    // Return lowest found note even if it is not the root
                    return(GetMIDINote(tuning, @string, fret, capo, bass));
                }
            }

            return(35);
        }
        public void ChordNameProcessor_HandlesOFChords(int number)
        {
            var testChordTemp = new ChordTemplate
            {
                Name        = $"OF{number}",
                DisplayName = $"OF{number}"
            };

            testChordTemp.SetFingering(1, -1, -1, -1, -1, -1);
            testChordTemp.SetFrets(8, -1, -1, -1, -1, -1);
            testArrangement.ChordTemplates.Add(testChordTemp);

            new ChordNameProcessor(new List <ImproverMessage>()).Apply(testArrangement, nullLog);

            testChordTemp.Name.Should().Be("");
            testChordTemp.DisplayName.Should().Be("");
            testChordTemp.Frets[0].Should().Be((sbyte)number);
        }
        public void ChordNameProcessor_CorrectsEmptyChordNames()
        {
            var testChordTemp1 = new ChordTemplate
            {
                Name        = " ",
                DisplayName = " "
            };
            var testChordTemp2 = new ChordTemplate
            {
                Name        = "   ",
                DisplayName = "   "
            };

            testArrangement.ChordTemplates.Add(testChordTemp1);
            testArrangement.ChordTemplates.Add(testChordTemp2);

            new ChordNameProcessor(new List <ImproverMessage>()).Apply(testArrangement, nullLog);

            testChordTemp1.Name.Should().Be("");
            testChordTemp1.DisplayName.Should().Be("");
            testChordTemp2.Name.Should().Be("");
            testChordTemp2.DisplayName.Should().Be("");
        }
Esempio n. 7
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
        }
        public void SlideOutEvent_CreatesHandshape()
        {
            const int chordTime   = 20222;
            const int sustainTime = 3000;

            var phrase = new Phrase("test", (byte)(testArrangement.Levels.Count - 1), PhraseMask.None);

            testArrangement.Phrases.Add(phrase);

            var phraseIter = new PhraseIteration(chordTime, testArrangement.Phrases.Count - 1);

            testArrangement.PhraseIterations.Add(phraseIter);

            var template = new ChordTemplate();

            template.SetFingering(1, 3, 3, -1, -1, -1);
            template.SetFrets(1, 3, 4, -1, -1, -1);

            testArrangement.ChordTemplates.Add(template);
            short chordId = (short)(testArrangement.ChordTemplates.Count - 1);

            var chord = new Chord
            {
                ChordId    = chordId,
                Time       = chordTime,
                ChordNotes = new List <Note>
                {
                    new Note
                    {
                        String         = 0,
                        Fret           = 1,
                        SlideUnpitchTo = 5,
                        Sustain        = sustainTime
                    },
                    new Note
                    {
                        String         = 1,
                        Fret           = 3,
                        SlideUnpitchTo = 7,
                        Sustain        = sustainTime
                    },
                    new Note
                    {
                        String         = 2,
                        Fret           = 3,
                        SlideUnpitchTo = 7,
                        Sustain        = sustainTime
                    }
                }
            };

            var hardestLevel = testArrangement.Levels.Last();

            var handshape = new HandShape(chordId, chordTime, chordTime + sustainTime);

            hardestLevel.Chords.Add(chord);
            hardestLevel.HandShapes.Add(handshape);
            testArrangement.Events.Add(new Event("so", chordTime));

            int handShapeCount     = hardestLevel.HandShapes.Count;
            int chordTemplateCount = testArrangement.ChordTemplates.Count;

            new CustomEventPostProcessor(new List <ImproverMessage>()).Apply(testArrangement, nullLog);

            testArrangement.Events.Should().NotContain(ev => ev.Code == "so");
            hardestLevel.HandShapes.Should().HaveCount(handShapeCount + 1);
            testArrangement.ChordTemplates.Should().HaveCount(chordTemplateCount + 1);
            handshape.EndTime.Should().BeLessThan(chordTime + sustainTime);
        }
Esempio n. 9
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;
        }