Пример #1
0
 def testReadLineBreak(self):
     data = """
     START_BAR 15
       COUNT_INFO_START
         BEAT_START
           COUNT |^+a|
         BEAT_END
         BEAT_START
           COUNT |^+a|
         BEAT_END
         BEAT_START
           COUNT |^ea+ea|
         BEAT_END
         BEAT_START
           COUNT |^+a|
         BEAT_END
       COUNT_INFO_END
       BARLINE NORMAL_BAR,NO_BAR
       BARLINE NORMAL_BAR,LINE_BREAK,NO_BAR
     END_BAR
     """
     handle = StringIO(data)
     iterator = fileUtils.dbFileIterator(handle)
     measure = dbfsv0.MeasureStructureV0().read(iterator)
     self.assert_(measure.isLineBreak())
Пример #2
0
 def testReadMeasure(self):
     data = """START_BAR 12
               COUNT_INFO_START
                 REPEAT_BEATS 4
                 BEAT_START
                   COUNT |^+|
                 BEAT_END
               COUNT_INFO_END
               BARLINE NORMAL_BAR,NO_BAR
               NOTE 0,1,o
               NOTE 0,2,o
               NOTE 1,2,o
               NOTE 2,2,o
               NOTE 2,3,o
               NOTE 3,2,o
               NOTE 3,3,o
               NOTE 4,1,o
               NOTE 4,2,o
               NOTE 5,2,o
               NOTE 6,2,o
               NOTE 6,3,o
               NOTE 7,2,x
               BARLINE NORMAL_BAR,NO_BAR
             END_BAR"""
     handle = StringIO(data)
     iterator = fileUtils.dbFileIterator(handle)
     measure = dbfsv0.MeasureStructureV0().read(iterator)
     self.assertEqual(len(measure), 8)
     self.assertEqual(measure.numNotes(), 13)
     self.assertEqual(measure.noteAt(0, 1), "o")
     self.assertEqual(measure.noteAt(0, 2), "o")
     self.assertEqual(measure.noteAt(1, 2), "o")
     self.assertEqual(measure.noteAt(2, 2), "o")
     self.assertEqual(measure.noteAt(2, 3), "o")
     self.assertEqual(measure.noteAt(3, 2), "o")
     self.assertEqual(measure.noteAt(3, 3), "o")
     self.assertEqual(measure.noteAt(4, 1), "o")
     self.assertEqual(measure.noteAt(4, 2), "o")
     self.assertEqual(measure.noteAt(5, 2), "o")
     self.assertEqual(measure.noteAt(6, 2), "o")
     self.assertEqual(measure.noteAt(6, 3), "o")
     self.assertEqual(measure.noteAt(7, 2), "x")
     self.assertFalse(measure.isRepeatStart())
     self.assertFalse(measure.isRepeatEnd())
     self.assertFalse(measure.isSectionEnd())
     self.assertFalse(measure.isLineBreak())
     self.assertEqual(measure.alternateText, None)
     self.assertEqual(measure.repeatCount, 1)
Пример #3
0
 def testReadSectionEnd(self):
     data = """
     START_BAR 8
       COUNT_INFO_START
         REPEAT_BEATS 4
         BEAT_START
           COUNT |^+|
         BEAT_END
       COUNT_INFO_END
       BARLINE NORMAL_BAR,NO_BAR
       BARLINE NORMAL_BAR,NO_BAR,SECTION_END
     END_BAR
     """
     handle = StringIO(data)
     iterator = fileUtils.dbFileIterator(handle)
     measure = dbfsv0.MeasureStructureV0().read(iterator)
     self.assert_(measure.isSectionEnd())
Пример #4
0
 def testReadRepeatBar(self):
     data = """START_BAR 8
                 COUNT_INFO_START
                   REPEAT_BEATS 4
                   BEAT_START
                     COUNT |^+|
                   BEAT_END
                 COUNT_INFO_END
                 BARLINE NORMAL_BAR,REPEAT_START,NO_BAR
                 BARLINE NORMAL_BAR,NO_BAR,REPEAT_END
                 REPEAT_COUNT 6
               END_BAR"""
     handle = StringIO(data)
     iterator = fileUtils.dbFileIterator(handle)
     measure = dbfsv0.MeasureStructureV0().read(iterator)
     self.assertEqual(measure.repeatCount, 6)
     self.assert_(measure.isRepeatStart())
     self.assert_(measure.isRepeatEnd())
Пример #5
0
 def testReadSimile(self):
     data = """
     START_BAR 8
       COUNT_INFO_START
         REPEAT_BEATS 4
         BEAT_START
           COUNT |^+|
         BEAT_END
       COUNT_INFO_END
       BARLINE NORMAL_BAR,NO_BAR
       BARLINE NORMAL_BAR,NO_BAR
       SIMILE 2
       SIMINDEX 1
     END_BAR
     """
     handle = StringIO(data)
     iterator = fileUtils.dbFileIterator(handle)
     measure = dbfsv0.MeasureStructureV0().read(iterator)
     self.assertEqual(measure.simileDistance, 2)
     self.assertEqual(measure.simileIndex, 1)
Пример #6
0
 def testReadAlternate(self):
     data = """
     START_BAR 8
       COUNT_INFO_START
         REPEAT_BEATS 4
         BEAT_START
           COUNT |^+|
         BEAT_END
       COUNT_INFO_END
       BARLINE NORMAL_BAR,NO_BAR
       BARLINE NORMAL_BAR,NO_BAR,SECTION_END,REPEAT_END
       REPEAT_COUNT 2
       ALTERNATE 2.
     END_BAR
     """
     handle = StringIO(data)
     iterator = fileUtils.dbFileIterator(handle)
     measure = dbfsv0.MeasureStructureV0().read(iterator)
     self.assert_(measure.isRepeatEnd())
     self.assertEqual(measure.alternateText, "2.")
Пример #7
0
 def get_output(self):
     handle = StringIO()
     indenter = fileUtils.Indenter(handle)
     dbfsv0.MeasureStructureV0().write(self.measure, indenter)
     return handle.getvalue().splitlines()