예제 #1
0
        private static Note calculateNote(int distance, Note _key)
        {
            int next = _key.getValue() + distance;

            if (next > 12)
            {
                next = next - 12;
            }
            return(NoteFactory.getNoteByValue(next, _key));
        }
        public Note getNote(int guitarString, int fret, Note key)
        {
            int value = fret + tuning.ElementAt(guitarString - 1).getValue();

            while (value > 12)
            {
                value = value - 12;
            }
            return(NoteFactory.getNoteByValue(value, key));
        }
        public Note getNote(int index, Note key)
        {
            int  distance;
            Note note;

            distance = intervals.ElementAt(index).getIntervalValue() + key.getValue();
            if (distance > 12)
            {
                distance = distance - 12;
            }
            note = NoteFactory.getNoteByValue(distance, key);
            return(note);
        }
예제 #4
0
        public static List <Chord> getChordRecomendationsTriads(Note key, Mode mode)
        {
            int          i;
            int          tonicValueCheck;
            Note         tonic;
            List <Chord> chords = new List <Chord>();

            for (i = 0; i < 12; i++)
            {
                tonicValueCheck = key.getValue() + i;
                if (tonicValueCheck > 12)
                {
                    tonicValueCheck = tonicValueCheck - 12;
                }
                tonic = NoteFactory.getNoteByValue(tonicValueCheck, key);

                if (mode.containsInterval(i))
                {
                    // augmented 0 4 8
                    if ((mode.containsInterval(4 + i) || (mode.containsInterval((4 + i) - 12))) &&
                        (mode.containsInterval(8 + i) || (mode.containsInterval((8 + i) - 12))))
                    {
                        chords.Add(ChordFactory.getChordByName(tonic.getName() + "aug"));
                    }

                    // major 0 4 7
                    if ((mode.containsInterval(4 + i) || (mode.containsInterval((4 + i) - 12))) &&
                        (mode.containsInterval(7 + i) || (mode.containsInterval((7 + i) - 12))))
                    {
                        chords.Add(ChordFactory.getChordByName(tonic.getName()));
                    }

                    // minor 0 3 7
                    if ((mode.containsInterval(3 + i) || (mode.containsInterval((3 + i) - 12))) &&
                        (mode.containsInterval(7 + i) || (mode.containsInterval((7 + i) - 12))))
                    {
                        chords.Add(ChordFactory.getChordByName(tonic.getName() + "m"));
                    }

                    // diminished 0 3 6
                    if ((mode.containsInterval(3 + i) || (mode.containsInterval((3 + i) - 12))) &&
                        (mode.containsInterval(6 + i) || (mode.containsInterval((6 + i) - 12))))
                    {
                        chords.Add(ChordFactory.getChordByName(tonic.getName() + "dim"));
                    }
                }
            }
            return(chords);
        }
