def retrieveSegments(self, fbRules=None, numParts=4, maxPitch=None): ''' generates the segmentList from an fbList, including any overlayed Segments if fbRules is None, creates a new rules.Rules() object if maxPitch is None, uses pitch.Pitch('B5') ''' if fbRules is None: fbRules = rules.Rules() if maxPitch is None: maxPitch = pitch.Pitch('B5') segmentList = [] bassLine = self.generateBassLine() if len(self._overlayedParts) >= 1: self._overlayedParts.append(bassLine) currentMapping = checker.extractHarmonies(self._overlayedParts) else: currentMapping = checker.createOffsetMapping(bassLine) allKeys = sorted(currentMapping.keys()) bassLine = bassLine.flat.notes bassNoteIndex = 0 previousBassNote = bassLine[bassNoteIndex] bassNote = currentMapping[allKeys[0]][-1] previousSegment = segment.OverlayedSegment(bassNote, bassNote.notationString, self._fbScale, fbRules, numParts, maxPitch) previousSegment.quarterLength = previousBassNote.quarterLength segmentList.append(previousSegment) for k in allKeys[1:]: (startTime, unused_endTime) = k bassNote = currentMapping[k][-1] currentSegment = segment.OverlayedSegment(bassNote, bassNote.notationString, self._fbScale, fbRules, numParts, maxPitch) for partNumber in range(1, len(currentMapping[k])): upperPitch = currentMapping[k][partNumber - 1] currentSegment.fbRules._partPitchLimits.append( (partNumber, upperPitch)) if startTime == previousBassNote.offset + previousBassNote.quarterLength: bassNoteIndex += 1 previousBassNote = bassLine[bassNoteIndex] currentSegment.quarterLength = previousBassNote.quarterLength else: for partNumber in range(len(currentMapping[k]), numParts + 1): previousSegment.fbRules._partsToCheck.append(partNumber) # Fictitious, representative only for harmonies preserved # with addition of melody or melodies currentSegment.quarterLength = 0.0 segmentList.append(currentSegment) previousSegment = currentSegment return segmentList
def retrieveSegments(self, fbRules = None, numParts = 4, maxPitch = None): ''' generates the segmentList from an fbList, including any overlayed Segments if fbRules is None, creates a new rules.Rules() object if maxPitch is None, uses pitch.Pitch('B5') ''' if fbRules is None: fbRules = rules.Rules() if maxPitch is None: maxPitch = pitch.Pitch('B5') segmentList = [] bassLine = self.generateBassLine() if len(self._overlayedParts) >= 1: self._overlayedParts.append(bassLine) currentMapping = checker.extractHarmonies(self._overlayedParts) else: currentMapping = checker.createOffsetMapping(bassLine) allKeys = sorted(currentMapping.keys()) bassLine = bassLine.flat.notes bassNoteIndex = 0 previousBassNote = bassLine[bassNoteIndex] bassNote = currentMapping[allKeys[0]][-1] previousSegment = segment.OverlayedSegment(bassNote, bassNote.notationString, self._fbScale, fbRules, numParts, maxPitch) previousSegment.quarterLength = previousBassNote.quarterLength segmentList.append(previousSegment) for k in allKeys[1:]: (startTime, unused_endTime) = k bassNote = currentMapping[k][-1] currentSegment = segment.OverlayedSegment(bassNote, bassNote.notationString, self._fbScale, fbRules, numParts, maxPitch) for partNumber in range(1, len(currentMapping[k])): upperPitch = currentMapping[k][partNumber-1] currentSegment.fbRules._partPitchLimits.append((partNumber, upperPitch)) if startTime == previousBassNote.offset + previousBassNote.quarterLength: bassNoteIndex+=1 previousBassNote = bassLine[bassNoteIndex] currentSegment.quarterLength = previousBassNote.quarterLength else: for partNumber in range(len(currentMapping[k]), numParts+1): previousSegment.fbRules._partsToCheck.append(partNumber) # Fictitious, representative only for harmonies preserved # with addition of melody or melodies currentSegment.quarterLength = 0.0 segmentList.append(currentSegment) previousSegment = currentSegment return segmentList