示例#1
0
def keyboardPartsToBraille(music21PartStaffUpper, music21PartStaffLower,
                           **keywords):
    """
    Translates two :class:`~music21.stream.Part` instances to braille, an upper part and a lower
    part. Assumes that the two parts are aligned and well constructed. Bar over bar format is used.
    """
    (inPlace, debug) = _translateArgs(**keywords)
    upperPartToTranscribe = music21PartStaffUpper
    if not inPlace:
        upperPartToTranscribe = music21PartStaffUpper.makeNotation(
            cautionaryNotImmediateRepeat=False)
    lowerPartToTranscribe = music21PartStaffLower
    if not inPlace:
        lowerPartToTranscribe = music21PartStaffLower.makeNotation(
            cautionaryNotImmediateRepeat=False)
    rhSegments = segment.findSegments(upperPartToTranscribe, **keywords)
    lhSegments = segment.findSegments(lowerPartToTranscribe, **keywords)
    allBrailleText = []
    for (rhSegment, lhSegment) in zip(rhSegments, lhSegments):
        bg = segment.BrailleGrandSegment(rhSegment, lhSegment)
        if not debug:
            allBrailleText.append(bg.transcription)
        else:
            allBrailleText.append(str(bg))
    return u"\n".join([unicode(bt) for bt in allBrailleText])
示例#2
0
def keyboardPartsToBraille(staffUpper, staffLower, **keywords):
    """
    Translates two :class:`~music21.stream.Part` instances to braille, an upper part and a lower
    part. Assumes that the two parts are aligned and well constructed. Bar over bar format is used.
    """
    (inPlace, debug) = _translateArgs(**keywords)
    upperPartToTranscribe = staffUpper
    if not inPlace:
        upperPartToTranscribe = staffUpper.makeNotation(cautionaryNotImmediateRepeat=False)
    lowerPartToTranscribe = staffLower
    if not inPlace:
        lowerPartToTranscribe = staffLower.makeNotation(cautionaryNotImmediateRepeat=False)
    rhSegments = segment.findSegments(upperPartToTranscribe, **keywords)
    lhSegments = segment.findSegments(lowerPartToTranscribe, **keywords)
    allBrailleText = []
    for (rhSegment, lhSegment) in zip(rhSegments, lhSegments):
        bg = segment.BrailleGrandSegment(rhSegment, lhSegment)
        if not debug:
            allBrailleText.append(bg.transcription)
        else:
            if six.PY2:
                bsStr = str(bg)
                bsUni = bsStr.decode('utf-8')
                allBrailleText.append(bsUni)
            else:
                allBrailleText.append(str(bg))
    
    if six.PY2 and debug:
        return u"\n".join(allBrailleText)
    else:
        return u"\n".join([unicode(bt) for bt in allBrailleText])
示例#3
0
def keyboardPartsToBraille(keyboardScore, **keywords):
    """
    Translates a Score object containing two :class:`~music21.stream.Part` instances to braille, 
    an upper part and a lower
    part. Assumes that the two parts are aligned and well constructed. Bar over bar format is used.
    """
    parts = keyboardScore.getElementsByClass(['Part', 'PartStaff'])
    if len(parts) != 2:
        raise BrailleTranslateException(
            "Can only translate two keyboard parts at a time")
    (inPlace, debug) = _translateArgs(**keywords)
    staffUpper = parts[0]
    staffLower = parts[1]
    upperPartToTranscribe = staffUpper
    if not inPlace:
        upperPartToTranscribe = staffUpper.makeNotation(
            cautionaryNotImmediateRepeat=False)
    lowerPartToTranscribe = staffLower
    if not inPlace:
        lowerPartToTranscribe = staffLower.makeNotation(
            cautionaryNotImmediateRepeat=False)
    rhSegments = segment.findSegments(upperPartToTranscribe,
                                      setHand='right',
                                      **keywords)
    lhSegments = segment.findSegments(lowerPartToTranscribe,
                                      setHand='left',
                                      **keywords)

    allBrailleText = []
    for (rhSegment, lhSegment) in zip(rhSegments, lhSegments):
        bg = segment.BrailleGrandSegment()
        for rhGroupingKey in rhSegment:
            bg[rhGroupingKey] = rhSegment[rhGroupingKey]

        for lhGroupingKey in lhSegment:
            bg[lhGroupingKey] = lhSegment[lhGroupingKey]

        bg.transcribe()
        if not debug:
            allBrailleText.append(bg.brailleText)
        else:
            if six.PY2:
                bsStr = str(bg)
                bsUni = bsStr.decode('utf-8')
                allBrailleText.append(bsUni)
            else:
                allBrailleText.append(str(bg))

    if six.PY2 and debug:
        return u"\n".join(allBrailleText)
    else:
        return u"\n".join([unicode(bt) for bt in allBrailleText])
