def testNineEight(self): count = MeasureCount.makeSimpleCount(self.eighths, 4) count.addBeats(Beat.Beat(self.eighths, 1), 1) self.assertEqual(count.timeSig(), (9, 8)) count = MeasureCount.makeSimpleCount(self.sixteenths, 4) count.addBeats(Beat.Beat(self.sixteenths, 2), 1) self.assertEqual(count.timeSig(), (9, 8))
def testFiveFour(self): count = MeasureCount.makeSimpleCount(self.eighths, 5) self.assertEqual(count.timeSig(), (5, 4)) count = MeasureCount.makeSimpleCount(self.triplets, 5) self.assertEqual(count.timeSig(), (5, 4)) count = MeasureCount.makeSimpleCount(self.sixteenths, 5) self.assertEqual(count.timeSig(), (5, 4))
def testSevenFour(self): count = MeasureCount.makeSimpleCount(self.eighths, 7) self.assertEqual(count.timeSig(), (7, 4)) count = MeasureCount.makeSimpleCount(self.triplets, 7) self.assertEqual(count.timeSig(), (7, 4)) count = MeasureCount.makeSimpleCount(self.sixteenths, 7) self.assertEqual(count.timeSig(), (7, 4))
def testSimpleDefaultWrite(self): myCounter = Counter.Counter("e+a") count = MeasureCount.makeSimpleCount(myCounter, 4) handle = StringIO() indenter = fileUtils.Indenter(handle) dbfsv1.DefaultMeasureCountStructureV1().write(count, indenter) output = handle.getvalue().splitlines() self.assertEqual(output, ["START_DEFAULT_MEASURE_COUNT", " BEAT_START", " NUM_TICKS 4", " COUNT |^e+a|", " BEAT_END", " BEAT_START", " NUM_TICKS 4", " COUNT |^e+a|", " BEAT_END", " BEAT_START", " NUM_TICKS 4", " COUNT |^e+a|", " BEAT_END", " BEAT_START", " NUM_TICKS 4", " COUNT |^e+a|", " BEAT_END", "END_DEFAULT_MEASURE_COUNT"])
def testMultiMeasures(self): score = Score() settings = ASCIISettings() settings.omitEmpty = False score.drumKit = DrumKit.DrumKit() score.drumKit.addDrum(Drum.Drum("HiHat", "Hh", "x")) score.drumKit.addDrum(Drum.Drum("Crash", "Cr", "x")) counter = MeasureCount.counterMaker(4, 16) score.insertMeasureByIndex(16, counter = counter) score.insertMeasureByIndex(16, counter = counter) score.insertMeasureByIndex(16, counter = counter) score.addNote(NotePosition(0, 0, 0, 0), "x") score.addNote(NotePosition(0, 1, 0, 0), "y") score.addNote(NotePosition(0, 2, 0, 0), "z") output = self.getOutput(score, settings) self.assertEqual(output, ['Tabbed with DrumBurp, a drum tab editor from www.whatang.org', '', 'Title : ', 'Artist : ', 'BPM : 120', 'Tabbed by : ', 'Date : ' + self.exportDate, '', 'Cr - Crash', 'Hh - HiHat', '', 'Cr|----------------|----------------|----------------|', 'Hh|x---------------|y---------------|z---------------|', ' 1e+a2e+a3e+a4e+a 1e+a2e+a3e+a4e+a 1e+a2e+a3e+a4e+a ', '', 'Tabbed with DrumBurp, a drum tab editor from www.whatang.org'])
def testSimpleWrite(self): myCounter = Counter.Counter("e+a") count = MeasureCount.makeSimpleCount(myCounter, 4) handle = StringIO() indenter = fileUtils.Indenter(handle) dbfsv0.MeasureCountStructureV0().write(count, indenter) output = handle.getvalue().splitlines() self.assertEqual(output, ["COUNT_INFO_START", " REPEAT_BEATS 4", " BEAT_START", " COUNT |^e+a|", " BEAT_END", "COUNT_INFO_END"])
def getSmallestSimpleCount(self): if not self.counter.isSimpleCount(): return None numBeats = self.counter.numBeats() maxLen = len(self) newCount = None for unused_, count in Counter.DEFAULT_REGISTRY: if len(count) * numBeats >= maxLen: continue mcount = MeasureCount.makeSimpleCount(count, numBeats) newMeasure = self.copyMeasure() newMeasure.setBeatCount(mcount) if self.numNotes() == newMeasure.numNotes(): newCount = mcount return newCount
def testSeventeenSixteen(self): count = MeasureCount.makeSimpleCount(self.sixteenths, 4) count.addBeats(Beat.Beat(self.sixteenths, 1), 1) self.assertEqual(count.timeSig(), (17, 16))
def testMake(self): count = MeasureCount.counterMaker(4, 16) self.assert_(isinstance(count, MeasureCount.MeasureCount)) self.assert_(count.isSimpleCount()) self.assertEqual(len(count), 16)
def _makeOldMeasure(self, lineData): self.counter = MeasureCount.counterMaker(int(lineData), len(self))