Esempio n. 1
0
        public static TabChord getTabByChord(Chord chord, int pitchPosition, Guitar guitar)
        {
            int    index                = 0;
            int    bassString           = 0;
            string buildDirection       = "";
            int    currentPitchPosition = 0;
            bool   foundNoteThree       = true;
            bool   foundNoteFour        = true;
            bool   foundNoteFive        = true;
            bool   foundNoteSix         = true;

            bool foundNoteTwo = false;

            if (chord.getSize() > 2)
            {
                foundNoteThree = false;
                if (chord.getSize() > 3)
                {
                    foundNoteFour = false;
                    if (chord.getSize() > 4)
                    {
                        foundNoteFive = false;
                        if (chord.getSize() > 5)
                        {
                            foundNoteSix = false;
                        }
                    }
                }
            }
            TabChord tabChord = new TabChord();

            tabChord.setPitch(pitchPosition);
            while (currentPitchPosition < pitchPosition)
            {
                if (guitar.getNote(6, index, chord.getNoteAt(0)).getValue() == chord.getNoteAt(0).getValue())
                {
                    bassString = 6;
                    tabChord.setFretNumber(6, index.ToString());
                    currentPitchPosition = currentPitchPosition + 1;
                    buildDirection       = "right";
                    if (index >= 3)
                    {
                        buildDirection = "left";
                        if (currentPitchPosition < pitchPosition)
                        {
                            currentPitchPosition = currentPitchPosition + 1;
                            buildDirection       = "right";
                        }
                    }
                    if (currentPitchPosition < pitchPosition)
                    {
                        index = index + 1;
                    }
                }
                else if (guitar.getNote(5, index, chord.getNoteAt(0)).getValue() == chord.getNoteAt(0).getValue())
                {
                    bassString = 5;
                    tabChord.setFretNumber(6, "X");
                    tabChord.setFretNumber(5, index.ToString());
                    currentPitchPosition = currentPitchPosition + 1;
                    buildDirection       = "right";
                    if (index >= 3)
                    {
                        buildDirection = "left";
                        if (currentPitchPosition < pitchPosition)
                        {
                            currentPitchPosition = currentPitchPosition + 1;
                            buildDirection       = "right";
                        }
                    }
                    if (currentPitchPosition < pitchPosition)
                    {
                        index = index + 1;
                    }
                }
                else if (guitar.getNote(4, index, chord.getNoteAt(0)).getValue() == chord.getNoteAt(0).getValue())
                {
                    bassString = 4;
                    tabChord.setFretNumber(6, "X");
                    tabChord.setFretNumber(5, "X");
                    tabChord.setFretNumber(4, index.ToString());
                    currentPitchPosition = currentPitchPosition + 1;
                    buildDirection       = "right";
                    if (index >= 3)
                    {
                        buildDirection = "left";
                        if (currentPitchPosition < pitchPosition)
                        {
                            currentPitchPosition = currentPitchPosition + 1;
                            buildDirection       = "right";
                        }
                    }
                    if (currentPitchPosition < pitchPosition)
                    {
                        index = index + 1;
                    }
                }
                else
                {
                    index = index + 1;
                }
            }

            int  tempValue  = 0;
            int  nextString = bassString - 1;
            bool found;

            if (buildDirection == "right")
            {
                while (nextString > 0)
                {
                    found = false;
                    for (int i = index + 3; i >= index; i--)
                    {
                        for (int j = 0; j < chord.getSize(); j++)
                        {
                            if (chord.getNoteAt(j).getValue() == guitar.getNote(nextString, i, chord.getNoteAt(0)).getValue())
                            {
                                found     = true;
                                tempValue = chord.getNoteAt(j).getValue();
                                tabChord.setFretNumber(nextString, i.ToString());
                            }
                        }
                    }
                    if (tempValue == chord.getNoteAt(1).getValue())
                    {
                        foundNoteTwo = true;
                    }
                    else if (chord.getSize() >= 3 && tempValue == chord.getNoteAt(2).getValue())
                    {
                        foundNoteThree = true;
                    }
                    else if (chord.getSize() >= 4 && tempValue == chord.getNoteAt(3).getValue())
                    {
                        foundNoteFour = true;
                    }
                    else if (chord.getSize() >= 5 && tempValue == chord.getNoteAt(4).getValue())
                    {
                        foundNoteFive = true;
                    }
                    else if (chord.getSize() == 6 && tempValue == chord.getNoteAt(5).getValue())
                    {
                        foundNoteSix = true;
                    }
                    if (found == false)
                    {
                        tabChord.setFretNumber(nextString, "X");
                    }
                    nextString = nextString - 1;
                }
                if (!foundNoteTwo)
                {
                    nextString = bassString - 1;
                    while (nextString > 0 && !foundNoteTwo)
                    {
                        for (int i = index + 3; i >= index; i--)
                        {
                            if (chord.getNoteAt(1).getValue() == guitar.getNote(nextString, i, chord.getNoteAt(0)).getValue())
                            {
                                foundNoteTwo = true;
                                tabChord.setFretNumber(nextString, i.ToString());
                            }
                        }
                        nextString = nextString - 1;
                    }
                }
                if (!foundNoteThree)
                {
                    nextString = bassString - 1;
                    while (nextString > 0 && !foundNoteThree)
                    {
                        for (int i = index + 3; i >= index; i--)
                        {
                            if (chord.getNoteAt(2).getValue() == guitar.getNote(nextString, i, chord.getNoteAt(0)).getValue())
                            {
                                foundNoteThree = true;
                                tabChord.setFretNumber(nextString, i.ToString());
                            }
                        }
                        nextString = nextString - 1;
                    }
                }
                if (!foundNoteFour)
                {
                    nextString = bassString - 1;
                    while (nextString > 0 && !foundNoteFour)
                    {
                        for (int i = index + 3; i >= index; i--)
                        {
                            if (chord.getNoteAt(3).getValue() == guitar.getNote(nextString, i, chord.getNoteAt(0)).getValue())
                            {
                                foundNoteFour = true;
                                tabChord.setFretNumber(nextString, i.ToString());
                            }
                        }
                        nextString = nextString - 1;
                    }
                }
                if (!foundNoteFive)
                {
                    nextString = bassString - 1;
                    while (nextString > 0 && !foundNoteFive)
                    {
                        for (int i = index + 3; i >= index; i--)
                        {
                            if (chord.getNoteAt(4).getValue() == guitar.getNote(nextString, i, chord.getNoteAt(0)).getValue())
                            {
                                foundNoteFive = true;
                                tabChord.setFretNumber(nextString, i.ToString());
                            }
                        }
                        nextString = nextString - 1;
                    }
                }
                if (!foundNoteSix)
                {
                    nextString = bassString - 1;
                    while (nextString > 0 && !foundNoteSix)
                    {
                        for (int i = index + 3; i >= index; i--)
                        {
                            if (chord.getNoteAt(5).getValue() == guitar.getNote(nextString, i, chord.getNoteAt(0)).getValue())
                            {
                                foundNoteSix = true;
                                tabChord.setFretNumber(nextString, i.ToString());
                            }
                        }
                        nextString = nextString - 1;
                    }
                }
            }
            else if (buildDirection == "left")
            {
                while (nextString > 0)
                {
                    found = false;
                    for (int i = index; i >= index - 3; i--)
                    {
                        for (int j = 0; j < chord.getSize(); j++)
                        {
                            if (chord.getNoteAt(j).getValue() == guitar.getNote(nextString, i, chord.getNoteAt(0)).getValue())
                            {
                                found     = true;
                                tempValue = chord.getNoteAt(j).getValue();
                                tabChord.setFretNumber(nextString, i.ToString());
                            }
                        }
                    }

                    if (tempValue == chord.getNoteAt(1).getValue())
                    {
                        foundNoteTwo = true;
                    }
                    else if (chord.getSize() >= 3 && tempValue == chord.getNoteAt(2).getValue())
                    {
                        foundNoteThree = true;
                    }
                    else if (chord.getSize() >= 4 && tempValue == chord.getNoteAt(3).getValue())
                    {
                        foundNoteFour = true;
                    }
                    else if (chord.getSize() >= 5 && tempValue == chord.getNoteAt(4).getValue())
                    {
                        foundNoteFive = true;
                    }
                    else if (chord.getSize() == 6 && tempValue == chord.getNoteAt(5).getValue())
                    {
                        foundNoteSix = true;
                    }
                    if (found == false)
                    {
                        tabChord.setFretNumber(nextString, "X");
                    }
                    nextString = nextString - 1;
                }
                if (!foundNoteTwo)
                {
                    nextString = bassString - 1;
                    while (nextString > 0 && !foundNoteTwo)
                    {
                        for (int i = index; i >= index - 3; i--)
                        {
                            if (chord.getNoteAt(1).getValue() == guitar.getNote(nextString, i, chord.getNoteAt(0)).getValue())
                            {
                                foundNoteTwo = true;
                                tabChord.setFretNumber(nextString, i.ToString());
                            }
                        }
                        nextString = nextString - 1;
                    }
                }
                if (!foundNoteThree)
                {
                    nextString = bassString - 1;
                    while (nextString > 0 && !foundNoteThree)
                    {
                        for (int i = index; i >= index - 3; i--)
                        {
                            if (chord.getNoteAt(2).getValue() == guitar.getNote(nextString, i, chord.getNoteAt(0)).getValue())
                            {
                                foundNoteThree = true;
                                tabChord.setFretNumber(nextString, i.ToString());
                            }
                        }
                        nextString = nextString - 1;
                    }
                }
                if (!foundNoteFour)
                {
                    nextString = bassString - 1;
                    while (nextString > 0 && !foundNoteFour)
                    {
                        for (int i = index; i >= index - 3; i--)
                        {
                            if (chord.getNoteAt(3).getValue() == guitar.getNote(nextString, i, chord.getNoteAt(0)).getValue())
                            {
                                foundNoteFour = true;
                                tabChord.setFretNumber(nextString, i.ToString());
                            }
                        }
                        nextString = nextString - 1;
                    }
                }
                if (!foundNoteFive)
                {
                    nextString = bassString - 1;
                    while (nextString > 0 && !foundNoteFive)
                    {
                        for (int i = index; i >= index - 3; i--)
                        {
                            if (chord.getNoteAt(4).getValue() == guitar.getNote(nextString, i, chord.getNoteAt(0)).getValue())
                            {
                                foundNoteFive = true;
                                tabChord.setFretNumber(nextString, i.ToString());
                            }
                        }
                        nextString = nextString - 1;
                    }
                }
                if (!foundNoteSix)
                {
                    nextString = bassString - 1;
                    while (nextString > 0 && !foundNoteSix)
                    {
                        for (int i = index; i >= index - 3; i--)
                        {
                            if (chord.getNoteAt(5).getValue() == guitar.getNote(nextString, i, chord.getNoteAt(0)).getValue())
                            {
                                foundNoteSix = true;
                                tabChord.setFretNumber(nextString, i.ToString());
                            }
                        }
                        nextString = nextString - 1;
                    }
                }
            }
            else
            {
                throw new System.ArgumentException("Tablature building for chord " + chord.getName() + " failed", "tabChordFactory");
            }
            return(tabChord);
        }
 public static void replaceChord(int location, Chord chord)
 {
     chords.RemoveAt(location);
     chords.Insert(location, chord);
     tablature.Insert(location, TabChordFactory.getTabByChord(chord, 1, _guitar));
 }
 public static void addChord(Chord chord)
 {
     chords.Add(chord);
     tablature.Add(TabChordFactory.getTabByChord(chord, 1, _guitar));
 }