示例#4
0
def partToBraille(music21Part, **keywords):
    '''
    Translates a :class:`~music21.stream.Part` to braille.

    This is one of two (w/ keyboardPartsToBraille) main routines.  Runs segment.findSegments
    and then for each segment runs transcribe on it.
    '''
    (inPlace, debug) = _translateArgs(**keywords)
    partToTranscribe = music21Part
    if not inPlace:
        partToTranscribe = music21Part.makeNotation(
            cautionaryNotImmediateRepeat=False)
    allSegments = segment.findSegments(partToTranscribe, **keywords)
    allBrailleText = []
    for brailleSegment in allSegments:
        transcription = brailleSegment.transcribe()

        if not debug:
            allBrailleText.append(transcription)
        else:
            allBrailleText.append(str(brailleSegment))

    from music21.braille.basic import beamStatus
    for x in list(
            beamStatus
    ):  # coerce to list first so that dictionary does not change size
        del beamStatus[x]  # while iterating.

    return '\n'.join([str(bt) for bt in allBrailleText])
示例#5
0
def partToBraille(music21Part, **keywords):
    """
    Translates a :class:`~music21.stream.Part` to braille.
    
    This is one of two (w/ keyboardPartsToBraille) main routines.  Runs segment.findSegments
    and then for each segment runs transcribe on it.
    """
    (inPlace, debug) = _translateArgs(**keywords)
    partToTranscribe = music21Part
    if not inPlace:
        partToTranscribe = music21Part.makeNotation(cautionaryNotImmediateRepeat=False)
    allSegments = segment.findSegments(partToTranscribe, **keywords)
    allBrailleText = []
    for brailleSegment in allSegments:
        transcription = brailleSegment.transcribe()
        
        if not debug:
            allBrailleText.append(transcription)
        else:
            if six.PY2:
                bsStr = str(brailleSegment)
                bsUni = bsStr.decode('utf-8')
                allBrailleText.append(bsUni)
            else:
                allBrailleText.append(str(brailleSegment))

    if six.PY2 and debug:
        return u"\n".join(allBrailleText)
    else:
        return u"\n".join([unicode(bt) for bt in allBrailleText])
示例#6
0
def partToBraille(music21Part, **keywords):
    """
    Translates a :class:`~music21.stream.Part` to braille.

    This is one of two (w/ keyboardPartsToBraille) main routines.  Runs segment.findSegments
    and then for each segment runs transcribe on it.
    """
    (inPlace, debug) = _translateArgs(**keywords)
    partToTranscribe = music21Part
    if not inPlace:
        partToTranscribe = music21Part.makeNotation(cautionaryNotImmediateRepeat=False)
    allSegments = segment.findSegments(partToTranscribe, **keywords)
    allBrailleText = []
    for brailleSegment in allSegments:
        transcription = brailleSegment.transcribe()

        if not debug:
            allBrailleText.append(transcription)
        else:
            allBrailleText.append(str(brailleSegment))

    from music21.braille.basic import beamStatus
    for x in list(beamStatus): # coerce to list first so that dictionary does not change size
        del beamStatus[x]      # while iterating.

    return "\n".join([str(bt) for bt in allBrailleText])
示例#7
0
def partToBraille(music21Part, **keywords):
    """
    Translates a :class:`~music21.stream.Part` to braille.
    """
    (inPlace, debug) = _translateArgs(**keywords)
    partToTranscribe = music21Part
    if not inPlace:
        partToTranscribe = music21Part.makeNotation(
            cautionaryNotImmediateRepeat=False)
    allSegments = segment.findSegments(partToTranscribe, **keywords)
    allBrailleText = []
    for brailleSegment in allSegments:
        transcription = brailleSegment.transcribe()

        if not debug:
            allBrailleText.append(transcription)
        else:
            if six.PY2:
                bsStr = str(brailleSegment)
                bsUni = bsStr.decode('utf-8')
                allBrailleText.append(bsUni)
            else:
                allBrailleText.append(str(brailleSegment))

    if six.PY2 and debug:
        return u"\n".join(allBrailleText)
    else:
        return u"\n".join([unicode(bt) for bt in allBrailleText])
