Esempio n. 1
0
    def test_events1(self):
        m = Mispel()
        model = m.parse(
            "with channel 2 notedriven :\n a3_8. b-_16 c#3_16.5\\vol{100}\\tempo[vivace] "
        )
        for section in model.sections:
            event = section.events[0]
            self.assertEqual(event.cs, None)
            self.assertTrue(event.__class__.__name__, 'NoteSpec')
            self.assertEqual(event.ns.name, 'a')
            self.assertEqual(event.ns.octave, '3')
            self.assertEqual(event.ns.invdur.value, 8)
            self.assertListEqual(event.ns.invdur.dots, ['.'])
            self.assertEqual(event.ns.properties, [])
            event = section.events[1]
            self.assertEqual(event.ns.name, 'b-')
            self.assertEqual(event.ns.octave, None)
            self.assertEqual(event.ns.invdur.value, 16)
            self.assertListEqual(event.ns.invdur.dots, [])
            self.assertEqual(event.ns.properties, [])
            event = section.events[2]
            self.assertEqual(event.ns.name, 'c#')
            self.assertEqual(event.ns.octave, '3')
            self.assertEqual(event.ns.invdur.value, 16.5)
            for p in event.ns.properties:
                if p.avol:
                    self.assertEqual(p.avol.symval, None)
                    self.assertEqual(p.avol.value.value, 100)
                elif p.stempo:
                    self.assertEqual(p.stempo.symval.symval, 'vivace')
                    self.assertEqual(p.stempo.value, None)

        self.assertListEqual(m.notes_for_section(0), ["a3", "b-3", "c#3"])
        self.assertListEqual(m.durations_for_section(0),
                             [1 / 8 + 1 / 16, 1 / 16, 1 / 16.5])
Esempio n. 2
0
 def test_drumnotes(self):
     m = Mispel()
     m.parse(r"""
     with track 0 channel 11:
         bassdrum_4 openhihat_8*2/3 openhihat ohh  
     """)
     notes = m.notes_for_section(0)
     self.assertListEqual(notes,
                          ['bassdrum', 'openhihat', 'openhihat', 'ohh'])
     durs = m.durations_for_section(0)
     self.assertListEqual(durs, [
         0.25, 0.08333333333333333, 0.08333333333333333, 0.08333333333333333
     ])
Esempio n. 3
0
 def test_lagforsection(self):
     m = Mispel()
     m.parse(r"""
     with track 0:
         a2_4 a3 a4_16\lag[0.9] b c5 d e f g a b a g f\lag{1} e d c b\lag{0.3}
     """)
     self.assertListEqual(
         m.notes_for_section(0),
         "a2 a3 a4 b4 c5 d5 e5 f5 g5 a5 b5 a5 g5 f5 e5 d5 c5 b5".split(" "))
     self.assertListEqual(m.lag_for_section(0),
                          [(('num', 'static', 0),
                            ('num', 'static', 0.9), 2),
                           (('num', 'static', 0.9),
                            ('num', 'anim', 1.0), 11),
                           (('num', 'anim', 1.0), ('num', 'anim', 0.3), 4),
                           (('num', 'anim', 0.3), ('num', 'anim', 0.3), 1)])
Esempio n. 4
0
 def test_dynamicsforsection(self):
     m = Mispel()
     m.parse(r"""
     with track 0:
         a3_8\vol[mf] b c4_4 d\vol{ff} e f\vol{30} e f-- r ax d\vol[20] c 
     """)
     self.assertListEqual(m.notes_for_section(0), [
         "a3", "b3", "c4", "d4", "e4", "f4", "e4", "f--4", "r", "ax4", "d4",
         "c4"
     ])
     self.assertListEqual(
         m.dynamics_for_section(0),
         [(('num', 'static', 70), ('sym', 'static', 'mf'), 0),
          (('sym', 'static', 'mf'), ('sym', 'anim', 'ff'), 3),
          (('sym', 'anim', 'ff'), ('num', 'anim', 30), 2),
          (('num', 'anim', 30), ('num', 'static', 20), 5),
          (('num', 'static', 20), ('num', 'static', 20), 2)])