Ejemplo n.º 1
0
        public void ChordFactoryTest_getChordRecomendationsByDegree()
        {
            Note         key            = NoteFactory.getNoteByName("C");
            Note         degree         = NoteFactory.getNoteByName("G");
            Mode         mode           = ModeFactory.getModeByName("Ionian");
            List <Chord> recomendations = ChordFactory.getChordRecomendationsByTonic(key, degree, mode);

            Assert.IsTrue(recomendations.Count() > 1);
        }
Ejemplo n.º 2
0
        public static List <Chord> getChordRecomendationsByLast(Note key, Chord lastChord, Mode mode)
        {
            List <Chord> chords = new List <Chord>();
            List <Chord> fives  = new List <Chord>();
            List <Chord> sevens = new List <Chord>();
            List <Chord> sixes  = new List <Chord>();
            int          value;
            int          distance;
            Note         note;
            bool         foundDegree;
            bool         foundFifth   = false;
            bool         foundSeventh = false;
            bool         foundSixth   = false;

            // V -> I -> IV
            foundDegree = false;
            distance    = lastChord.getNoteAt(0).getValue() - key.getValue();
            if (distance < 12)
            {
                distance = distance + 12;
            }
            if (mode.containsInterval(7 + distance) || mode.containsInterval(7 + distance - 12))
            {
                value = lastChord.getNoteAt(0).getValue() + 7;
                if (value > 12)
                {
                    value = value - 12;
                }
                note        = NoteFactory.getNoteByValue(value, key);
                foundDegree = true;
            }
            // May add b5 and #5 recomendations back in

            /*
             * else if (mode.containsInterval(6))
             * {
             *  value = lastChord.getNoteAt(0).getValue() + 6;
             *  if (value > 12) { value = value - 12; }
             *  note = NoteFactory.getNoteByValue(value, key);
             *  foundDegree = true;
             * }
             * else if (mode.containsInterval(8))
             * {
             *  value = lastChord.getNoteAt(0).getValue() + 8;
             *  if (value > 12) { value = value - 12; }
             *  note = NoteFactory.getNoteByValue(value, key);
             *  foundDegree = true;
             * }
             */
            else
            {
                note = NoteFactory.getNoteByValue(key.getValue(), key);
            }
            if (foundDegree)
            {
                fives      = ChordFactory.getChordRecomendationsByTonic(key, note, mode);
                foundFifth = true;
            }

            // VII -> I -> II
            foundDegree = false;
            distance    = lastChord.getNoteAt(0).getValue() - key.getValue();
            if (distance < 12)
            {
                distance = distance + 12;
            }
            if (mode.containsInterval(10 + distance) || mode.containsInterval(10 + distance - 12))
            {
                value = lastChord.getNoteAt(0).getValue() + 10;
                if (value > 12)
                {
                    value = value - 12;
                }
                note        = NoteFactory.getNoteByValue(value, key);
                foundDegree = true;
            }
            else if (mode.containsInterval(11 + distance) || mode.containsInterval(11 + distance - 12))
            {
                value = lastChord.getNoteAt(0).getValue() + 11;
                if (value > 12)
                {
                    value = value - 12;
                }
                note        = NoteFactory.getNoteByValue(value, key);
                foundDegree = true;
            }
            else
            {
                note = NoteFactory.getNoteByValue(key.getValue(), key);
            }
            if (foundDegree)
            {
                sevens       = ChordFactory.getChordRecomendationsByTonic(key, note, mode);
                foundSeventh = true;
            }


            // VI -> I -> III
            foundDegree = false;
            distance    = lastChord.getNoteAt(0).getValue() - key.getValue();
            if (distance < 12)
            {
                distance = distance + 12;
            }
            if (mode.containsInterval(9 + distance) || mode.containsInterval(9 + distance - 12))
            {
                value = lastChord.getNoteAt(0).getValue() + 9;
                if (value > 12)
                {
                    value = value - 12;
                }
                note        = NoteFactory.getNoteByValue(value, key);
                foundDegree = true;
            }
            else if (mode.containsInterval(8 + distance) || mode.containsInterval(8 + distance - 12))
            {
                value = lastChord.getNoteAt(0).getValue() + 8;
                if (value > 12)
                {
                    value = value - 12;
                }
                note        = NoteFactory.getNoteByValue(value, key);
                foundDegree = true;
            }
            else
            {
                note = NoteFactory.getNoteByValue(key.getValue(), key);
            }
            if (foundDegree)
            {
                sixes      = ChordFactory.getChordRecomendationsByTonic(key, note, mode);
                foundSixth = true;
            }

            if (foundFifth)
            {
                chords.AddRange(fives);
            }
            if (foundSeventh)
            {
                chords.AddRange(sevens);
            }
            if (foundSixth)
            {
                chords.AddRange(sixes);
            }

            return(chords);
        }