public static string GetChordType(Intervals intervals) { foreach (var entry in ChordMap) { if (intervals.Equals(entry.Value)) { return(entry.Key); } } return(null); }
/// <summary> /// Returns a list of chords represented by this chord progression /// </summary> /// <returns></returns> public Chord[] GetChords() { if (knownChords != null) { return(knownChords); } Chord[] chords = new Chord[progressionElements.Length]; Pattern scalePattern = key.Scale.Intervals.SetRoot(key.Root).GetPattern(); string[] scaleNotes = scalePattern.ToString().Split(' '); int counter = 0; foreach (string progressionElement in progressionElements) { Note rootNote = NoteProviderFactory.GetNoteProvider() .CreateNote(scaleNotes[RomanNumeralToIndex(progressionElement)]); rootNote.UseSameDurationAs(key.Root); Intervals intervals = Chord.MAJOR_INTERVALS; if ((progressionElement[0] == 'i') || (progressionElement[0] == 'v')) { // Checking to see if the progression element is lowercase intervals = Chord.MINOR_INTERVALS; } if ((progressionElement.ToLower().IndexOf("o") > 0) || (progressionElement.ToLower().IndexOf("d") > 0)) { // Checking to see if the progression element is diminished intervals = Chord.DIMINISHED_INTERVALS; } if (progressionElement.EndsWith("7")) { if (intervals.Equals(Chord.MAJOR_INTERVALS)) { intervals = Chord.MAJOR_SEVENTH_INTERVALS; } else if (intervals.Equals(Chord.MINOR_INTERVALS)) { intervals = Chord.MINOR_SEVENTH_INTERVALS; } else if (intervals.Equals(Chord.DIMINISHED_INTERVALS)) { intervals = Chord.DIMINISHED_SEVENTH_INTERVALS; } } if (progressionElement.EndsWith("7%6")) { if (intervals.Equals(Chord.MAJOR_INTERVALS)) { intervals = Chord.MAJOR_SEVENTH_SIXTH_INTERVALS; } else if (intervals.Equals(Chord.MINOR_INTERVALS)) { intervals = Chord.MINOR_SEVENTH_SIXTH_INTERVALS; } } // Check for inversions int inversions = CountInversions(progressionElement); chords[counter] = new Chord(rootNote, intervals); if (inversions > 0) { chords[counter].Inversion = inversions; } counter++; } return(chords); }