Skip to content

Instantly share code, notes, and snippets.

View johentsch's full-sized avatar

Johannes Hentschel johentsch

View GitHub Profile
@johentsch
johentsch / absolute_chord2rn.py
Created April 4, 2022 14:37
Given an absolute chord (such as 'Ab') and an absolute key (such as 'C') return the chord's scale degree ('bVI').
from ms3 import fifths2rn, name2fifths, rel2abs_key
def absolute_chord2rn(abs_chord, abs_key):
"""Given an absolute chord (such as 'Ab') and an absolute key (such as 'C') return the chord's scale degree ('bVI')."""
is_minor_chord, is_minor_key = abs_chord.islower(), abs_key.islower()
chord_fifths, key_fifths = name2fifths(abs_chord), name2fifths(abs_key)
interval = chord_fifths - key_fifths
result = fifths2rn(interval, is_minor_key)
if is_minor_chord:
result = result.lower()
@johentsch
johentsch / sort_labels.py
Last active July 24, 2020 11:23
Function for sorting DCML harmony labels with respect to their features given a custom ordering logic.
import re
import pandas as pd
import numpy as np
from urllib.request import urlopen
REGEX = {}
def features2type(numeral, form=None, figbass=None):
""" Turns a combination of the three chord features into a chord type.