Esempio n. 4
0
 public void ChordFactoryTest_getChrodByName()
 {
     _chord = ChordFactory.getChordByName("A");
     Assert.AreEqual("A, C#, E", _chord.getNotes());
     _chord = ChordFactory.getChordByName("Am");
     Assert.AreEqual("A, C, E", _chord.getNotes());
     _chord = ChordFactory.getChordByName("A5");
     Assert.AreEqual("A, E", _chord.getNotes());
     _chord = ChordFactory.getChordByName("A6");
     Assert.AreEqual("A, C#, E, F#", _chord.getNotes());
     _chord = ChordFactory.getChordByName("Ab");
     Assert.AreEqual("Ab, C, Eb", _chord.getNotes());
     _chord = ChordFactory.getChordByName("Abm");
     Assert.AreEqual("Ab, B, Eb", _chord.getNotes());
     _chord = ChordFactory.getChordByName("Ab5");
     Assert.AreEqual("Ab, Eb", _chord.getNotes());
     _chord = ChordFactory.getChordByName("Ab6");
     Assert.AreEqual("Ab, C, Eb, F", _chord.getNotes());
     _chord = ChordFactory.getChordByName("Csus");
     Assert.AreEqual("C, F, G", _chord.getNotes());
     _chord = ChordFactory.getChordByName("Csus2");
     Assert.AreEqual("C, D, G", _chord.getNotes());
     _chord = ChordFactory.getChordByName("C7sus");
     Assert.AreEqual("C, F, G, Bb", _chord.getNotes());
     _chord = ChordFactory.getChordByName("Cdim");
     Assert.AreEqual("C, Eb, Gb", _chord.getNotes());
     _chord = ChordFactory.getChordByName("Cmaj7");
     Assert.AreEqual("C, E, G, B", _chord.getNotes());
     _chord = ChordFactory.getChordByName("Cmaj9");
     Assert.AreEqual("C, E, G, B, D", _chord.getNotes());
     _chord = ChordFactory.getChordByName("Cmaj7(b5)");
     Assert.AreEqual("C, E, Gb, B", _chord.getNotes());
     _chord = ChordFactory.getChordByName("Cm(maj7)");
     Assert.AreEqual("C, Eb, G, B", _chord.getNotes());
     _chord = ChordFactory.getChordByName("Cm9(maj7)");
     Assert.AreEqual("C, Eb, G, B, D", _chord.getNotes());
     _chord = ChordFactory.getChordByName("C7");
     Assert.AreEqual("C, E, G, Bb", _chord.getNotes());
     _chord = ChordFactory.getChordByName("Cm7");
     Assert.AreEqual("C, Eb, G, Bb", _chord.getNotes());
     _chord = ChordFactory.getChordByName("C7(b9)");
     Assert.AreEqual("C, E, G, Bb, Db", _chord.getNotes());
     _chord = ChordFactory.getChordByName("C7(#9)");
     Assert.AreEqual("C, E, G, Bb, Eb", _chord.getNotes());
     _chord = ChordFactory.getChordByName("C7+");
     Assert.AreEqual("C, E, Ab, Bb", _chord.getNotes());
     _chord = ChordFactory.getChordByName("C7+(b9)");
     Assert.AreEqual("C, E, Ab, Bb, Db", _chord.getNotes());
     _chord = ChordFactory.getChordByName("C9+");
     Assert.AreEqual("C, E, Ab, Bb, D", _chord.getNotes());
     _chord = ChordFactory.getChordByName("C9(#11)");
     Assert.AreEqual("C, E, G, Bb, D, Gb", _chord.getNotes());
     _chord = ChordFactory.getChordByName("C11");
     Assert.AreEqual("C, E, G, Bb, D, F", _chord.getNotes());
     _chord = ChordFactory.getChordByName("Cm11");
     Assert.AreEqual("C, Eb, G, Bb, D, F", _chord.getNotes());
     _chord = ChordFactory.getChordByName("CM11");
     Assert.AreEqual("C, E, G, B, D, F", _chord.getNotes());
     _chord = ChordFactory.getChordByName("C13");
     Assert.AreEqual("C, E, G, Bb, D, A", _chord.getNotes());
     _chord = ChordFactory.getChordByName("C13(b9)");
     Assert.AreEqual("C, E, G, Bb, Db, A", _chord.getNotes());
     _chord = ChordFactory.getChordByName("C13(#9)");
     Assert.AreEqual("C, E, G, Bb, Eb, A", _chord.getNotes());
     _chord = ChordFactory.getChordByName("C13(b9b5)");
     Assert.AreEqual("C, E, Gb, Bb, Db, A", _chord.getNotes());
     _chord = ChordFactory.getChordByName("C9");
     Assert.AreEqual("C, E, G, Bb, D", _chord.getNotes());
     _chord = ChordFactory.getChordByName("C9(b5)");
     Assert.AreEqual("C, E, Gb, Bb, D", _chord.getNotes());
     _chord = ChordFactory.getChordByName("Cm9");
     Assert.AreEqual("C, Eb, G, Bb, D", _chord.getNotes());
     _chord = ChordFactory.getChordByName("C6");
     Assert.AreEqual("C, E, G, A", _chord.getNotes());
     _chord = ChordFactory.getChordByName("Cm6");
     Assert.AreEqual("C, Eb, G, A", _chord.getNotes());
     _chord = ChordFactory.getChordByName("C6/9");
     Assert.AreEqual("C, E, G, A, D", _chord.getNotes());
     _chord = ChordFactory.getChordByName("Cm6/9");
     Assert.AreEqual("C, Eb, G, A, D", _chord.getNotes());
     _chord = ChordFactory.getChordByName("C7");
     Assert.AreEqual("C, E, G, Bb", _chord.getNotes());
     _chord = ChordFactory.getChordByName("Cm7");
     Assert.AreEqual("C, Eb, G, Bb", _chord.getNotes());
     _chord = ChordFactory.getChordByName("C7(b5)");
     Assert.AreEqual("C, E, Gb, Bb", _chord.getNotes());
     _chord = ChordFactory.getChordByName("Cm7(b5)");
     Assert.AreEqual("C, Eb, Gb, Bb", _chord.getNotes());
     _chord = ChordFactory.getChordByName("C(b5)");
     Assert.AreEqual("C, E, Gb", _chord.getNotes());
     _chord = ChordFactory.getChordByName("Bm7(b5)");
     Assert.AreEqual("B, D, F, A", _chord.getNotes());
     _chord = ChordFactory.getChordByName("Caug");
     Assert.AreEqual("C, E, Ab", _chord.getNotes());
     _chord = ChordFactory.getChordByName("C(add9)");
     Assert.AreEqual("C, E, G, D", _chord.getNotes());
     Assert.AreEqual("C(add9)", _chord.getName());
     //_chord = ChordFactory.getChordByName("C/G");
     //Assert.AreEqual("G, C, E, G", _chord.getNotes());
 }
