def _create_clef(self, element): cl = int(element.attribute_by_name("clef.line").value) cs = element.attribute_by_name("clef.shape").value octavechg = 0 if element.has_attribute("clef.dis"): cd = element.attribute_by_name("clef.dis").value if cd == "8": octavechg = 1 if element.has_attribute("clef.dis.place"): cdp = element.attribute_by_name("clef.dis.place").value if cdp == "below": octavechg = -(octavechg) return clef.standardClefFromXN("{0}{1}".format(cs, cl))
def _create_staffdef(self, element): staffnum = element.attribute_by_name('n').value if staffnum not in self._staff_registry.keys(): lg.debug("Creating staffdef from {0}".format(element.id)) self._staff_registry[staffnum] = stream.Part() # we put "staff" and "staffdef" construction in the same place, # since we want to be able to create a staff on the fly, without a # staffdef. However, many things are only set in the staffdef # element. If we don't have a staffdef, we can safely leave at this point. if not element.name == "staffdef": return # clef, key sig, and time sig all have a tuple stored for each staff. # the tuple is (<m21_obj>, bool), where bool is the value of whether or # not this object is new and should be put in a measure. # clef lg.debug("Creating clef.") if element.has_attribute('clef.line'): cl = int(element.attribute_by_name('clef.line').value) else: cl = 2 # we'll construct a treble clef by default if element.has_attribute('clef.shape'): cs = element.attribute_by_name('clef.shape').value else: cs = "G" octavechg = 0 if element.has_attribute('clef.dis'): cd = element.attribute_by_name('clef.dis').value if cd == '8': octavechg = 1 if element.has_attribute('clef.dis.place'): cdp = element.attribute_by_name('clef.dis.place').value if cdp == 'below': octavechg = -(octavechg) m_clef = clef.standardClefFromXN("{0}{1}".format(cs, cl)) pdb.set_trace() self._clef_registry[staffnum] = [m_clef, True] # keysig lg.debug("Creating keysig") if element.has_attribute('key.sig'): ks = element.attribute_by_name('key.sig').value else: ks = self._ks m_ks = key.KeySignature(self._keysig_converter(ks)) self._key_sig_registry[staffnum] = [m_ks, True] # time sig lg.debug("Creating timesig") m_ts = meter.TimeSignature() if element.has_attribute('meter.count'): mc = element.attribute_by_name('meter.count').value else: mc = self._mc if element.has_attribute('meter.unit'): mu = element.attribute_by_name('meter.unit').value else: mu = self._mu m_ts.load("{0}/{1}".format(mc, mu)) self._time_sig_registry[staffnum] = [m_ts, True]