Objects for exporting music21 data as braille.
Takes in a KeySignature and returns its representation in braille as a string in utf-8 unicode.
>>> from music21.braille import translate
>>> from music21 import key
>>> ksFourSharps = key.KeySignature(4)
>>> translate.keySigToBraille(ksFourSharps)
u'\u283c\u2819\u2829'
Method for translating a Measure into braille. Currently, only translates Note and Rest objects.
If showLeadingOctave is set to True, the first note of the measure carries an octave designation. Other notes in the measure carry an octave designation only if applicable. (See showOctaveWithNote().)
Given a Note, returns the appropriate braille characters as a string in utf-8 unicode.
The format for note display in braille is the accidental (if necessary) + octave (if necessary) + pitch name with length.
If the note has an Accidental, the accidental is always displayed unless its displayStatus is set to False. The octave of the note is only displayed if showOctave is set to True.
>>> from music21.braille import translate
>>> from music21 import note
>>> C4 = note.Note('C4')
>>> translate.noteToBraille(sampleNote = C4)
u'\u2810\u2839'
>>> C4.quarterLength = 2.0
>>> translate.noteToBraille(sampleNote = C4)
u'\u2810\u281d'
>>> Ds4 = note.Note('D#4')
>>> translate.noteToBraille(sampleNote = Ds4)
u'\u2829\u2810\u2831'
>>> translate.noteToBraille(sampleNote = Ds4, showOctave = False)
u'\u2829\u2831'
>>> Ds4.pitch.setAccidentalDisplay(False)
>>> translate.noteToBraille(sampleNote = Ds4)
u'\u2810\u2831'
>>> A2 = note.Note('A2')
>>> A2.quarterLength = 3.0
>>> translate.noteToBraille(sampleNote = A2)
u'\u2818\u280e\u2804'
Given a Part, returns the appropriate braille characters as a string in utf-8 unicode.
A thing to keep in mind: there is a 40 braille character limit per line. All spaces are filled in with empty six-cell braille characters.
Given a Rest, returns the appropriate braille characters as a string in utf-8 unicode.
Currently, only supports single rests with or without dots. Compound rests are not supported.
>>> from music21.braille import translate
>>> from music21 import note
>>> dottedQuarter = note.Rest(quarterLength = 1.5)
>>> translate.restToBraille(dottedQuarter)
u'\u2827\u2804'
>>> whole = note.Rest(quarterLength = 4.0)
>>> translate.restToBraille(whole)
u'\u280d'
>>> quarterPlusSixteenth = note.Rest(quarterLength = 1.25)
>>> translate.restToBraille(quarterPlusSixteenth)
Traceback (most recent call last):
BrailleTranslateException: Rest duration cannot be translated to braille.
Determines whether a currentNote carries an octave designation in relation to a previousNote.
Rules:
Takes in a TimeSignature and returns its representation in braille as a string in utf-8 unicode.
The format for a numerical time signature in braille is the number symbol + beat count as a braille number + beat units, also a braille number but brought down in the cell.
>>> from music21.braille import translate
>>> from music21 import meter
>>> translate.timeSigToBraille(sampleTimeSig = meter.TimeSignature('3/4'))
u'\u283c\u2809\u2832'
>>> translate.timeSigToBraille(sampleTimeSig = meter.TimeSignature('12/8'))
u'\u283c\u2801\u2803\u2826'
>>> translate.timeSigToBraille(sampleTimeSig = meter.TimeSignature('4/4'))
u'\u283c\u2819\u2832'
>>> from music21.braille import translate