Esempio n. 5
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);
        }
Esempio n. 6
0
        public static Chord getChordByName(string name)
        {
            if (!(ChordController.checkChordName(name)))
            {
                throw new System.ArgumentException("Parameter must have a valid name", "Chord Name: " + name);
            }

            int    i         = 0;
            bool   needsMore = true;
            string tonicName;
            string slashBass;
            Note   tonic;
            Chord  chord = new Chord();

            chord.setName(name);
            var chordName = name.ToCharArray();

            tonicName = chordName[i].ToString();
            i++;

            if (i + 1 <= chordName.Length && (chordName[i] == 'b' || chordName[i] == '#'))
            {
                tonicName = tonicName + chordName[i].ToString();
                i++;
            }

            tonic = NoteFactory.getNoteByName(tonicName);
            chord.addNote(tonic);

            // Calculate first interval (dim3, m3, M3, aug3)
            if (needsMore)
            {
                // X5
                if (i + 1 <= chordName.Length && chordName[i] == '5')
                {
                    chord.addNote(calculateNote(7, tonic));
                    i++;
                    needsMore = false;
                }
                // Xsus
                else if (i + 3 <= chordName.Length && chordName[i] == 's' && chordName[i + 1] == 'u' && chordName[i + 2] == 's')
                {
                    i = i + 3;
                    if (i + 1 <= chordName.Length && chordName[i] == '2')
                    {
                        chord.addNote(calculateNote(2, tonic));
                        i++;
                    }
                    else
                    {
                        chord.addNote(calculateNote(5, tonic));
                    }
                    chord.addNote(calculateNote(7, tonic));
                    needsMore = false;
                }
                // X7sus
                else if (i + 4 <= chordName.Length && chordName[i] == '7' && chordName[i + 1] == 's' && chordName[i + 2] == 'u' && chordName[i + 3] == 's')
                {
                    chord.addNote(calculateNote(5, tonic));
                    chord.addNote(calculateNote(7, tonic));
                    chord.addNote(calculateNote(10, tonic));
                    i         = i + 4;
                    needsMore = false;
                }
                // Xdim
                else if (i + 3 <= chordName.Length && chordName[i] == 'd' && chordName[i + 1] == 'i' && chordName[i + 2] == 'm')
                {
                    chord.addNote(calculateNote(3, tonic));
                    chord.addNote(calculateNote(6, tonic));
                    i         = i + 3;
                    needsMore = false;
                }
                //Xm
                else if (i + 1 == chordName.Length && chordName[i] == 'm')
                {
                    chord.addNote(calculateNote(3, tonic));
                    i++;
                }
                // Xm...
                else if (i + 1 <= chordName.Length && chordName[i] == 'm' && chordName[i + 1] != 'a')
                {
                    chord.addNote(calculateNote(3, tonic));
                    i++;
                }
                // X...
                else
                {
                    chord.addNote(calculateNote(4, tonic));
                }
            }

            // Add next interval (dim5, P5, aug5)

            if (needsMore)
            {
                // X(b5)
                if (i + 4 <= chordName.Length && chordName[i] == '(' && chordName[i + 1] == 'b' && chordName[i + 2] == '5' &&
                    chordName[i + 3] == ')')
                {
                    chord.addNote(calculateNote(6, tonic));
                    i         = i + 4;
                    needsMore = false;
                }
                // X7(b5)
                else if (i + 5 <= chordName.Length && chordName[i] == '7' && chordName[i + 1] == '(' && chordName[i + 2] == 'b' &&
                         chordName[i + 3] == '5' && chordName[i + 4] == ')')
                {
                    chord.addNote(calculateNote(6, tonic));
                    chord.addNote(calculateNote(10, tonic));
                    i         = i + 5;
                    needsMore = false;
                }
                // Xmaj7(b5)
                else if (i + 8 <= chordName.Length && chordName[i] == 'm' && chordName[i + 1] == 'a' && chordName[i + 2] == 'j' &&
                         chordName[i + 3] == '7' && chordName[i + 4] == '(' && chordName[i + 5] == 'b' && chordName[i + 6] == '5')
                {
                    chord.addNote(calculateNote(6, tonic));
                    chord.addNote(calculateNote(11, tonic));
                    i         = i + 8;
                    needsMore = false;
                }
                // X9(b5)
                else if (i + 5 <= chordName.Length && chordName[i] == '9' && chordName[i + 1] == '(' && chordName[i + 2] == 'b' &&
                         chordName[i + 3] == '5')
                {
                    chord.addNote(calculateNote(6, tonic));
                    chord.addNote(calculateNote(10, tonic));
                    chord.addNote(calculateNote(2, tonic));
                    i         = i + 5;
                    needsMore = false;
                }
                // X13(b9b5)
                else if (i + 8 <= chordName.Length && chordName[i] == '1' && chordName[i + 1] == '3' && chordName[i + 2] == '(' &&
                         chordName[i + 3] == 'b' && chordName[i + 4] == '9' && chordName[i + 5] == 'b' && chordName[i + 6] == '5')
                {
                    chord.addNote(calculateNote(6, tonic));
                    chord.addNote(calculateNote(10, tonic));
                    chord.addNote(calculateNote(1, tonic));
                    chord.addNote(calculateNote(9, tonic));
                    i         = i + 8;
                    needsMore = false;
                }
                // Xaug
                else if (i + 3 <= chordName.Length && chordName[i] == 'a' && chordName[i + 1] == 'u' && chordName[i + 2] == 'g')
                {
                    chord.addNote(calculateNote(8, tonic));
                    i         = i + 3;
                    needsMore = false;
                }
                // X7+
                else if (i + 2 <= chordName.Length && chordName[i] == '7' && chordName[i + 1] == '+')
                {
                    chord.addNote(calculateNote(8, tonic));
                    chord.addNote(calculateNote(10, tonic));
                    i = i + 2;
                    // X7+(b9)
                    if (i + 4 <= chordName.Length && chordName[i] == '(' && chordName[i + 1] == 'b' && chordName[i + 2] == '9')
                    {
                        chord.addNote(calculateNote(1, tonic));
                        i = i + 4;
                    }
                    needsMore = false;
                }
                // X9+
                else if (i + 2 <= chordName.Length && chordName[i] == '9' && chordName[i + 1] == '+')
                {
                    chord.addNote(calculateNote(8, tonic));
                    chord.addNote(calculateNote(10, tonic));
                    chord.addNote(calculateNote(2, tonic));
                    i         = i + 2;
                    needsMore = false;
                }
                // X...
                else
                {
                    chord.addNote(calculateNote(7, tonic));
                }
            }

            // Add final intervals (M6, m7, M7)

            if (needsMore)
            {
                // X(add9)
                if (i + 6 <= chordName.Length && chordName[i] == '(' && chordName[i + 1] == 'a' && chordName[i + 2] == 'd' &&
                    chordName[i + 3] == 'd' && chordName[i + 4] == '9')
                {
                    chord.addNote(calculateNote(2, tonic));
                    i         = i + 6;
                    needsMore = false;
                }
                // X6
                else if (i + 1 <= chordName.Length && chordName[i] == '6')
                {
                    chord.addNote(calculateNote(9, tonic));
                    i++;
                    // X6/9
                    if (i + 2 <= chordName.Length && chordName[i] == '/' && chordName[i + 1] == '9')
                    {
                        chord.addNote(calculateNote(2, tonic));
                        i = i + 2;
                    }
                    needsMore = false;
                }
                // X13
                else if (i + 2 <= chordName.Length && chordName[i] == '1' && chordName[i + 1] == '3')
                {
                    chord.addNote(calculateNote(10, tonic));
                    i = i + 2;
                    // X13(b9)
                    if (i + 4 <= chordName.Length && chordName[i] == '(' && chordName[i + 1] == 'b' && chordName[i + 2] == '9')
                    {
                        chord.addNote(calculateNote(1, tonic));
                        i = i + 4;
                    }
                    // X13(#9)
                    else if (i + 4 <= chordName.Length && chordName[i] == '(' && chordName[i + 1] == '#' && chordName[i + 2] == '9')
                    {
                        chord.addNote(calculateNote(3, tonic));
                        i = i + 4;
                    }
                    else
                    {
                        chord.addNote(calculateNote(2, tonic));
                    }
                    chord.addNote(calculateNote(9, tonic));
                    needsMore = false;
                }
                // X7
                else if (i + 1 <= chordName.Length && chordName[i] == '7')
                {
                    chord.addNote(calculateNote(10, tonic));
                    i++;
                    // X7(b9)
                    if (i + 4 <= chordName.Length && chordName[i] == '(' && chordName[i + 1] == 'b' && chordName[i + 2] == '9')
                    {
                        chord.addNote(calculateNote(1, tonic));
                        i = i + 4;
                    }
                    // X7(#9)
                    else if (i + 4 <= chordName.Length && chordName[i] == '(' && chordName[i + 1] == '#' && chordName[i + 2] == '9')
                    {
                        chord.addNote(calculateNote(3, tonic));
                        i = i + 4;
                    }
                    needsMore = false;
                }
                // X9
                else if (i + 1 <= chordName.Length && chordName[i] == '9')
                {
                    i++;
                    // X9(#11)
                    if (i + 5 <= chordName.Length && chordName[i] == '(' && chordName[i + 1] == '#' && chordName[i + 2] == '1' &&
                        chordName[i + 3] == '1')
                    {
                        chord.addNote(calculateNote(10, tonic));
                        chord.addNote(calculateNote(2, tonic));
                        chord.addNote(calculateNote(6, tonic));
                        i = i + 5;
                    }
                    // X9maj7
                    else if (i + 6 <= chordName.Length && chordName[i + 1] == 'm' && chordName[i + 2] == 'a' &&
                             chordName[i + 3] == 'j' && chordName[i + 4] == '7')
                    {
                        chord.addNote(calculateNote(11, tonic));
                        chord.addNote(calculateNote(2, tonic));
                        i         = i + 6;
                        needsMore = false;
                    }
                    else
                    {
                        chord.addNote(calculateNote(10, tonic));
                        chord.addNote(calculateNote(2, tonic));
                    }
                    needsMore = false;
                }
                // X11
                else if (i + 1 <= chordName.Length && chordName[i] == '1' && chordName[i + 1] == '1')
                {
                    chord.addNote(calculateNote(10, tonic));
                    chord.addNote(calculateNote(2, tonic));
                    chord.addNote(calculateNote(5, tonic));
                    i         = i + 2;
                    needsMore = false;
                }
                // XM11
                else if (i + 3 <= chordName.Length && chordName[i] == 'M' && chordName[i + 1] == '1' && chordName[i + 2] == '1')
                {
                    chord.addNote(calculateNote(11, tonic));
                    chord.addNote(calculateNote(2, tonic));
                    chord.addNote(calculateNote(5, tonic));
                    i         = i + 3;
                    needsMore = false;
                }
                // Xmaj7
                else if (i + 3 <= chordName.Length && chordName[i] == 'm' && chordName[i + 1] == 'a' && chordName[i + 2] == 'j')
                {
                    chord.addNote(calculateNote(11, tonic));
                    i = i + 3;
                    if (i + 1 <= chordName.Length && chordName[i] == '9')
                    {
                        chord.addNote(calculateNote(2, tonic));
                    }
                    i++;
                    needsMore = false;
                }
                // X(maj7)
                else if (i + 6 <= chordName.Length && chordName[i] == '(' && chordName[i + 1] == 'm' && chordName[i + 2] == 'a' && chordName[i + 3] == 'j' &&
                         chordName[i + 4] == '7')
                {
                    chord.addNote(calculateNote(11, tonic));
                    i         = i + 6;
                    needsMore = false;
                }
            }

            // X/bassNote
            if (i < chordName.Count() && chordName[i] == '/')
            {
                i++;
                if (i < chordName.Count() && NoteController.checkNoteName(chordName[i].ToString()))
                {
                    slashBass = chordName[i].ToString();
                    i++;
                }
                else
                {
                    throw new System.ArgumentException("\nThe character length for " + name + " is: " + chordName.Length + "\nThe index for " + name + " is: " + i, "Chord Name: " + name);
                }

                if (i < chordName.Count() && (chordName[i] == 'b' || chordName[i] == '#'))
                {
                    slashBass = slashBass + chordName[i].ToString();
                    i++;
                }
                chord.insertNote(NoteFactory.getNoteByName(slashBass), 0);
            }

            if (i < chordName.Length)
            {
                throw new System.ArgumentException("\nThe character length for " + name + " is: " + chordName.Length + "\nThe index for " + name + " is: " + i, "Chord Name: " + name);
            }

            chord.color = RandomColorFactory.GetRandomColor();

            return(chord);
        }