Esempio n. 1
0
    def setUp(self):
        self.score = Score()
        self.score.version = '3.0'
        part_list = self.score.add_child(PartList())
        score_part = part_list.add_child(ScorePart(id='P1'))
        score_part.add_child(PartName(name="Oboe"))
        score_part.add_child(PartAbbreviation("Ob."))

        measure = self.score.add_child(Measure(number='1'))
        part = measure.add_child(Part(id='P1'))
        attributes = part.add_child(Attributes())
        attributes.add_child(Divisions(2))
        time = attributes.add_child(Time())
        time.add_child(Beats(4))
        time.add_child(BeatType(4))
        clef = attributes.add_child(Clef())
        clef.add_child(Sign('G'))
        clef.add_child(Line(2))
        note = part.add_child(Note())
        note.add_child(Rest(measure='yes'))
        note.add_child(Duration(8))

        measure = self.score.add_child(Measure(number='2'))
        part = measure.add_child(Part(id='P1'))
        attributes = part.add_child(Attributes())
        attributes.add_child(Divisions(2))
        note = part.add_child(Note())
        note.add_child(Rest(measure='yes'))
        note.add_child(Duration(8))
Esempio n. 2
0
class TestRest(TestCase):
    def setUp(self):
        self.rest = Rest()

    def test_rest(self):
        result = '''<rest/>
'''

        self.assertEqual(self.rest.to_string(), result)

    def test_rest_2(self):
        self.rest.add_child(DisplayStep('C'))
        self.rest.add_child(DisplayOctave(4))
        result = '''<rest>
  <display-step>C</display-step>
  <display-octave>4</display-octave>
</rest>
'''
        self.assertEqual(self.rest.to_string(), result)

    def test_rest_3(self):
        self.rest.add_child(DisplayStep('C'))
        self.rest.display_step.value = 'D'
        self.rest.add_child(DisplayOctave(7))
        result = '''<rest>
  <display-step>D</display-step>
  <display-octave>7</display-octave>
</rest>
'''
        self.assertEqual(self.rest.to_string(), result)
Esempio n. 3
0
    def test_1(self):
        part = Part(id='P1')
        attributes = part.add_child(Attributes())
        attributes.add_child(Divisions(2))
        d = part.add_child(Direction())
        dt = d.add_child(DirectionType())
        dt.add_child(Words(value='bla'))
        note = part.add_child(Note())
        note.add_child(Rest())
        note.add_child(Duration(8))

        result = '''<part id="P1">
  <attributes>
    <divisions>2</divisions>
  </attributes>
  <direction>
    <direction-type>
      <words>bla</words>
    </direction-type>
  </direction>
  <note>
    <rest/>
    <duration>8</duration>
  </note>
</part>
'''
        self.assertEqual(part.to_string(), result)
Esempio n. 4
0
    def test_add_chord(self):

        ch = self.note.add_child(Chord())
        self.note.add_child(Pitch())
        self.note.add_child(Grace())
        with self.assertRaises(Exception):
            ch.add_child(Rest())
Esempio n. 5
0
 def setUp(self):
     self.note = Note()
     # self.dtd = note_dtd.__deepcopy__()
     self.note.add_xml_child(Instrument())
     self.note.add_xml_child(Rest())
     self.note.add_xml_child(Duration())
     self.note.add_xml_child(Type('quarter'))
Esempio n. 6
0
    def test_add_note(self):
        note = Note()
        note.add_child(Rest())
        note.add_child(Duration(2))
        self.part.add_child(note)

        note = Note()
        note.add_child(Rest())
        note.add_child(Duration(2))
        result = '''<part id="p1">
  <attributes>
    <divisions>1</divisions>
  </attributes>
  <note>
    <rest/>
    <duration>2</duration>
  </note>
</part>
'''
        self.assertEqual(self.part.to_string(), result)
Esempio n. 7
0
 def test_close_1(self):
     self.note.add_child(Rest())
     self.note.add_child(Grace())
     self.note.close_dtd()
     result = [
         'Grace', 'Chord', 'Rest', 'Instrument', 'FootNote', 'Level',
         'Voice', 'Type', 'Dot', 'Accidental', 'TimeModification', 'Stem',
         'Notehead', 'NoteheadText', 'StaffElement', 'Beam', 'Notations',
         'Lyric', 'Play'
     ]
     self.assertEqual([
         node.type_.__name__
         for node in self.note.current_dtd_choice.traverse_leaves()
     ], result)
Esempio n. 8
0
    def __init__(self,
                 parent_chord,
                 event=Rest(),
                 is_tied=False,
                 *args,
                 **kwargs):
        super().__init__(*args, **kwargs)
        self._parent_chord = None
        self._accidental = TreeAccidental(show=False, value='natural')
        self._accidental._note = self
        self._event = None
        self.event = event
        self._offset = None
        self._is_tied = False

        self.parent_chord = parent_chord
        self.is_tied = is_tied
        self.is_finger_tremolo = False
Esempio n. 9
0
 def test_close_2(self):
     self.note.add_child(Rest())
     with self.assertRaises(ChildIsNotOptional):
         self.note.close_dtd()
Esempio n. 10
0
 def test_rest(self):
     rest = self.note.add_child(Rest())
     self.note.add_child(Duration(1))
Esempio n. 11
0
 def setUp(self):
     self.rest = Rest()
Esempio n. 12
0
 def get_pitch_rest(self):
     if self.value == 0:
         return Rest()
     else:
         return Pitch(*self.get_pitch_name())