Esempio 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);
        }
        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);
        }
Esempio n. 3
0
        public static Progression moreRecomendations(Progression progression)
        {
            string inputError = "\nI'm sorry that was not a valid coice." +
                                "\nPlease try again.";

            List <Chord> recomendations = new List <Chord>();
            Note         tonic          = NoteFactory.getNoteByValue(progression.getKey().getValue(), progression.getKey());
            bool         validChoice    = false;
            string       choice;
            int          i;

            while (validChoice == false)
            {
                i = 1;
                System.Console.WriteLine("1) I (" + progression.getMode().getNote(0, progression.getKey()).getName() + ")");
                if (progression.getMode().containsInterval(1))
                {
                    System.Console.WriteLine((i + 1) + ") bII (" + progression.getMode().getNote(i, progression.getKey()).getName() + ")");
                    i++;
                }
                if (progression.getMode().containsInterval(2))
                {
                    System.Console.WriteLine((i + 1) + ") II (" + progression.getMode().getNote(i, progression.getKey()).getName() + ")");
                    i++;
                }
                if (progression.getMode().containsInterval(3))
                {
                    System.Console.WriteLine(((i + 1) + 1) + ") bIII (" + progression.getMode().getNote(i, progression.getKey()).getName() + ")");
                    i++;
                }
                if (progression.getMode().containsInterval(4))
                {
                    System.Console.WriteLine((i + 1) + ") III (" + progression.getMode().getNote(i, progression.getKey()).getName() + ")");
                    i++;
                }
                if (progression.getMode().containsInterval(5))
                {
                    System.Console.WriteLine((i + 1) + ") IV (" + progression.getMode().getNote(i, progression.getKey()).getName() + ")");
                    i++;
                }
                if (progression.getMode().containsInterval(6))
                {
                    System.Console.WriteLine((i + 1) + ") bV (" + progression.getMode().getNote(i, progression.getKey()).getName() + ")");
                    i++;
                }
                if (progression.getMode().containsInterval(7))
                {
                    System.Console.WriteLine((i + 1) + ") V (" + progression.getMode().getNote(i, progression.getKey()).getName() + ")");
                    i++;
                }
                if (progression.getMode().containsInterval(8))
                {
                    System.Console.WriteLine((i + 1) + ") bVI (" + progression.getMode().getNote(i, progression.getKey()).getName() + ")");
                    i++;
                }
                if (progression.getMode().containsInterval(9))
                {
                    System.Console.WriteLine((i + 1) + ") VI (" + progression.getMode().getNote(i, progression.getKey()).getName() + ")");
                    i++;
                }
                if (progression.getMode().containsInterval(10))
                {
                    System.Console.WriteLine((i + 1) + ") bVII (" + progression.getMode().getNote(i, progression.getKey()).getName() + ")");
                    i++;
                }
                if (progression.getMode().containsInterval(11))
                {
                    System.Console.WriteLine((i + 1) + ") VII (" + progression.getMode().getNote(i, progression.getKey()).getName() + ")");
                    i++;
                }
                choice = System.Console.ReadLine();
                for (i = 1; i <= progression.getMode().getSize(); i++)
                {
                    if (i.ToString() == choice)
                    {
                        validChoice = true;
                        tonic       = progression.getMode().getNote(i - 1, progression.getKey());
                    }
                }
                if (validChoice == false)
                {
                    System.Console.WriteLine(inputError);
                }
            }
            validChoice    = false;
            recomendations = ChordFactory.getChordRecomendationsByTonic(progression.getKey(), tonic, progression.getMode());
            while (validChoice == false)
            {
                for (i = 0; i < recomendations.Count(); i++)
                {
                    System.Console.WriteLine((i + 1).ToString() + ") " + recomendations.ElementAt(i).getName());
                    if (i + 1 == recomendations.Count())
                    {
                        System.Console.WriteLine((i + 2).ToString() + ") Back to chord menu");
                    }
                }
                choice = System.Console.ReadLine();

                for (i = 1; i <= recomendations.Count(); i++)
                {
                    if (i.ToString() == choice)
                    {
                        validChoice = true;
                        progression.addChord(recomendations.ElementAt(i - 1));
                        System.Console.WriteLine("\n" + progression.getChord(progression.getSize() - 1).getName() + " has been added to the progression.");
                    }
                    else if ((i + 1).ToString() == choice)
                    {
                        validChoice = true;
                    }
                }
                if (validChoice == false)
                {
                    System.Console.WriteLine(inputError);
                }
            }
            return(progression);
        }