.. _moduleMusedata.base40:

music21.musedata.base40
=======================

.. WARNING: DO NOT EDIT THIS FILE: AUTOMATICALLY GENERATED. Edit the .py file directly

.. module:: music21.musedata.base40



.. function:: base40ActualInterval(base40NumA, base40NumB)


    Calculates a music21 Interval between two Base40 pitch
    numbers, as calculated using the music21.interval module.

    Raises a Base40 Exception if (a) Either of the Base40 pitch
    numbers does not correspond to a pitch name or (b) If
    an unusual interval is encountered that can't be handled
    by music21.



    >>> from music21 import *
    >>> musedata.base40.base40ActualInterval(163,191)
    <music21.interval.Interval m6>
    >>> musedata.base40.base40ActualInterval(186,174) #Descending M3
    <music21.interval.Interval M-3>
    >>> musedata.base40.base40ActualInterval(1,5)
    <music21.interval.Interval AAAA1>
    >>> musedata.base40.base40ActualInterval(1,3)
    <music21.interval.Interval AA1>
    >>> musedata.base40.base40ActualInterval(2,6)
    Traceback (most recent call last):
    Base40Exception: Pitch name not assigned to this Base40 number 6



.. function:: base40DeltaToInterval(delta)


    Returns a music21 Interval between two Base40 pitch numbers
    given the delta (difference) between them.

    Raises a Base40 Exception if the interval is not handled by Base40.
    Base40 can only handle major, minor, perfect, augmented,
    and diminished intervals. Although not for certain, it seems
    that the engineers that designed this system assumed that
    other intervals (doubly augmented intervals, for instance)
    would be of a very rare occurrence, and extreme intervals
    which would trigger an incorrect answer (C-- to C##, for
    instance, would return a diminished second, even though it's
    a quadruple augmented unison) just would not occur.



    >>> from music21 import *
    >>> musedata.base40.base40DeltaToInterval(4)
    <music21.interval.Interval d2>
    >>> musedata.base40.base40DeltaToInterval(11)
    <music21.interval.Interval m3>
    >>> musedata.base40.base40DeltaToInterval(23)
    <music21.interval.Interval P5>
    >>> musedata.base40.base40DeltaToInterval(-23)
    <music21.interval.Interval P-5>
    >>> musedata.base40.base40DeltaToInterval(52)
    <music21.interval.Interval M10>
    >>> musedata.base40.base40DeltaToInterval(-52)
    <music21.interval.Interval M-10>
    >>> musedata.base40.base40DeltaToInterval(77)
    Traceback (most recent call last):
    Base40Exception: Interval not handled by Base40 37



.. function:: base40Interval(base40NumA, base40NumB)


    Returns a music21 Interval between two base40 pitch
    numbers, using their delta (difference) as defined
    in Base40. The interval provided is without direction.

    Raises a Base40 Exception if the delta doesn't correspond
    to an interval in Base40, or if either base40 pitch
    number doesn't correspond to a pitch name.



    >>> from music21 import *
    >>> musedata.base40.base40Interval(163,191)
    <music21.interval.Interval m6>
    >>> musedata.base40.base40Interval(186,174)      #Descending M3
    <music21.interval.Interval M-3>
    >>> musedata.base40.base40Interval(1,5)          #INCORRECT!
    <music21.interval.Interval d2>
    >>> musedata.base40.base40Interval(1,3)
    Traceback (most recent call last):
    Base40Exception: Interval not handled by Base40 2
    >>> musedata.base40.base40Interval(2,6)
    Traceback (most recent call last):
    Base40Exception: Pitch name not assigned to this Base40 number 6 Interval does not exist



.. function:: base40ToPitch(base40Num)


    Converts a Base40 pitch number into a music21 Pitch.
    The Base40 number is octave specific.

    Raises a Base40 Exception if the Base40 pitch number given doesn't
    have an associated pitch name. There is one unassigned number
    each time the interval between two letters is a whole step.



    >>> from music21 import *
    >>> musedata.base40.base40ToPitch(1)
    C--1
    >>> musedata.base40.base40ToPitch(40)
    B##1
    >>> musedata.base40.base40ToPitch(23)
    Traceback (most recent call last):
    Base40Exception: Pitch name not assigned to this Base40 number 23
    >>> musedata.base40.base40ToPitch(186)
    G5



.. function:: pitchToBase40(pitchToConvert)


    Converts a pitch string or a music21 Pitch into a Base40
    pitch number. The Base40 number is octave specific.

    Raises a Base40 Exception if the pitch to convert is outside the set
    of pitches that Base40 can handle; for example, half flats
    and half sharps or triple flats and triple sharps.



    >>> from music21 import *
    >>> musedata.base40.pitchToBase40(pitch.Pitch('C--5'))
    161
    >>> musedata.base40.pitchToBase40('F##4')
    142
    >>> musedata.base40.pitchToBase40('F###4')
    Traceback (most recent call last):
    Base40Exception: Base40 cannot handle this pitch F###4



