Пример #1
0
 def initializePartStaves(self, scoreData: ScoreData):
     self.parts = []
     for partData in scoreData.parts:
         newPart: GridPart = GridPart()
         self.parts.append(newPart)
         for _staffData in partData.staves:
             newStaff: GridStaff = GridStaff()
             newPart.staves.append(newStaff)
Пример #2
0
 def initializeBySlice(self, oldSlice):
     self.parts = []
     for oldPart in oldSlice.parts:
         newPart = GridPart()
         self.parts.append(newPart)
         for oldStaff in oldPart.staves:
             newStaff = GridStaff()
             newPart.staves.append(newStaff)
             for _oldVoice in oldStaff.voices:
                 newVoice = GridVoice()
                 newStaff.voices.append(newVoice)
Пример #3
0
    def initializeByStaffCount(self, staffCount: int):
        self.parts = []
        for _ in range(0, staffCount):
            newPart: GridPart = GridPart()
            self.parts.append(newPart)

            newStaff: GridStaff = GridStaff()
            newPart.staves.append(newStaff)

            newVoice: GridVoice = GridVoice()
            newStaff.voices.append(newVoice)
Пример #4
0
    def __init__(self,
                 ownerMeasure,
                 timestamp: HumNum,
                 sliceType: SliceType,
                 partCount: int = 0,
                 fromSlice=None):
        from converter21.humdrum import GridMeasure
        from converter21.humdrum import HumGrid
        ownerMeasure: GridMeasure
        self._timestamp: HumNum = timestamp
        self._type: SliceType = sliceType
        self._ownerGrid: HumGrid = None
        self._measure: GridMeasure = None  # enclosing measure
        if ownerMeasure:
            self._ownerGrid = ownerMeasure.ownerGrid  # measure's enclosing grid
            self._measure = ownerMeasure

        self.parts: [GridPart] = []
        if fromSlice is None:
            # GridSlice::GridSlice -- Constructor.  If partcount is positive, then
            #    allocate the desired number of parts (still have to allocate staves
            #    in part before using).
            for _ in range(0, partCount):
                part: GridPart = GridPart()
                staff: GridStaff = GridStaff()
                voice: GridVoice = GridVoice()
                self.parts.append(part)
                part.staves.append(staff)
                staff.voices.append(voice)
        else:
            # This constructor allocates the matching part and staff count of the
            # input fromSlice parameter.  There will be no GridVoices allocated inside
            # the GridStaffs (they will be required to have at least one).
            for fromPart in fromSlice.parts:
                part = GridPart()
                self.parts.append(part)
                for _ in fromPart.staves:
                    staff = GridStaff()
                    part.staves.append(staff)