示例#8
0
def partToBraille(music21Part,
                  *,
                  inPlace=False,
                  debug=False,
                  cancelOutgoingKeySig=True,
                  descendingChords=None,
                  dummyRestLength=None,
                  maxLineLength=40,
                  segmentBreaks=None,
                  showClefSigns=False,
                  showFirstMeasureNumber=True,
                  showHand=None,
                  showHeading=True,
                  showLongSlursAndTiesTogether: t.Optional[bool] = None,
                  showShortSlursAndTiesTogether=False,
                  slurLongPhraseWithBrackets=True,
                  suppressOctaveMarks=False,
                  upperFirstInNoteFingering=True,
                  ):
    '''
    Translates a :class:`~music21.stream.Part` to braille.

    This is one of two (w/ keyboardPartsToBraille) main routines.  Runs segment.findSegments
    and then for each segment runs transcribe on it.
    '''
    partToTranscribe = music21Part
    if not inPlace:
        partToTranscribe = music21Part.makeNotation(cautionaryNotImmediateRepeat=False)
    allSegments = segment.findSegments(partToTranscribe,
                                       cancelOutgoingKeySig=cancelOutgoingKeySig,
                                       descendingChords=descendingChords,
                                       dummyRestLength=dummyRestLength,
                                       maxLineLength=maxLineLength,
                                       segmentBreaks=segmentBreaks,
                                       showClefSigns=showClefSigns,
                                       showFirstMeasureNumber=showFirstMeasureNumber,
                                       showHand=showHand,
                                       showHeading=showHeading,
                                       showLongSlursAndTiesTogether=showLongSlursAndTiesTogether,
                                       showShortSlursAndTiesTogether=showShortSlursAndTiesTogether,
                                       slurLongPhraseWithBrackets=slurLongPhraseWithBrackets,
                                       suppressOctaveMarks=suppressOctaveMarks,
                                       upperFirstInNoteFingering=upperFirstInNoteFingering,
                                       )
    allBrailleText = []
    for brailleSegment in allSegments:
        transcription = brailleSegment.transcribe()

        if not debug:
            allBrailleText.append(transcription)
        else:
            allBrailleText.append(str(brailleSegment))

    from music21.braille.basic import beamStatus
    for x in list(beamStatus):  # coerce to list first so that dictionary does not change size
        del beamStatus[x]      # while iterating.

    return '\n'.join([str(bt) for bt in allBrailleText])
示例#9
0
def keyboardPartsToBraille(keyboardScore, **keywords):
    """
    Translates a Score object containing two :class:`~music21.stream.Part` instances to braille,
    an upper part and a lower
    part. Assumes that the two parts are aligned and well constructed. Bar over bar format is used.
    """
    parts = keyboardScore.getElementsByClass(['Part', 'PartStaff'])
    if len(parts) != 2:
        raise BrailleTranslateException("Can only translate two keyboard parts at a time")
    (inPlace, debug) = _translateArgs(**keywords)
    staffUpper = parts[0]
    staffLower = parts[1]
    upperPartToTranscribe = staffUpper
    if not inPlace:
        upperPartToTranscribe = staffUpper.makeNotation(cautionaryNotImmediateRepeat=False)
    lowerPartToTranscribe = staffLower
    if not inPlace:
        lowerPartToTranscribe = staffLower.makeNotation(cautionaryNotImmediateRepeat=False)
    rhSegments = segment.findSegments(upperPartToTranscribe, setHand='right', **keywords)
    lhSegments = segment.findSegments(lowerPartToTranscribe, setHand='left', **keywords)

    allBrailleText = []
    for (rhSegment, lhSegment) in zip(rhSegments, lhSegments):
        bg = segment.BrailleGrandSegment()
        for rhGroupingKey in rhSegment:
            bg[rhGroupingKey] = rhSegment[rhGroupingKey]

        for lhGroupingKey in lhSegment:
            bg[lhGroupingKey] = lhSegment[lhGroupingKey]

        bg.transcribe()
        if not debug:
            allBrailleText.append(bg.brailleText)
        else:
            if six.PY2:
                bsStr = str(bg)
                bsUni = bsStr.decode('utf-8')
                allBrailleText.append(bsUni)
            else:
                allBrailleText.append(str(bg))

    if six.PY2 and debug:
        return u"\n".join(allBrailleText)
    else:
        return u"\n".join([unicode(bt) for bt in allBrailleText])
