Esempio n. 1
0
 def test_contructor(self):
     Note(MusicalPitch.new_from_notename("c'"),
          Duration.new_from_string("4."))
     self.assertRaises(AssertionError, Note, "4.",
                       MusicalPitch.new_from_notename("c'"))
     self.assertRaises(AssertionError, Note, Duration.new_from_string("4."),
                       "c'")
Esempio n. 2
0
 def test_contructor(self):
     Note(MusicalPitch.new_from_notename("c'"),
          Duration.new_from_string("4."))
     self.assertRaises(AssertionError,
                       Note, "4.", MusicalPitch.new_from_notename("c'"))
     self.assertRaises(AssertionError,
                       Note, Duration.new_from_string("4."), "c'")
Esempio n. 3
0
 def test_bar_fill_skips(self):
     n1 = Note(MusicalPitch.new_from_notename("g'"),
               Duration(4, 0))
     self.score.voice11.append(n1)
     self.score.voice11.append(Rest(Duration.new_from_string("4")))
     self.bp.fill_skips()
     self.assertTrue(isinstance(self.score.voice11.m_tdict[Rat(0, 1)]['elem'][0], Note))
     self.assertTrue(isinstance(self.score.voice11.m_tdict[Rat(1, 4)]['elem'][0], Rest))
     self.assertTrue(isinstance(self.score.voice11.m_tdict[Rat(1, 2)]['elem'][0], Skip))
     self.assertTrue(isinstance(self.score.voice11.m_tdict[Rat(3, 4)]['elem'][0], Skip))
Esempio n. 4
0
 def new_from_string(string):
     s = string.strip()
     m = re_melodic.match(s)
     if m.end() < len(s) - 1:
         # FIXME: raise ValueError like rest
         raise Note.Exception("characters left in string", string)
     return Note(
         MusicalPitch.new_from_notename(
             "%s%s" % (m.group('notename'), m.group('octave'))),
         Duration.new_from_string("%s%s" %
                                  (m.group('len'), m.group('dots'))))
Esempio n. 5
0
 def test_add_partial_bar(self):
     self.score.add_partial_bar(Duration.new_from_string("4"), TimeSignature(4, 4))
     self.score.add_bar(None)
     self.assertEqual(self.score.m_bars[0].m_timepos, Rat(0, 1))
     self.assertEqual(self.score.m_bars[0].end(), Rat(1, 4))
     self.assertEqual(self.score.m_bars[1].m_timepos, Rat(1, 4))
     self.assertEqual(self.score.get_bar_at(Rat(0, 1)), self.score.m_bars[0])
     self.assertEqual(self.score.get_bar_at(Rat(1, 4)), self.score.m_bars[1])
     self.score.voice11.append(Note.new_from_string("c4"))
     self.score.voice11.append(Note.new_from_string("c1"))
     self.score.voice11.append(Note.new_from_string("c1"))
Esempio n. 6
0
 def new_from_string(string):
     s = string.strip()
     m = re_melodic.match(s)
     if m.end() < len(s) - 1:
         # FIXME: raise ValueError like rest
         raise Note.Exception("characters left in string", string)
     return Note(
         MusicalPitch.new_from_notename("%s%s" % (m.group('notename'),
                                                  m.group('octave'))),
         Duration.new_from_string("%s%s" % (m.group('len'), m.group('dots')))
     )
Esempio n. 7
0
 def test_bar_fill_skips(self):
     n1 = Note(MusicalPitch.new_from_notename("g'"), Duration(4, 0))
     self.score.voice11.append(n1)
     self.score.voice11.append(Rest(Duration.new_from_string("4")))
     self.bp.fill_skips()
     self.assertTrue(
         isinstance(self.score.voice11.m_tdict[Rat(0, 1)]['elem'][0], Note))
     self.assertTrue(
         isinstance(self.score.voice11.m_tdict[Rat(1, 4)]['elem'][0], Rest))
     self.assertTrue(
         isinstance(self.score.voice11.m_tdict[Rat(1, 2)]['elem'][0], Skip))
     self.assertTrue(
         isinstance(self.score.voice11.m_tdict[Rat(3, 4)]['elem'][0], Skip))
Esempio n. 8
0
 def test_add_partial_bar(self):
     self.score.add_partial_bar(Duration.new_from_string("4"),
                                TimeSignature(4, 4))
     self.score.add_bar(None)
     self.assertEqual(self.score.m_bars[0].m_timepos, Rat(0, 1))
     self.assertEqual(self.score.m_bars[0].end(), Rat(1, 4))
     self.assertEqual(self.score.m_bars[1].m_timepos, Rat(1, 4))
     self.assertEqual(self.score.get_bar_at(Rat(0, 1)),
                      self.score.m_bars[0])
     self.assertEqual(self.score.get_bar_at(Rat(1, 4)),
                      self.score.m_bars[1])
     self.score.voice11.append(Note.new_from_string("c4"))
     self.score.voice11.append(Note.new_from_string("c1"))
     self.score.voice11.append(Note.new_from_string("c1"))
Esempio n. 9
0
 def test_add_rest(self):
     self.score.voice11.append(Rest(Duration.new_from_string("8")))
     self.assertIsInstance(self.score.voice11.m_tdict[Rat(0, 1)]['elem'][0], Rest)
     self.assertIsInstance(self.score.voice11.m_tdict[Rat(0, 1)]['elem'][0].w_parent(), Voice)
Esempio n. 10
0
 def test_midigen_rest(self):
     self.score.voice11.append(Note.new_from_string("c4"))
     self.score.voice11.append(Rest(Duration.new_from_string("4")))
     self.score.voice11.append(Note.new_from_string("c4"))
     t = mpd.score_to_tracks(self.score)
     self.assertEqual(t[0].str_repr(), "n48 d1/4 o48 d1/4 n48 d1/4 o48")
Esempio n. 11
0
 def new_from_string(string):
     return Skip(Duration.new_from_string(string))
Esempio n. 12
0
 def new_from_string(string):
     return Rest(Duration.new_from_string(string))
Esempio n. 13
0
 def test_new_from_string(self):
     d = Duration.new_from_string("4")
     self.assertEquals(d.get_rat_value(), Rat(1, 4))
     self.assertRaises(Duration.BadStringException,
                       Duration.new_from_string, "44x")
Esempio n. 14
0
 def test_add_rest(self):
     self.score.voice11.append(Rest(Duration.new_from_string("8")))
     self.assertIsInstance(self.score.voice11.m_tdict[Rat(0, 1)]['elem'][0],
                           Rest)
     self.assertIsInstance(
         self.score.voice11.m_tdict[Rat(0, 1)]['elem'][0].w_parent(), Voice)
Esempio n. 15
0
 def new_from_string(string):
     return Rest(Duration.new_from_string(string))
Esempio n. 16
0
 def test_new_from_string(self):
     d = Duration.new_from_string("4")
     self.assertEquals(d.get_rat_value(), Rat(1, 4))
     self.assertRaises(Duration.BadStringException,
         Duration.new_from_string, "44x")
Esempio n. 17
0
 def new_from_string(string):
     return Skip(Duration.new_from_string(string))
Esempio n. 18
0
 def test_midigen_rest(self):
     self.score.voice11.append(Note.new_from_string("c4"))
     self.score.voice11.append(Rest(Duration.new_from_string("4")))
     self.score.voice11.append(Note.new_from_string("c4"))
     t = mpd.score_to_tracks(self.score)
     self.assertEqual(t[0].str_repr(), "n48 d1/4 o48 d1/4 n48 d1/4 o48")