def generateLinkedTieStartsAndEnds(self, linkedTieStarts: [tuple], linkedTieEnds: [tuple], linkSignifier: str) -> bool: # Use this in the future to limit to grand-staff search (or 3 staves for organ): # vector<vector<HTp> > tracktokens; # this->getTrackSeq(tracktokens, spinestart, OPT_DATA | OPT_NOEMPTY); # Only analyzing linked ties for now (others ties are handled without analysis in # HumdrumFile.createMusic21Stream, for example). if linkSignifier is None or linkSignifier == '': return True lstart: str = linkSignifier + '[' lmiddle: str = linkSignifier + '_' lend: str = linkSignifier + ']' startDatabase: [tuple] = [(None,-1)] * 400 for line in self._lines: if not line.isData: continue for tok in line.tokens(): if not tok.isKern: continue if not tok.isData: continue if tok.isNull: continue if tok.isRest: continue for subtokenIdx, subtokenStr in enumerate(tok.subtokens): if lstart in subtokenStr: b40: int = Convert.kernToBase40(subtokenStr) startDatabase[b40] = (tok, subtokenIdx) if lend in subtokenStr: b40: int = Convert.kernToBase40(subtokenStr) if startDatabase[b40][0] is not None: linkedTieStarts.append(startDatabase[b40]) linkedTieEnds.append( (tok, subtokenIdx) ) startDatabase[b40] = (None, -1) if lmiddle in subtokenStr: b40: int = Convert.kernToBase40(subtokenStr) if startDatabase[b40][0] is not None: linkedTieStarts.append(startDatabase[b40]) linkedTieEnds.append( (tok, subtokenIdx) ) startDatabase[b40] = (tok, subtokenIdx) return True
def generateLinkedTieStartsAndEnds(self, linkedTieStarts: t.List[t.Tuple[ HumdrumToken, int]], linkedTieEnds: t.List[t.Tuple[HumdrumToken, int]], linkSignifier: str) -> bool: # Use this in the future to limit to grand-staff search (or 3 staves for organ): # vector<vector<HTp> > tracktokens; # this->getTrackSeq(tracktokens, spinestart, OPT_DATA | OPT_NOEMPTY); # Only analyzing linked ties for now (others ties are handled without analysis in # HumdrumFile.createMusic21Stream, for example). if linkSignifier is None or linkSignifier == '': return True lstart: str = linkSignifier + '[' lmiddle: str = linkSignifier + '_' lend: str = linkSignifier + ']' startDatabase: t.List[t.Tuple[t.Optional[HumdrumToken], int]] = [(None, -1)] * 400 for line in self._lines: if not line.isData: continue for tok in line.tokens(): if not tok.isKern: continue if not tok.isData: continue if tok.isNull: continue if tok.isRest: continue for subtokenIdx, subtokenStr in enumerate(tok.subtokens): if lstart in subtokenStr: startb40: int = Convert.kernToBase40(subtokenStr) startDatabase[startb40] = (tok, subtokenIdx) if lend in subtokenStr: endb40: int = Convert.kernToBase40(subtokenStr) endEntry: t.Tuple[t.Optional[HumdrumToken], int] = startDatabase[endb40] if endEntry[0] is not None: if t.TYPE_CHECKING: assert isinstance(endEntry[0], HumdrumToken) linkedTieStarts.append((endEntry[0], endEntry[1])) linkedTieEnds.append((tok, subtokenIdx)) startDatabase[endb40] = (None, -1) if lmiddle in subtokenStr: middleb40: int = Convert.kernToBase40(subtokenStr) middleEntry: t.Tuple[t.Optional[HumdrumToken], int] = (startDatabase[middleb40]) if middleEntry[0] is not None: if t.TYPE_CHECKING: assert isinstance(middleEntry[0], HumdrumToken) linkedTieStarts.append( (middleEntry[0], middleEntry[1])) linkedTieEnds.append((tok, subtokenIdx)) startDatabase[middleb40] = (tok, subtokenIdx) return True