.. _moduleAbc.translate:

music21.abc.translate
=====================

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

.. module:: music21.abc.translate


Functions for translating music21 objects and
:class:`~music21.abc.base.ABCHandler` instances.
Mostly, these functions are for advanced, low level usage.
For basic importing of ABC files from a file or URL to a
:class:`~music21.stream.Stream`, use the music21 converter
module's :func:`~music21.converter.parse` function.






.. function:: abcToStreamOpus(abcHandler, inputM21=None, number=None)

    Convert a multi-work stream into one or more complete works packed into a an Opus Stream.

    If a `number` argument is given, and a work is defined by that number, that work is returned.



.. function:: abcToStreamPart(abcHandler, inputM21=None, spannerBundle=None)


    Handler conversion of a single Part of a multi-part score.
    Results, as a Part, are built into the provided inputM21 object
    (a Score or similar Stream) or a newly created Stream.



.. function:: abcToStreamScore(abcHandler, inputM21=None)

    Given an abcHandler object, build into a multi-part :class:`~music21.stream.Score` with metadata.

    This assumes that this ABCHandler defines a single work (with 1 or fewer reference numbers).

    if the optional parameter inputM21 is given a music21 Stream subclass, it will use that object
    as the outermost object.  However, inner parts will always be made :class:`~music21.stream.Part` objects.



.. function:: reBar(music21Part, inPlace=True)


    Re-bar overflow measures using the last known time signature.



    >>> from music21.abc import translate
    >>> from music21 import corpus
    >>> irl = corpus.parse("irl")
    >>> music21Part = irl[1][1]


    The whole part is in 2/4 time, but there are some measures expressed in 4/4 time
    without an explicit time signature change, an error in abc parsing due to the
    omission of barlines. The method will split those measures such that they conform
    to the last time signature, in this case 2/4. The default is to reBar in place.
    The measure numbers are updated accordingly. (NOTE: reBar is called automatically
    in abcToStreamPart)


    The key signature and clef are assumed to be the same in the second measure after the
    split, so both are omitted. If the time signature is not the same in the second measure,
    the new time signature is indicated, and the measure following returns to the last time
    signature, except in the case that a new time signature is indicated.




    >>> music21Part.measure(15).show("text")
    {0.0} <music21.note.Note A>
    {1.0} <music21.note.Note A>
    >>> music21Part.measure(16).show("text")
    {0.0} <music21.note.Note A>
    {0.5} <music21.note.Note B->
    {1.0} <music21.note.Note A>
    {1.5} <music21.note.Note G>


    An example where the time signature wouldn't be the same. This score is probably
    mistakenly unmarked as 4/4, or is given that time signature by default.




    >>> music21Part2 = irl[14][1] # 4/4 time signature
    >>> music21Part2.measure(1).show("text")
    {0.0} <music21.note.Note C>
    {1.0} <music21.note.Note A>
    {1.5} <music21.note.Note G>
    {2.0} <music21.note.Note E>
    {2.5} <music21.note.Note G>
    >>> music21Part2.measure(2).show("text")
    {0.0} <music21.meter.TimeSignature 1/8>
    {0.0} <music21.note.Note E>