示例#10
0
def partToBraille(music21Part, **keywords):
    """
    Translates a :class:`~music21.stream.Part` to braille.
    """
    (inPlace, debug) = _translateArgs(**keywords)
    partToTranscribe = music21Part
    if not inPlace:
        partToTranscribe = music21Part.makeNotation(cautionaryNotImmediateRepeat=False)
    allSegments = segment.findSegments(partToTranscribe, **keywords)
    allBrailleText = []
    for brailleSegment in allSegments:
        transcription = brailleSegment.transcribe()
        if not debug:
            allBrailleText.append(transcription)
        else:
            allBrailleText.append(str(brailleSegment))
    return u"\n".join([unicode(bt) for bt in allBrailleText])
示例#11
0
def keyboardPartsToBraille(keyboardScore,
                           *,
                           inPlace=False,
                           debug=False,
                           cancelOutgoingKeySig=True,
                           descendingChords=None,
                           dummyRestLength=None,
                           maxLineLength=40,
                           segmentBreaks=None,
                           showClefSigns=False,
                           showFirstMeasureNumber=True,
                           showHand=None,
                           showHeading=True,
                           showLongSlursAndTiesTogether: t.Optional[bool] = None,
                           showShortSlursAndTiesTogether=False,
                           slurLongPhraseWithBrackets=True,
                           suppressOctaveMarks=False,
                           upperFirstInNoteFingering=True,
                           ):
    '''
    Translates a Score object containing two :class:`~music21.stream.Part` instances to braille,
    an upper part and a lower
    part. Assumes that the two parts are aligned and well constructed. Bar over bar format is used.
    '''
    parts = keyboardScore.getElementsByClass(['Part', 'PartStaff'])
    if len(parts) != 2:
        raise BrailleTranslateException('Can only translate two keyboard parts at a time')
    staffUpper = parts[0]
    staffLower = parts[1]
    upperPartToTranscribe = staffUpper
    if not inPlace:
        upperPartToTranscribe = staffUpper.makeNotation(cautionaryNotImmediateRepeat=False)
    lowerPartToTranscribe = staffLower
    if not inPlace:
        lowerPartToTranscribe = staffLower.makeNotation(cautionaryNotImmediateRepeat=False)
    rhSegments = segment.findSegments(upperPartToTranscribe,
                                      setHand='right',
                                      cancelOutgoingKeySig=cancelOutgoingKeySig,
                                      descendingChords=descendingChords,
                                      dummyRestLength=dummyRestLength,
                                      maxLineLength=maxLineLength,
                                      segmentBreaks=segmentBreaks,
                                      showClefSigns=showClefSigns,
                                      showFirstMeasureNumber=showFirstMeasureNumber,
                                      showHand=showHand,
                                      showHeading=showHeading,
                                      showLongSlursAndTiesTogether=showLongSlursAndTiesTogether,
                                      showShortSlursAndTiesTogether=showShortSlursAndTiesTogether,
                                      slurLongPhraseWithBrackets=slurLongPhraseWithBrackets,
                                      suppressOctaveMarks=suppressOctaveMarks,
                                      upperFirstInNoteFingering=upperFirstInNoteFingering,
                                      )
    lhSegments = segment.findSegments(lowerPartToTranscribe,
                                      setHand='left',
                                      cancelOutgoingKeySig=cancelOutgoingKeySig,
                                      descendingChords=descendingChords,
                                      dummyRestLength=dummyRestLength,
                                      maxLineLength=maxLineLength,
                                      segmentBreaks=segmentBreaks,
                                      showClefSigns=showClefSigns,
                                      showFirstMeasureNumber=showFirstMeasureNumber,
                                      showHand=showHand,
                                      showHeading=showHeading,
                                      showLongSlursAndTiesTogether=showLongSlursAndTiesTogether,
                                      showShortSlursAndTiesTogether=showShortSlursAndTiesTogether,
                                      slurLongPhraseWithBrackets=slurLongPhraseWithBrackets,
                                      suppressOctaveMarks=suppressOctaveMarks,
                                      upperFirstInNoteFingering=upperFirstInNoteFingering,
                                      )

    allBrailleText = []
    for (rhSegment, lhSegment) in zip(rhSegments, lhSegments):
        bg = segment.BrailleGrandSegment(lineLength=maxLineLength)
        for rhGroupingKey in rhSegment:
            # print(type(rhSegment), type(rhSegment[rhGroupingKey]))
            # breakpoint()
            bg[rhGroupingKey] = rhSegment[rhGroupingKey]

        for lhGroupingKey in lhSegment:
            bg[lhGroupingKey] = lhSegment[lhGroupingKey]

        bg.transcribe()
        if not debug:
            allBrailleText.append(bg.brailleText)
        else:
            allBrailleText.append(str(bg))

    return '\n'.join([str(bt) for bt in allBrailleText])