orbichord/chordinate.py
def interscalarMatrix(
    chordA: Chord,
    chordB: Chord,
    scale: ConcreteScale,
    cardinality: bool = True,
    permutation: Permutation = Permutation.ANY
) -> list:
    """Compute the interscalar matrix between two chords

    Parameters
    ----------
        chrodA : Chrod
            Voice leading start chord.
        chrodA : Chrod
            Voice leading end chord
        scale : ConcreteScale
            Scale use a metric.
        cardinality: bool, optional
            If true chord cardinality is invariant.
        permutation : Permutation, optional
            Permutation invariance in the interscalar matrix.

    Return
    ------
        list
            List of voice leading scalar steps

    Examples
    --------
    >>> from music21.chord import Chord
    >>> from music21.scale import MajorScale
    >>> from orbichord.chordinate import interscalarMatrix, Permutation
    >>> scale = MajorScale('C')
    >>> chordA = Chord('C E G')
    >>> chordB = Chord('A C E')
    >>> matrix = interscalarMatrix(
    ...     chordA, chordB, scale
    >>> )
    >>> print(matrix)
    [[0, 0, 1], [2, 3, 3], [-2, -2, -2]]
    """
    if chordA.multisetCardinality != chordB.multisetCardinality:
        raise ValueError('Chords are not of the same dimension!')
    if cardinality:
        tmpA = chordA.removeRedundantPitchClasses(inPlace=False)
        tmpB = chordB.removeRedundantPitchClasses(inPlace=False)
        if tmpA.multisetCardinality == tmpB.multisetCardinality:
            chordA = tmpA
            chordB = tmpB
    pointA = scalePoint(chordA, scale)
    pointB = scalePoint(chordB, scale)
    if permutation == Permutation.ANY:
        pointA.sort(); pointB.sort()
    dimension = len(pointA)
    voice_leadings = []
    max_scale_degree = scale.getDegreeMaxUnique()
    while pointB[0] < max_scale_degree:
        delta = [0]*dimension
        for i in range(dimension):
            delta[i] = mod(pointB[i], pointA[i], max_scale_degree)
        voice_leadings.append(delta)
        if permutation == Permutation.NONE:
            break
        tmp = pointB[0]
        pointB = pointB[1:] + [tmp + max_scale_degree]
    return voice_leadings
Compute the interscalar matrix between two chords

    Parameters
    ----------
        chrodA : Chrod
            Voice leading start chord.
        chrodA : Chrod
            Voice leading end chord
        scale : ConcreteScale
            Scale use a metric.
        cardinality: bool, optional
            If true chord cardinality is invariant.
        permutation : Permutation, optional
            Permutation invariance in the interscalar matrix.

    Return
    ------
        list
            List of voice leading scalar steps

    Examples
    --------
    >>> from music21.chord import Chord
    >>> from music21.scale import MajorScale
    >>> from orbichord.chordinate import interscalarMatrix, Permutation
    >>> scale = MajorScale('C')
    >>> chordA = Chord('C E G')
    >>> chordB = Chord('A C E')
    >>> matrix = interscalarMatrix(
    ...     chordA, chordB, scale
    >>> )
    >>> print(matrix)
    [[0, 0, 1], [2, 3, 3], [-2, -2, -2]]
    
Compute the interscalar matrix between two chords
Parameters

chrodA : Chrod
Voice leading start chord.
chrodA : Chrod
Voice leading end chord
scale : ConcreteScale
Scale use a metric.
cardinality: bool, optional
If true chord cardinality is invariant.
permutation : Permutation, optional
Permutation invariance in the interscalar matrix.

Return

list
List of voice leading scalar steps

Examples


