def addLyricsToBassNote(bassNote, notationString=None): ''' Takes in a bassNote and a corresponding notationString as arguments. Adds the parsed notationString as lyrics to the bassNote, which is useful when displaying the figured bass in external software. >>> from music21.figuredBass import realizer >>> from music21 import note >>> n1 = note.Note('G3') >>> realizer.addLyricsToBassNote(n1, "6,4") >>> n1.lyrics[0].text '6' >>> n1.lyrics[1].text '4' >>> #_DOCS_SHOW n1.show() .. image:: images/figuredBass/fbRealizer_lyrics.* :width: 100 ''' bassNote.lyrics = [] n = notation.Notation(notationString) if len(n.figureStrings) == 0: return maxLength = 0 for fs in n.figureStrings: if len(fs) > maxLength: maxLength = len(fs) for fs in n.figureStrings: spacesInFront = '' for i in range(maxLength - len(fs)): spacesInFront += ' ' bassNote.addLyric(spacesInFront + fs, applyRaw=True)
def getPitchNames(self, bassPitch, notationString=None): ''' Takes a bassPitch and notationString and returns a list of corresponding pitch names based on the scale value and mode above and inclusive of the bassPitch name. >>> from music21.figuredBass import realizerScale >>> fbScale = realizerScale.FiguredBassScale() >>> fbScale.getPitchNames('D3', '6') ['D', 'F', 'B'] >>> fbScale.getPitchNames('G3') ['G', 'B', 'D'] >>> fbScale.getPitchNames('B3', '6,#5') ['B', 'D', 'F#', 'G'] >>> fbScale.getPitchNames('C#3', '-7') # Fully diminished seventh chord ['C#', 'E', 'G', 'B-'] ''' bassPitch = convertToPitch( bassPitch) # Convert string to pitch (if necessary) bassSD = self.realizerScale.getScaleDegreeFromPitch(bassPitch) nt = notation.Notation(notationString) if bassSD is None: bassPitchCopy = copy.deepcopy(bassPitch) bassNote = note.Note(bassPitchCopy) if (self.keySig.accidentalByStep(bassNote.pitch.step) != bassNote.pitch.accidental): bassNote.pitch.accidental = self.keySig.accidentalByStep( bassNote.pitch.step) bassSD = self.realizerScale.getScaleDegreeFromPitch(bassNote.pitch) pitchNames = [] for i in range(len(nt.numbers)): pitchSD = (bassSD + nt.numbers[i] - 1) % 7 samplePitch = self.realizerScale.pitchFromDegree(pitchSD) pitchName = nt.modifiers[i].modifyPitchName(samplePitch.name) pitchNames.append(pitchName) pitchNames.append(bassPitch.name) pitchNames.reverse() return pitchNames