Example #1
0
    def addNoteGroupings(self, measureNumber, noteGroupingR, noteGroupingL):
        if self.rightHandLine is None and self.leftHandLine is None:
            self.makeNewLines()
        if self.rightHandLine.textLocation == 0:
            self.rightHandLine.insert(
                self.highestMeasureNumberLength - len(measureNumber),
                measureNumber)
            self.leftHandLine.textLocation = self.rightHandLine.textLocation
        addSpace = True
        if self.rightHandLine.containsNoteGrouping is False:
            addSpace = False
            self.rightHandLine.append(symbols['rh_keyboard'], addSpace=True)
            self.leftHandLine.append(symbols['lh_keyboard'], addSpace=True)
            if noteGroupingR:
                for dot in yieldDots(noteGroupingR[0]):
                    self.rightHandLine.append(dot, addSpace=False)
            if noteGroupingL:
                for dot in yieldDots(noteGroupingL[0]):
                    self.leftHandLine.append(dot, addSpace=False)
        if (self.rightHandLine.canAppend(noteGroupingR, addSpace=addSpace)
                and self.leftHandLine.canAppend(noteGroupingL,
                                                addSpace=addSpace)):
            if noteGroupingL:
                self.leftHandLine.append(noteGroupingL, addSpace=addSpace)
            if noteGroupingR:
                self.rightHandLine.append(noteGroupingR, addSpace=addSpace)
            if self.rightHandLine.textLocation > self.leftHandLine.textLocation:
                self.leftHandLine.textLocation = self.rightHandLine.textLocation
            else:
                self.rightHandLine.textLocation = self.leftHandLine.textLocation
        else:
            self.makeNewLines()
            self.rightHandLine.insert(
                self.highestMeasureNumberLength - len(measureNumber),
                measureNumber)
            self.leftHandLine.textLocation = self.rightHandLine.textLocation
            self.rightHandLine.append(symbols['rh_keyboard'], addSpace=True)
            self.leftHandLine.append(symbols['lh_keyboard'], addSpace=True)
            if noteGroupingR:
                for dot in yieldDots(noteGroupingR[0]):
                    self.rightHandLine.append(dot, addSpace=False)
                self.rightHandLine.append(noteGroupingR, addSpace=False)

            if noteGroupingL:
                for dot in yieldDots(noteGroupingL[0]):
                    self.leftHandLine.append(dot, addSpace=False)
                self.leftHandLine.append(noteGroupingL, addSpace=False)
            if self.rightHandLine.textLocation > self.leftHandLine.textLocation:
                self.leftHandLine.textLocation = self.rightHandLine.textLocation
            else:
                self.rightHandLine.textLocation = self.leftHandLine.textLocation
        self.rightHandLine.containsNoteGrouping = True
        self.leftHandLine.containsNoteGrouping = True
Example #2
0
    def addNoteGroupings(self, measureNumber, noteGroupingR, noteGroupingL):
        if self.rightHandLine is None and self.leftHandLine is None:
            self.makeNewLines()
        if self.rightHandLine.textLocation == 0:
            self.rightHandLine.insert(self.highestMeasureNumberLength - len(measureNumber),
                                  measureNumber)
            self.leftHandLine.textLocation = self.rightHandLine.textLocation
        addSpace = True
        if self.rightHandLine.containsNoteGrouping is False:
            addSpace = False
            self.rightHandLine.append(symbols['rh_keyboard'], addSpace=True)
            self.leftHandLine.append(symbols['lh_keyboard'], addSpace=True)
            if noteGroupingR:
                for dot in yieldDots(noteGroupingR[0]):
                    self.rightHandLine.append(dot, addSpace=False)
            if noteGroupingL:
                for dot in yieldDots(noteGroupingL[0]):
                    self.leftHandLine.append(dot, addSpace=False)
        if (self.rightHandLine.canAppend(noteGroupingR, addSpace=addSpace)
                and self.leftHandLine.canAppend(noteGroupingL, addSpace=addSpace)):
            if noteGroupingL:
                self.leftHandLine.append(noteGroupingL, addSpace=addSpace)
            if noteGroupingR:
                self.rightHandLine.append(noteGroupingR, addSpace=addSpace)
            if self.rightHandLine.textLocation > self.leftHandLine.textLocation:
                self.leftHandLine.textLocation = self.rightHandLine.textLocation
            else:
                self.rightHandLine.textLocation = self.leftHandLine.textLocation
        else:
            self.makeNewLines()
            self.rightHandLine.insert(self.highestMeasureNumberLength - len(measureNumber),
                                  measureNumber)
            self.leftHandLine.textLocation = self.rightHandLine.textLocation
            self.rightHandLine.append(symbols['rh_keyboard'], addSpace=True)
            self.leftHandLine.append(symbols['lh_keyboard'], addSpace=True)
            if noteGroupingR:
                for dot in yieldDots(noteGroupingR[0]):
                    self.rightHandLine.append(dot, addSpace=False)
                self.rightHandLine.append(noteGroupingR, addSpace=False)

            if noteGroupingL:
                for dot in yieldDots(noteGroupingL[0]):
                    self.leftHandLine.append(dot, addSpace=False)
                self.leftHandLine.append(noteGroupingL, addSpace=False)
            if self.rightHandLine.textLocation > self.leftHandLine.textLocation:
                self.leftHandLine.textLocation = self.rightHandLine.textLocation
            else:
                self.rightHandLine.textLocation = self.leftHandLine.textLocation
        self.rightHandLine.containsNoteGrouping = True
        self.leftHandLine.containsNoteGrouping = True
