Esempio n. 1
0
 def testInsertMeasure_BadIndex(self):
     self.staff.addMeasure(Measure(1))
     self.staff.addMeasure(Measure(2))
     m = Measure(3)
     self.assertRaises(BadTimeError, self.staff.insertMeasure,
                       NotePosition(measureIndex=-1), m)
     self.assertRaises(BadTimeError, self.staff.insertMeasure,
                       NotePosition(measureIndex=3), m)
Esempio n. 2
0
 def testRepr(self):
     self.assertEqual(repr(NotePosition()),
                      "NotePosition(None, None, None, None)")
     self.assertEqual(repr(NotePosition(0)),
                      "NotePosition(0, None, None, None)")
     self.assertEqual(repr(NotePosition(0, 0)),
                      "NotePosition(0, 0, None, None)")
     self.assertEqual(repr(NotePosition(0, 0, 0, 0)),
                      "NotePosition(0, 0, 0, 0)")
Esempio n. 3
0
 def testDeleteNote_BadTime(self):
     self.assertRaises(
         BadTimeError, self.staff.deleteNote,
         NotePosition(measureIndex=-1, noteTime=0, drumIndex=0))
     self.assertRaises(
         BadTimeError, self.staff.deleteNote,
         NotePosition(measureIndex=20, noteTime=0, drumIndex=0))
     self.assertRaises(
         BadTimeError, self.staff.deleteNote,
         NotePosition(measureIndex=0, noteTime=-1, drumIndex=0))
     self.assertRaises(
         BadTimeError, self.staff.deleteNote,
         NotePosition(measureIndex=0, noteTime=20, drumIndex=0))
Esempio n. 4
0
 def testgetItemAtPosition_BadTime(self):
     self.assertRaises(
         BadTimeError, self.staff.getItemAtPosition,
         NotePosition(measureIndex=-1, noteTime=0, drumIndex=0))
     self.assertRaises(
         BadTimeError, self.staff.getItemAtPosition,
         NotePosition(measureIndex=20, noteTime=0, drumIndex=0))
     self.assertRaises(
         BadTimeError, self.staff.getItemAtPosition,
         NotePosition(measureIndex=0, noteTime=-1, drumIndex=0))
     self.assertRaises(
         BadTimeError, self.staff.getItemAtPosition,
         NotePosition(measureIndex=0, noteTime=20, drumIndex=0))
Esempio n. 5
0
 def setPotentialRepeatNotes(self, notes, head):
     newMeasures = [(np.staffIndex, np.measureIndex) for np in notes]
     notesByMeasures = dict((x, list(y)) for x, y in itertools.groupby(
         notes, lambda np: (np.staffIndex, np.measureIndex)))
     for measure in self._potentials:
         if measure not in notesByMeasures:
             qmeasure = self.getQMeasure(
                 NotePosition(measure[0], measure[1]))
             qmeasure.setPotentials()
     for measure in newMeasures:
         qmeasure = self.getQMeasure(NotePosition(measure[0], measure[1]))
         notes = notesByMeasures[measure]
         qmeasure.setPotentials(notes, head)
     self._potentials = newMeasures
Esempio n. 6
0
 def repeatCount(self, value):
     if value != self._info.repeatCount:
         if self.isRepeatEnd():
             self._info.repeatCount = max(value, 2)
         else:
             self._info.repeatCount = 1
         self._runCallBack(NotePosition())
Esempio n. 7
0
 def testInitAllByName(self):
     np = NotePosition(staffIndex=1, measureIndex=2,
                       noteTime=3, drumIndex=4)
     self.assertEqual(np.staffIndex, 1)
     self.assertEqual(np.measureIndex, 2)
     self.assertEqual(np.noteTime, 3)
     self.assertEqual(np.drumIndex, 4)
Esempio n. 8
0
 def _exportStaff(self, staff, staffIndex):
     kit = self.score.drumKit
     kitSize = len(kit)
     indices = range(0, kitSize)
     indices.reverse()
     position = NotePosition(staffIndex = staffIndex)
     staffString = []
     bpmString = self._getBpmChanges(staff, position)
     if bpmString:
         staffString.append(bpmString)
     repeatString = self._getRepeatString(staff, position)
     if repeatString:
         staffString.append(repeatString)
     stickAbove = self._getSticking(staff, True, position)
     if stickAbove:
         staffString.append(stickAbove)
     for drumIndex in indices:
         drum = kit[drumIndex]
         lineString, lineOk = self._getDrumLine(staff,
                                                drum,
                                                position,
                                                drumIndex)
         if lineOk or drum.locked or not self.settings.omitEmpty:
             staffString.append(lineString)
     if self.settings.printCounts:
         countString = self._getCountLine(staff, position)
         staffString.append(countString)
     stickBelow = self._getSticking(staff, False, position)
     if stickBelow:
         staffString.append(stickBelow)
     return staffString
Esempio n. 9
0
 def __init__(self, qScore, newSize, fontType):
     super(SetFontSizeCommand,
           self).__init__(qScore, NotePosition(),
                          "set " + fontType + " font size")
     self._fontName = fontType + "FontSize"
     self._newSize = newSize
     self._oldSize = getattr(self._qScore.displayProperties, self._fontName)
Esempio n. 10
0
 def _deleteStaffByIndex(self, index):
     self._checkStaffIndex(index)
     staff = self._staffs[index]
     staff.clearCallBack()
     if staff.isSectionEnd():
         if index == 0 or self.getStaffByIndex(index - 1).isSectionEnd():
             position = NotePosition(staffIndex=index)
             sectionIndex = self.positionToSectionIndex(position)
             self._deleteSectionTitle(sectionIndex)
         else:
             prevStaff = self.getStaffByIndex(index - 1)
             position = NotePosition(staffIndex=index - 1,
                                     measureIndex=prevStaff.numMeasures() - 1)
             prevStaff.setSectionEnd(position, True)
     self._staffs.pop(index)
     for offset, nextStaff in enumerate(self._staffs[index:]):
         self._setStaffCallBack(nextStaff, index + offset)
Esempio n. 11
0
 def __init__(self, qScore, positions):
     super(ClearMeasureCommand, self).__init__(qScore, NotePosition(),
                                               "clear measures")
     self._indexes = [
         self._score.measurePositionToIndex(np) for np in positions
     ]
     self._oldMeasures = [
         self._score.copyMeasure(note) for note in positions
     ]