예제 #5
0
        public void NoteFactoryTest_getNoteByValue()
        {
            Note _key = NoteFactory.getNoteByName("A");

            _note = NoteFactory.getNoteByValue(1, _key);
            Assert.AreEqual("A", _note.getName());
            _note = NoteFactory.getNoteByValue(2, _key);
            Assert.AreEqual("Bb", _note.getName());
            _note = NoteFactory.getNoteByValue(3, _key);
            Assert.AreEqual("B", _note.getName());
            _note = NoteFactory.getNoteByValue(4, _key);
            Assert.AreEqual("C", _note.getName());
            _note = NoteFactory.getNoteByValue(5, _key);
            Assert.AreEqual("C#", _note.getName());
            _note = NoteFactory.getNoteByValue(6, _key);
            Assert.AreEqual("D", _note.getName());
            _note = NoteFactory.getNoteByValue(7, _key);
            Assert.AreEqual("Eb", _note.getName());
            _note = NoteFactory.getNoteByValue(8, _key);
            Assert.AreEqual("E", _note.getName());
            _note = NoteFactory.getNoteByValue(9, _key);
            Assert.AreEqual("F", _note.getName());
            _note = NoteFactory.getNoteByValue(10, _key);
            Assert.AreEqual("F#", _note.getName());
            _note = NoteFactory.getNoteByValue(11, _key);
            Assert.AreEqual("G", _note.getName());
            _note = NoteFactory.getNoteByValue(12, _key);
            Assert.AreEqual("G#", _note.getName());

            _key  = NoteFactory.getNoteByName("A#");
            _note = NoteFactory.getNoteByValue(1, _key);
            Assert.AreEqual("A", _note.getName());
            _note = NoteFactory.getNoteByValue(2, _key);
            Assert.AreEqual("A#", _note.getName());
            _note = NoteFactory.getNoteByValue(3, _key);
            Assert.AreEqual("B", _note.getName());
            _note = NoteFactory.getNoteByValue(4, _key);
            Assert.AreEqual("C", _note.getName());
            _note = NoteFactory.getNoteByValue(5, _key);
            Assert.AreEqual("C#", _note.getName());
            _note = NoteFactory.getNoteByValue(6, _key);
            Assert.AreEqual("D", _note.getName());
            _note = NoteFactory.getNoteByValue(7, _key);
            Assert.AreEqual("D#", _note.getName());
            _note = NoteFactory.getNoteByValue(8, _key);
            Assert.AreEqual("E", _note.getName());
            _note = NoteFactory.getNoteByValue(9, _key);
            Assert.AreEqual("F", _note.getName());
            _note = NoteFactory.getNoteByValue(10, _key);
            Assert.AreEqual("F#", _note.getName());
            _note = NoteFactory.getNoteByValue(11, _key);
            Assert.AreEqual("G", _note.getName());
            _note = NoteFactory.getNoteByValue(12, _key);
            Assert.AreEqual("G#", _note.getName());

            _key  = NoteFactory.getNoteByName("Bb");
            _note = NoteFactory.getNoteByValue(1, _key);
            Assert.AreEqual("A", _note.getName());
            _note = NoteFactory.getNoteByValue(2, _key);
            Assert.AreEqual("Bb", _note.getName());
            _note = NoteFactory.getNoteByValue(3, _key);
            Assert.AreEqual("B", _note.getName());
            _note = NoteFactory.getNoteByValue(4, _key);
            Assert.AreEqual("C", _note.getName());
            _note = NoteFactory.getNoteByValue(5, _key);
            Assert.AreEqual("Db", _note.getName());
            _note = NoteFactory.getNoteByValue(6, _key);
            Assert.AreEqual("D", _note.getName());
            _note = NoteFactory.getNoteByValue(7, _key);
            Assert.AreEqual("Eb", _note.getName());
            _note = NoteFactory.getNoteByValue(8, _key);
            Assert.AreEqual("E", _note.getName());
            _note = NoteFactory.getNoteByValue(9, _key);
            Assert.AreEqual("F", _note.getName());
            _note = NoteFactory.getNoteByValue(10, _key);
            Assert.AreEqual("Gb", _note.getName());
            _note = NoteFactory.getNoteByValue(11, _key);
            Assert.AreEqual("G", _note.getName());
            _note = NoteFactory.getNoteByValue(12, _key);
            Assert.AreEqual("Ab", _note.getName());

            _key  = NoteFactory.getNoteByName("B");
            _note = NoteFactory.getNoteByValue(1, _key);
            Assert.AreEqual("A", _note.getName());
            _note = NoteFactory.getNoteByValue(2, _key);
            Assert.AreEqual("A#", _note.getName());
            _note = NoteFactory.getNoteByValue(3, _key);
            Assert.AreEqual("B", _note.getName());
            _note = NoteFactory.getNoteByValue(4, _key);
            Assert.AreEqual("C", _note.getName());
            _note = NoteFactory.getNoteByValue(5, _key);
            Assert.AreEqual("C#", _note.getName());
            _note = NoteFactory.getNoteByValue(6, _key);
            Assert.AreEqual("D", _note.getName());
            _note = NoteFactory.getNoteByValue(7, _key);
            Assert.AreEqual("D#", _note.getName());
            _note = NoteFactory.getNoteByValue(8, _key);
            Assert.AreEqual("E", _note.getName());
            _note = NoteFactory.getNoteByValue(9, _key);
            Assert.AreEqual("F", _note.getName());
            _note = NoteFactory.getNoteByValue(10, _key);
            Assert.AreEqual("F#", _note.getName());
            _note = NoteFactory.getNoteByValue(11, _key);
            Assert.AreEqual("G", _note.getName());
            _note = NoteFactory.getNoteByValue(12, _key);
            Assert.AreEqual("G#", _note.getName());

            _key  = NoteFactory.getNoteByName("C");
            _note = NoteFactory.getNoteByValue(1, _key);
            Assert.AreEqual("A", _note.getName());
            _note = NoteFactory.getNoteByValue(2, _key);
            Assert.AreEqual("Bb", _note.getName());
            _note = NoteFactory.getNoteByValue(3, _key);
            Assert.AreEqual("B", _note.getName());
            _note = NoteFactory.getNoteByValue(4, _key);
            Assert.AreEqual("C", _note.getName());
            _note = NoteFactory.getNoteByValue(5, _key);
            Assert.AreEqual("Db", _note.getName());
            _note = NoteFactory.getNoteByValue(6, _key);
            Assert.AreEqual("D", _note.getName());
            _note = NoteFactory.getNoteByValue(7, _key);
            Assert.AreEqual("Eb", _note.getName());
            _note = NoteFactory.getNoteByValue(8, _key);
            Assert.AreEqual("E", _note.getName());
            _note = NoteFactory.getNoteByValue(9, _key);
            Assert.AreEqual("F", _note.getName());
            _note = NoteFactory.getNoteByValue(10, _key);
            Assert.AreEqual("Gb", _note.getName());
            _note = NoteFactory.getNoteByValue(11, _key);
            Assert.AreEqual("G", _note.getName());
            _note = NoteFactory.getNoteByValue(12, _key);
            Assert.AreEqual("Ab", _note.getName());

            _key  = NoteFactory.getNoteByName("C#");
            _note = NoteFactory.getNoteByValue(1, _key);
            Assert.AreEqual("A", _note.getName());
            _note = NoteFactory.getNoteByValue(2, _key);
            Assert.AreEqual("A#", _note.getName());
            _note = NoteFactory.getNoteByValue(3, _key);
            Assert.AreEqual("B", _note.getName());
            _note = NoteFactory.getNoteByValue(4, _key);
            Assert.AreEqual("C", _note.getName());
            _note = NoteFactory.getNoteByValue(5, _key);
            Assert.AreEqual("C#", _note.getName());
            _note = NoteFactory.getNoteByValue(6, _key);
            Assert.AreEqual("D", _note.getName());
            _note = NoteFactory.getNoteByValue(7, _key);
            Assert.AreEqual("D#", _note.getName());
            _note = NoteFactory.getNoteByValue(8, _key);
            Assert.AreEqual("E", _note.getName());
            _note = NoteFactory.getNoteByValue(9, _key);
            Assert.AreEqual("F", _note.getName());
            _note = NoteFactory.getNoteByValue(10, _key);
            Assert.AreEqual("F#", _note.getName());
            _note = NoteFactory.getNoteByValue(11, _key);
            Assert.AreEqual("G", _note.getName());
            _note = NoteFactory.getNoteByValue(12, _key);
            Assert.AreEqual("G#", _note.getName());

            _key  = NoteFactory.getNoteByName("Db");
            _note = NoteFactory.getNoteByValue(1, _key);
            Assert.AreEqual("A", _note.getName());
            _note = NoteFactory.getNoteByValue(2, _key);
            Assert.AreEqual("Bb", _note.getName());
            _note = NoteFactory.getNoteByValue(3, _key);
            Assert.AreEqual("B", _note.getName());
            _note = NoteFactory.getNoteByValue(4, _key);
            Assert.AreEqual("C", _note.getName());
            _note = NoteFactory.getNoteByValue(5, _key);
            Assert.AreEqual("Db", _note.getName());
            _note = NoteFactory.getNoteByValue(6, _key);
            Assert.AreEqual("D", _note.getName());
            _note = NoteFactory.getNoteByValue(7, _key);
            Assert.AreEqual("Eb", _note.getName());
            _note = NoteFactory.getNoteByValue(8, _key);
            Assert.AreEqual("E", _note.getName());
            _note = NoteFactory.getNoteByValue(9, _key);
            Assert.AreEqual("F", _note.getName());
            _note = NoteFactory.getNoteByValue(10, _key);
            Assert.AreEqual("Gb", _note.getName());
            _note = NoteFactory.getNoteByValue(11, _key);
            Assert.AreEqual("G", _note.getName());
            _note = NoteFactory.getNoteByValue(12, _key);
            Assert.AreEqual("Ab", _note.getName());

            _key  = NoteFactory.getNoteByName("D");
            _note = NoteFactory.getNoteByValue(1, _key);
            Assert.AreEqual("A", _note.getName());
            _note = NoteFactory.getNoteByValue(2, _key);
            Assert.AreEqual("Bb", _note.getName());
            _note = NoteFactory.getNoteByValue(3, _key);
            Assert.AreEqual("B", _note.getName());
            _note = NoteFactory.getNoteByValue(4, _key);
            Assert.AreEqual("C", _note.getName());
            _note = NoteFactory.getNoteByValue(5, _key);
            Assert.AreEqual("C#", _note.getName());
            _note = NoteFactory.getNoteByValue(6, _key);
            Assert.AreEqual("D", _note.getName());
            _note = NoteFactory.getNoteByValue(7, _key);
            Assert.AreEqual("Eb", _note.getName());
            _note = NoteFactory.getNoteByValue(8, _key);
            Assert.AreEqual("E", _note.getName());
            _note = NoteFactory.getNoteByValue(9, _key);
            Assert.AreEqual("F", _note.getName());
            _note = NoteFactory.getNoteByValue(10, _key);
            Assert.AreEqual("F#", _note.getName());
            _note = NoteFactory.getNoteByValue(11, _key);
            Assert.AreEqual("G", _note.getName());
            _note = NoteFactory.getNoteByValue(12, _key);
            Assert.AreEqual("Ab", _note.getName());

            _key  = NoteFactory.getNoteByName("D#");
            _note = NoteFactory.getNoteByValue(1, _key);
            Assert.AreEqual("A", _note.getName());
            _note = NoteFactory.getNoteByValue(2, _key);
            Assert.AreEqual("A#", _note.getName());
            _note = NoteFactory.getNoteByValue(3, _key);
            Assert.AreEqual("B", _note.getName());
            _note = NoteFactory.getNoteByValue(4, _key);
            Assert.AreEqual("C", _note.getName());
            _note = NoteFactory.getNoteByValue(5, _key);
            Assert.AreEqual("C#", _note.getName());
            _note = NoteFactory.getNoteByValue(6, _key);
            Assert.AreEqual("D", _note.getName());
            _note = NoteFactory.getNoteByValue(7, _key);
            Assert.AreEqual("D#", _note.getName());
            _note = NoteFactory.getNoteByValue(8, _key);
            Assert.AreEqual("E", _note.getName());
            _note = NoteFactory.getNoteByValue(9, _key);
            Assert.AreEqual("F", _note.getName());
            _note = NoteFactory.getNoteByValue(10, _key);
            Assert.AreEqual("F#", _note.getName());
            _note = NoteFactory.getNoteByValue(11, _key);
            Assert.AreEqual("G", _note.getName());
            _note = NoteFactory.getNoteByValue(12, _key);
            Assert.AreEqual("G#", _note.getName());

            _key  = NoteFactory.getNoteByName("Eb");
            _note = NoteFactory.getNoteByValue(1, _key);
            Assert.AreEqual("A", _note.getName());
            _note = NoteFactory.getNoteByValue(2, _key);
            Assert.AreEqual("Bb", _note.getName());
            _note = NoteFactory.getNoteByValue(3, _key);
            Assert.AreEqual("B", _note.getName());
            _note = NoteFactory.getNoteByValue(4, _key);
            Assert.AreEqual("C", _note.getName());
            _note = NoteFactory.getNoteByValue(5, _key);
            Assert.AreEqual("Db", _note.getName());
            _note = NoteFactory.getNoteByValue(6, _key);
            Assert.AreEqual("D", _note.getName());
            _note = NoteFactory.getNoteByValue(7, _key);
            Assert.AreEqual("Eb", _note.getName());
            _note = NoteFactory.getNoteByValue(8, _key);
            Assert.AreEqual("E", _note.getName());
            _note = NoteFactory.getNoteByValue(9, _key);
            Assert.AreEqual("F", _note.getName());
            _note = NoteFactory.getNoteByValue(10, _key);
            Assert.AreEqual("Gb", _note.getName());
            _note = NoteFactory.getNoteByValue(11, _key);
            Assert.AreEqual("G", _note.getName());
            _note = NoteFactory.getNoteByValue(12, _key);
            Assert.AreEqual("Ab", _note.getName());

            _key  = NoteFactory.getNoteByName("E");
            _note = NoteFactory.getNoteByValue(1, _key);
            Assert.AreEqual("A", _note.getName());
            _note = NoteFactory.getNoteByValue(2, _key);
            Assert.AreEqual("Bb", _note.getName());
            _note = NoteFactory.getNoteByValue(3, _key);
            Assert.AreEqual("B", _note.getName());
            _note = NoteFactory.getNoteByValue(4, _key);
            Assert.AreEqual("C", _note.getName());
            _note = NoteFactory.getNoteByValue(5, _key);
            Assert.AreEqual("C#", _note.getName());
            _note = NoteFactory.getNoteByValue(6, _key);
            Assert.AreEqual("D", _note.getName());
            _note = NoteFactory.getNoteByValue(7, _key);
            Assert.AreEqual("D#", _note.getName());
            _note = NoteFactory.getNoteByValue(8, _key);
            Assert.AreEqual("E", _note.getName());
            _note = NoteFactory.getNoteByValue(9, _key);
            Assert.AreEqual("F", _note.getName());
            _note = NoteFactory.getNoteByValue(10, _key);
            Assert.AreEqual("F#", _note.getName());
            _note = NoteFactory.getNoteByValue(11, _key);
            Assert.AreEqual("G", _note.getName());
            _note = NoteFactory.getNoteByValue(12, _key);
            Assert.AreEqual("G#", _note.getName());

            _key  = NoteFactory.getNoteByName("F");
            _note = NoteFactory.getNoteByValue(1, _key);
            Assert.AreEqual("A", _note.getName());
            _note = NoteFactory.getNoteByValue(2, _key);
            Assert.AreEqual("Bb", _note.getName());
            _note = NoteFactory.getNoteByValue(3, _key);
            Assert.AreEqual("B", _note.getName());
            _note = NoteFactory.getNoteByValue(4, _key);
            Assert.AreEqual("C", _note.getName());
            _note = NoteFactory.getNoteByValue(5, _key);
            Assert.AreEqual("Db", _note.getName());
            _note = NoteFactory.getNoteByValue(6, _key);
            Assert.AreEqual("D", _note.getName());
            _note = NoteFactory.getNoteByValue(7, _key);
            Assert.AreEqual("Eb", _note.getName());
            _note = NoteFactory.getNoteByValue(8, _key);
            Assert.AreEqual("E", _note.getName());
            _note = NoteFactory.getNoteByValue(9, _key);
            Assert.AreEqual("F", _note.getName());
            _note = NoteFactory.getNoteByValue(10, _key);
            Assert.AreEqual("Gb", _note.getName());
            _note = NoteFactory.getNoteByValue(11, _key);
            Assert.AreEqual("G", _note.getName());
            _note = NoteFactory.getNoteByValue(12, _key);
            Assert.AreEqual("Ab", _note.getName());

            _key  = NoteFactory.getNoteByName("F#");
            _note = NoteFactory.getNoteByValue(1, _key);
            Assert.AreEqual("A", _note.getName());
            _note = NoteFactory.getNoteByValue(2, _key);
            Assert.AreEqual("A#", _note.getName());
            _note = NoteFactory.getNoteByValue(3, _key);
            Assert.AreEqual("B", _note.getName());
            _note = NoteFactory.getNoteByValue(4, _key);
            Assert.AreEqual("C", _note.getName());
            _note = NoteFactory.getNoteByValue(5, _key);
            Assert.AreEqual("C#", _note.getName());
            _note = NoteFactory.getNoteByValue(6, _key);
            Assert.AreEqual("D", _note.getName());
            _note = NoteFactory.getNoteByValue(7, _key);
            Assert.AreEqual("D#", _note.getName());
            _note = NoteFactory.getNoteByValue(8, _key);
            Assert.AreEqual("E", _note.getName());
            _note = NoteFactory.getNoteByValue(9, _key);
            Assert.AreEqual("F", _note.getName());
            _note = NoteFactory.getNoteByValue(10, _key);
            Assert.AreEqual("F#", _note.getName());
            _note = NoteFactory.getNoteByValue(11, _key);
            Assert.AreEqual("G", _note.getName());
            _note = NoteFactory.getNoteByValue(12, _key);
            Assert.AreEqual("G#", _note.getName());

            _key  = NoteFactory.getNoteByName("Gb");
            _note = NoteFactory.getNoteByValue(1, _key);
            Assert.AreEqual("A", _note.getName());
            _note = NoteFactory.getNoteByValue(2, _key);
            Assert.AreEqual("Bb", _note.getName());
            _note = NoteFactory.getNoteByValue(3, _key);
            Assert.AreEqual("B", _note.getName());
            _note = NoteFactory.getNoteByValue(4, _key);
            Assert.AreEqual("C", _note.getName());
            _note = NoteFactory.getNoteByValue(5, _key);
            Assert.AreEqual("Db", _note.getName());
            _note = NoteFactory.getNoteByValue(6, _key);
            Assert.AreEqual("D", _note.getName());
            _note = NoteFactory.getNoteByValue(7, _key);
            Assert.AreEqual("Eb", _note.getName());
            _note = NoteFactory.getNoteByValue(8, _key);
            Assert.AreEqual("E", _note.getName());
            _note = NoteFactory.getNoteByValue(9, _key);
            Assert.AreEqual("F", _note.getName());
            _note = NoteFactory.getNoteByValue(10, _key);
            Assert.AreEqual("Gb", _note.getName());
            _note = NoteFactory.getNoteByValue(11, _key);
            Assert.AreEqual("G", _note.getName());
            _note = NoteFactory.getNoteByValue(12, _key);
            Assert.AreEqual("Ab", _note.getName());

            _key  = NoteFactory.getNoteByName("G");
            _note = NoteFactory.getNoteByValue(1, _key);
            Assert.AreEqual("A", _note.getName());
            _note = NoteFactory.getNoteByValue(2, _key);
            Assert.AreEqual("Bb", _note.getName());
            _note = NoteFactory.getNoteByValue(3, _key);
            Assert.AreEqual("B", _note.getName());
            _note = NoteFactory.getNoteByValue(4, _key);
            Assert.AreEqual("C", _note.getName());
            _note = NoteFactory.getNoteByValue(5, _key);
            Assert.AreEqual("Db", _note.getName());
            _note = NoteFactory.getNoteByValue(6, _key);
            Assert.AreEqual("D", _note.getName());
            _note = NoteFactory.getNoteByValue(7, _key);
            Assert.AreEqual("Eb", _note.getName());
            _note = NoteFactory.getNoteByValue(8, _key);
            Assert.AreEqual("E", _note.getName());
            _note = NoteFactory.getNoteByValue(9, _key);
            Assert.AreEqual("F", _note.getName());
            _note = NoteFactory.getNoteByValue(10, _key);
            Assert.AreEqual("F#", _note.getName());
            _note = NoteFactory.getNoteByValue(11, _key);
            Assert.AreEqual("G", _note.getName());
            _note = NoteFactory.getNoteByValue(12, _key);
            Assert.AreEqual("Ab", _note.getName());

            _key  = NoteFactory.getNoteByName("G#");
            _note = NoteFactory.getNoteByValue(1, _key);
            Assert.AreEqual("A", _note.getName());
            _note = NoteFactory.getNoteByValue(2, _key);
            Assert.AreEqual("A#", _note.getName());
            _note = NoteFactory.getNoteByValue(3, _key);
            Assert.AreEqual("B", _note.getName());
            _note = NoteFactory.getNoteByValue(4, _key);
            Assert.AreEqual("C", _note.getName());
            _note = NoteFactory.getNoteByValue(5, _key);
            Assert.AreEqual("C#", _note.getName());
            _note = NoteFactory.getNoteByValue(6, _key);
            Assert.AreEqual("D", _note.getName());
            _note = NoteFactory.getNoteByValue(7, _key);
            Assert.AreEqual("D#", _note.getName());
            _note = NoteFactory.getNoteByValue(8, _key);
            Assert.AreEqual("E", _note.getName());
            _note = NoteFactory.getNoteByValue(9, _key);
            Assert.AreEqual("F", _note.getName());
            _note = NoteFactory.getNoteByValue(10, _key);
            Assert.AreEqual("F#", _note.getName());
            _note = NoteFactory.getNoteByValue(11, _key);
            Assert.AreEqual("G", _note.getName());
            _note = NoteFactory.getNoteByValue(12, _key);
            Assert.AreEqual("G#", _note.getName());

            _key  = NoteFactory.getNoteByName("Ab");
            _note = NoteFactory.getNoteByValue(1, _key);
            Assert.AreEqual("A", _note.getName());
            _note = NoteFactory.getNoteByValue(2, _key);
            Assert.AreEqual("Bb", _note.getName());
            _note = NoteFactory.getNoteByValue(3, _key);
            Assert.AreEqual("B", _note.getName());
            _note = NoteFactory.getNoteByValue(4, _key);
            Assert.AreEqual("C", _note.getName());
            _note = NoteFactory.getNoteByValue(5, _key);
            Assert.AreEqual("Db", _note.getName());
            _note = NoteFactory.getNoteByValue(6, _key);
            Assert.AreEqual("D", _note.getName());
            _note = NoteFactory.getNoteByValue(7, _key);
            Assert.AreEqual("Eb", _note.getName());
            _note = NoteFactory.getNoteByValue(8, _key);
            Assert.AreEqual("E", _note.getName());
            _note = NoteFactory.getNoteByValue(9, _key);
            Assert.AreEqual("F", _note.getName());
            _note = NoteFactory.getNoteByValue(10, _key);
            Assert.AreEqual("Gb", _note.getName());
            _note = NoteFactory.getNoteByValue(11, _key);
            Assert.AreEqual("G", _note.getName());
            _note = NoteFactory.getNoteByValue(12, _key);
            Assert.AreEqual("Ab", _note.getName());
        }
예제 #6
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);
        }