# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # Ordered Pitch Class Interval (UPCI)

import music21


def get_opci(x, y):
    """
    Get Straus' OPCI
    'y - x mod12'
    """
    
    x = music21.pitch.Pitch(x).pitchClass
    y = music21.pitch.Pitch(y).pitchClass
    
    opci = (y - x) % 12
    
    return opci


get_opci('C4','G5')

StarcoderdataJupyterScriptsDedupFiltered