Example #3
0
    def optionalAddKeyboardSymbolsAndDots(self, noteGrouping=None):
        '''
        Adds symbols for rh_keyboard or lh_keyboard depending on what
        is appropriate

        returns a boolean indicating whether a space needs to be added
        before the next symbol is needed.
        '''
        addSpace = True
        if (not self.currentLine.containsNoteGrouping
                and (self.rightHandSymbol or self.leftHandSymbol)):
            if self.currentLine.textLocation == 0:
                addSpace = False
            if self.rightHandSymbol:
                self.currentLine.append(symbols['rh_keyboard'], addSpace=addSpace)
            elif self.leftHandSymbol:
                self.currentLine.append(symbols['lh_keyboard'], addSpace=addSpace)
            if noteGrouping:
                for dot in yieldDots(noteGrouping[0]):
                    self.currentLine.append(dot, addSpace=False)
            addSpace = False

        if self.currentLine.textLocation == 0:
            addSpace = False

        return addSpace
Example #4
0
 def addInaccord(self, inaccord):
     addSpace = self.optionalAddKeyboardSymbolsAndDots(inaccord)
     try:
         self.currentLine.append(inaccord, addSpace=addSpace)
     except BrailleTextException:
         self.makeNewLine()
         if self.rightHandSymbol or self.leftHandSymbol:
             if self.rightHandSymbol:
                 self.currentLine.insert(2, symbols['rh_keyboard'])
             elif self.leftHandSymbol:
                 self.currentLine.insert(2, symbols['lh_keyboard'])
             for dot in yieldDots(inaccord[0]):
                 self.currentLine.append(dot, addSpace=False)
             self.currentLine.append(inaccord, addSpace=False)
         else:
             self.currentLine.insert(2, inaccord)
     self.currentLine.containsNoteGrouping = True
Example #5
0
    def optionallyAddDotToPrevious(self, el=None):
        '''
        if el is None or not a Dynamic or TextExpression, add a dot-3 Dot
        before the current transcription
        under certain circumstances:

        1. self.previousElement exists
        2. the last character in the current transcription (self.trans) fits the criteria for
           basic.yieldDots()
        3. one of these three.  PreviousElement was...:
            a. a Dynamic.
            b. a Clef and clef signs are being transcribed
            c. a TextExpression not ending in "."

        Returns True if a dot as added, or False otherwise.
        '''
        prev = self.previousElement
        if prev is None:
            return False
        if not self.trans:
            return False  # need to consult previous element in translation

        if el is not None and isinstance(el, dynamics.Dynamic):
            return False
        if el is not None and isinstance(el, expressions.TextExpression):
            return False

        if (isinstance(prev, dynamics.Dynamic)
                or (isinstance(prev, clef.Clef) and self.showClefSigns)
                or (isinstance(prev, expressions.TextExpression)
                    # TE is an abbreviation, no extra dot 3 necessary
                    and prev.content[-1] != '.')):
            for dot in basic.yieldDots(self.trans[-1][0]):
                self.trans.insert(
                    -1, dot)  # insert one before the end, not append...
                prev.editorial.brailleEnglish.append(f'Dot 3 {dot}')
                return True  # only append max one dot.

        return False
Example #6
0
    def optionallyAddDotToPrevious(self, el=None):
        '''
        if el is None or not a Dynamic or TextExpression, add a dot-3 Dot
        before the current transcription
        under certain circumstances:

        1. self.previousElement exists
        2. the last character in the current transcription (self.trans) fits the criteria for
           basic.yieldDots()
        3. one of these three.  PreviousElement was...:
            a. a Dynamic.
            b. a Clef and clef signs are being transcribed
            c. a TextExpression not ending in "."

        Returns True if a dot as added, or False otherwise.
        '''
        prev = self.previousElement
        if prev is None:
            return False
        if not self.trans:
            return False # need to consult previous element in translation

        if el is not None and 'Dynamic' in el.classes:
            return False
        if el is not None and 'TextExpression' in el.classes:
            return False

        if ('Dynamic' in prev.classes
                or ('Clef' in prev.classes
                        and self.showClefSigns)
                or ('TextExpression' in prev.classes
                    and prev.content[-1] != '.') # TE is an abbreviation, no extra dot 3 necessary
            ):
            for dot in basic.yieldDots(self.trans[-1][0]):
                self.trans.insert(-1, dot) # insert one before the end, not append...
                prev._brailleEnglish.append("Dot 3 {0}".format(dot))
                return True # only append max one dot.

        return False