Esempio n. 1
0
def analyze_7th_chord(chord):
    """

    :param chord:
    :return: chord_notes, chord_type_full, chord_modes

    Example:
    >>> chord_notes, chord_type_full, results = analyze_chord("G7")
    >>> for chord_degree, key, harmonic_func_full in results:
    ...     print("{} (comprising {}) is a {} chord ({}) of the key of {}".format(chord_type_full,', '.join(chord_notes),
    ...                                                                           chord_degree, harmonic_func_full,
    ...                                                                           key))
    G dominant seventh (comprising G, B, D, F) is a V chord (dominant seventh) of the key of C

    """
    chord_notes = chords.from_shorthand(chord)
    chord_type_full = chords.determine_seventh(chord_notes)[0]
    chord_type_short = chords.determine_seventh(chord_notes, shorthand=True)[0]
    type_key = (
        "M7"
        if chord_type_short[-2:] == "M7"
        else ("m7" if chord_type_short[-2:] == "m7" else ("m7b5" if chord_type_short[-2:] == "m7b5" else "7"))
    )

    chord_modes = []
    for key in CIRCLE_OF_5THS:
        harmonic_func = determine(chord_notes, key, shorthand=True)[0]
        harmonic_func_full = determine(chord_notes, key, shorthand=False)[0]
        chord_degree = harmonic_func[:-1]
        if chord_degree in MODE_CHORD_TYPE:
            func_chord_type = MODE_CHORD_TYPE[chord_degree]
            if func_chord_type == type_key:
                chord_modes.append((chord_degree, key, harmonic_func_full))
    return chord_notes, chord_type_full, chord_modes
Esempio n. 2
0
def analyze_7th_chord(chord):
    """

    :param chord:
    :return: chord_notes, chord_type_full, chord_modes

    Example:
    >>> chord_notes, chord_type_full, results = analyze_chord("G7")
    >>> for chord_degree, key, harmonic_func_full in results:
    ...     print("{} (comprising {}) is a {} chord ({}) of the key of {}".format(chord_type_full,', '.join(chord_notes),
    ...                                                                           chord_degree, harmonic_func_full,
    ...                                                                           key))
    G dominant seventh (comprising G, B, D, F) is a V chord (dominant seventh) of the key of C

    """
    chord_notes = chords.from_shorthand(chord)
    chord_type_full = chords.determine_seventh(chord_notes)[0]
    chord_type_short = chords.determine_seventh(chord_notes, shorthand=True)[0]
    type_key = 'M7' if chord_type_short[-2:] == 'M7' else (
        'm7' if chord_type_short[-2:] == 'm7' else
        ('m7b5' if chord_type_short[-2:] == 'm7b5' else '7'))

    chord_modes = []
    for key in CIRCLE_OF_5THS:
        harmonic_func = determine(chord_notes, key, shorthand=True)[0]
        harmonic_func_full = determine(chord_notes, key, shorthand=False)[0]
        chord_degree = harmonic_func[:-1]
        if chord_degree in MODE_CHORD_TYPE:
            func_chord_type = MODE_CHORD_TYPE[chord_degree]
            if func_chord_type == type_key:
                chord_modes.append((chord_degree, key, harmonic_func_full))
    return chord_notes, chord_type_full, chord_modes
Esempio n. 3
0
def twelve_bar_blues_chord_progression(key):
    from mingus.core.harmony import MODE_CHORD_FUNCTIONS
    key_notes = get_notes(key)
    aChord = chords.create_dominant_seventh_symbol(key)
    bChord = chords.create_dominant_seventh_symbol(key_notes[3])
    cChord = chords.determine_seventh(MODE_CHORD_FUNCTIONS[1](key), shorthand=True)[0]
    dChord = chords.determine_seventh(MODE_CHORD_FUNCTIONS[4](key), shorthand=True)[0]
    return [aChord, bChord, aChord, aChord,
            bChord, bChord, aChord, aChord,
            cChord, dChord, aChord, aChord]
Esempio n. 4
0
def reharmonize_v_to_ii_v(chord):
    chord_notes, chord_type_full, chord_modes = analyze_chord(chord)
    assert len(chord_modes) == 1
    chord_degree, key, harmonic_func_full = chord_modes[0]
    ii_chord_type_short = chords.determine_seventh(chords.ii7(key),
                                                   shorthand=True)[0]
    return [ii_chord_type_short, chord]
Esempio n. 5
0
	def test_determine_seventh_shorthand(self):

			self.chordsTest([ [["Am7", "CM6", "CM|Am"], ["A", "C", "E", "G"]],\
							  [["CM7", "Em|CM"], ["C", "E", "G", "B"]],\
							  [["CM7"], ["E", "G", "B", "C"]],\
							  [["Fm/M7", "Abaug|Fm"], ["F", "Ab", "C", "E"]]],
							  lambda x: chords.determine_seventh(x, True), "proper naming")
