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())
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)
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())
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())
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)
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.")
def get_output(self): handle = StringIO() indenter = fileUtils.Indenter(handle) dbfsv0.MeasureStructureV0().write(self.measure, indenter) return handle.getvalue().splitlines()