.. _moduleAbj.translate:

music21.abj.translate
=====================

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

.. module:: music21.abj.translate

Translation methods for going from music21 to Victor Adan and Trevor Baca's Abjad framework -- a high-quality, Lilypond-based python framework for algorithmic music composition and post-tonal music. See http://packages.python.org/Abjad/ for more details.  Requires abjad 2.0 (not 1.1.1) to work.  Fetchable via SVN as of January 2011. automatically imported in music21.abj: 




.. function:: noteToAbjad(m21Note)

    Translates a simple music21 Note (no ties or tuplets) to an abjad note. 

    >>> import abjad
    >>> import music21
    >>> m21Note1 = music21.note.Note("C#5")
    >>> m21Note1.quarterLength = 2
    >>> abjadNote1 = music21.abj.noteToAbjad(m21Note1)
    >>> abjadNote1
    Note("cs''2") 
    >>> abjad.iotools.show(abjadNote1)


    .. image:: images/abjad_output_cs.*
        :width: 217


    

    
    >>> m21Note2 = music21.note.Note("D--2")
    >>> m21Note2.quarterLength = 0.125
    >>> abjadNote2 = music21.abj.noteToAbjad(m21Note2)
    >>> abjadNote2
    Note('dff,32') 
    >>> m21Note3 = music21.note.Note("E-6")
    >>> m21Note3.quarterLength = 2.333333333333333
    >>> abjadNote3 = music21.abj.noteToAbjad(m21Note3)
    Traceback (most recent call last): 
    AbjadTranslateException: cannot translate complex notes directly 

.. function:: music21ObjectToAbjad(m21Object)

    translates an arbitrary object into abjad objects. might return a tuple because some single m21 objects will require multiple abjad objects (and vice versa). 

    

.. function:: pitchToAbjad(m21Pitch)

    translates a music21 :class:`music21.pitch.Pitch` object to abjad.Pitch object 

    >>> import music21
    >>> m21p = music21.pitch.Pitch("D--2")
    >>> music21.abj.pitchToAbjad(m21p)
    NamedChromaticPitch('dff,') 

.. function:: streamToAbjad(m21Stream, makeNotation=True)

    translates a Stream into an Abjad container 

    >>> import abjad
    >>> import music21
    >>> stream1 = music21.parse("c4 d8. e-16 FF2", "4/4")
    >>> abjadContainer = music21.abj.streamToAbjad(stream1)
    >>> abjadContainer
    Staff{4} 
    >>> abjadContainer.leaves[:]
    (Note("c'4"), Note("d'8."), Note("ef'16"), Note('f,2')) 
    >>> abjad.iotools.show(abjadContainer)

    


    .. image:: images/abjad_translateStream1.*
        :width: 371


    

    

.. function:: translateLilyStringPitch(lilyStringPitch)

    Translates cis to cs And ces to cf 

    

    >>> translateLilyStringPitch("cis''2")
    "cs''2" 

    