Esempio n. 6
0
 def test_determine_seventh_shorthand(self):
     self.chordsTest([[['Am7', 'CM6', 'CM|Am'], ['A', 'C', 'E', 'G']],
                      [['CM7', 'Em|CM'], ['C', 'E', 'G', 'B']],
                      [['CM7'], ['E', 'G', 'B', 'C']],
                      [['Fm/M7', 'Abaug|Fm'], ['F', 'Ab', 'C', 'E']]],
                     lambda x: chords.determine_seventh(x, True),
                     'proper naming')
Esempio n. 7
0
 def test_determine_seventh_shorthand(self):
     self.chordsTest(
         [
             [["Am7", "CM6", "CM|Am"], ["A", "C", "E", "G"]],
             [["CM7", "Em|CM"], ["C", "E", "G", "B"]],
             [["CM7"], ["E", "G", "B", "C"]],
             [["Fm/M7", "Abaug|Fm"], ["F", "Ab", "C", "E"]],
         ],
         lambda x: chords.determine_seventh(x, True),
         "proper naming",
     )
Esempio n. 8
0
def create_seventh_name(note):
    return chords.determine_seventh(chords.seventh(note, note),
                                    shorthand=True)[0]
Esempio n. 9
0
        for chord in args.chords:
            ii_chord_type_short, chord = reharmonize_v_to_ii_v(chord)
            print("II-V ({}, {})".format(ii_chord_type_short, chord))

    elif args.action == 'ii_v_tritone_substitution':
        for chord in args.chords:
            chord_notes = chords.from_shorthand(chord)
            new_note = reduce_accidentals(tritone(chord_notes[0]))
            new_chord = new_note + '7'

            ii_chord_type_short, chord = reharmonize_v_to_ii_v(new_chord)
            print("{} {}".format(ii_chord_type_short, new_chord))

    elif args.action == 'chord_modes':
        chords = [
            chords.determine_seventh(mode_func(args.key), shorthand=True)[0]
            for mode_func in MODE_CHORD_FUNCTIONS
        ]
        print(', '.join(chords))

    elif args.action == '12_bar_blues':
        for four_bars in twelve_bar_blues(args.key):
            print('\t'.join(four_bars))

    elif args.action == 'blues_scale':
        print("{} blues scale: {}".format(args.key,
                                          ', '.join(blues_scale(args.key))))

    elif args.action == '12_bar_blues_printout':
        from mingus.containers.note import QuarterNoteFactory as Q
        from mingus.core.chords import WholNoteChordFactory as WNC
Esempio n. 10
0
def reharmonize_v_to_ii_v(chord):
    chord_notes, chord_type_full, chord_modes = analyze_chord(chord)
    assert len(chord_modes) == 1
    chord_degree, key, harmonic_func_full = chord_modes[0]
    ii_chord_type_short = chords.determine_seventh(chords.ii7(key), shorthand=True)[0]
    return [ii_chord_type_short, chord]
Esempio n. 11
0
def create_seventh_name(note):
    return chords.determine_seventh(chords.seventh(note, note), shorthand=True)[0]
Esempio n. 12
0
    elif args.action == 'reharmonize_v_to_ii_v':
        for chord in args.chords:
            ii_chord_type_short, chord = reharmonize_v_to_ii_v(chord)
            print("II-V ({}, {})".format(ii_chord_type_short, chord))

    elif args.action == 'ii_v_tritone_substitution':
        for chord in args.chords:
            chord_notes = chords.from_shorthand(chord)
            new_note = reduce_accidentals(tritone(chord_notes[0]))
            new_chord = new_note + '7'

            ii_chord_type_short, chord = reharmonize_v_to_ii_v(new_chord)
            print("{} {}".format(ii_chord_type_short, new_chord))

    elif args.action == 'chord_modes':
        chords = [chords.determine_seventh(mode_func(args.key), shorthand=True)[0]
                  for mode_func in MODE_CHORD_FUNCTIONS]
        print(', '.join(chords))

    elif args.action == '12_bar_blues':
        for four_bars in twelve_bar_blues(args.key):
            print('\t'.join(four_bars))

    elif args.action == 'blues_scale':
        print("{} blues scale: {}".format(args.key, ', '.join(blues_scale(args.key))))

    elif args.action == '12_bar_blues_printout':
        from mingus.containers.note import QuarterNoteFactory as Q
        from mingus.core.chords import WholNoteChordFactory as WNC
        blues_scale = Blues(args.key)
        bar = Bar()
Esempio n. 13
0
 def test_determine_seventh_shorthand(self):
     self.chordsTest([[['Am7', 'CM6', 'CM|Am'], ['A', 'C', 'E', 'G']],
                     [['CM7', 'Em|CM'], ['C', 'E', 'G', 'B']], [['CM7'], ['E'
                     , 'G', 'B', 'C']], [['Fm/M7', 'Abaug|Fm'], ['F', 'Ab',
                     'C', 'E']]], lambda x: chords.determine_seventh(x,
                     True), 'proper naming')