Compute the interscalar matrix between two chords Parameters chrodA : Chrod Voice leading start chord . chrodA : Chrod Voice leading end chord scale : ConcreteScale Scale use a metric . cardinality : bool optional If true chord cardinality is invariant . permutation : Permutation optional Permutation invariance in the interscalar matrix . Return list List of voice leading scalar steps Examples
def interscalarMatrix(
    chordA: Chord,
    chordB: Chord,
    scale: ConcreteScale,
    cardinality: bool = True,
    permutation: Permutation = Permutation.ANY
) -> list:
    if chordA.multisetCardinality != chordB.multisetCardinality:
        raise ValueError('Chords are not of the same dimension!')
    if cardinality:
        tmpA = chordA.removeRedundantPitchClasses(inPlace=False)
        tmpB = chordB.removeRedundantPitchClasses(inPlace=False)
        if tmpA.multisetCardinality == tmpB.multisetCardinality:
            chordA = tmpA
            chordB = tmpB
    pointA = scalePoint(chordA, scale)
    pointB = scalePoint(chordB, scale)
    if permutation == Permutation.ANY:
        pointA.sort(); pointB.sort()
    dimension = len(pointA)
    voice_leadings = []
    max_scale_degree = scale.getDegreeMaxUnique()
    while pointB[0] < max_scale_degree:
        delta = [0]*dimension
        for i in range(dimension):
            delta[i] = mod(pointB[i], pointA[i], max_scale_degree)
        voice_leadings.append(delta)
        if permutation == Permutation.NONE:
            break
        tmp = pointB[0]
        pointB = pointB[1:] + [tmp + max_scale_degree]
    return voice_leadings
def interscalarMatrix ( chordA : Chord , chordB : Chord , scale : ConcreteScale , cardinality : bool = True , permutation : Permutation = Permutation . ANY ) -> list : if chordA . multisetCardinality != chordB . multisetCardinality : raise ValueError ( 'Chords are not of the same dimension!' ) if cardinality : tmpA = chordA . removeRedundantPitchClasses ( inPlace = False ) tmpB = chordB . removeRedundantPitchClasses ( inPlace = False ) if tmpA . multisetCardinality == tmpB . multisetCardinality : chordA = tmpA chordB = tmpB pointA = scalePoint ( chordA , scale ) pointB = scalePoint ( chordB , scale ) if permutation == Permutation . ANY : pointA . sort ( ) ; pointB . sort ( ) dimension = len ( pointA ) voice_leadings = [ ] max_scale_degree = scale . getDegreeMaxUnique ( ) while pointB [ 0 ] < max_scale_degree : delta = [ 0 ] * dimension for i in range ( dimension ) : delta [ i ] = mod ( pointB [ i ] , pointA [ i ] , max_scale_degree ) voice_leadings . append ( delta ) if permutation == Permutation . NONE : break tmp = pointB [ 0 ] pointB = pointB [ 1 : ] + [ tmp + max_scale_degree ] return voice_leadings
Compute the interscalar matrix between two chords
Parameters
Compute the interscalar matrix between two chords Parameters
"""Compute the interscalar matrix between two chords

    Parameters
    ----------
        chrodA : Chrod
            Voice leading start chord.
        chrodA : Chrod
            Voice leading end chord
        scale : ConcreteScale
            Scale use a metric.
        cardinality: bool, optional
            If true chord cardinality is invariant.
        permutation : Permutation, optional
            Permutation invariance in the interscalar matrix.

    Return
    ------
        list
            List of voice leading scalar steps

    Examples
    --------
    >>> from music21.chord import Chord
    >>> from music21.scale import MajorScale
    >>> from orbichord.chordinate import interscalarMatrix, Permutation
    >>> scale = MajorScale('C')
    >>> chordA = Chord('C E G')
    >>> chordB = Chord('A C E')
    >>> matrix = interscalarMatrix(
    ...     chordA, chordB, scale
    >>> )
    >>> print(matrix)
    [[0, 0, 1], [2, 3, 3], [-2, -2, -2]]
    """
chordA
Chord
chordB
Chord
scale
ConcreteScale
cardinality
bool
permutation
Permutation