def createScalePart(): c = QuarterNote(); c.step = "C" d = QuarterNote(); d.step = "D" # etc b = QuarterNote(); b.step = "B" s1 = Stream() s1.append([c, d, b]) print(s1.lily) lS1 = LilyString("{" + s1.lily + "}") lS1.showPNG()
def searchForNotes(notesStr): '''the notesStr is a string of notes in the following form: "C4 D4 E4 B3 C4" that's it: name, octave. With no accidentals. If octave is 0 then it means do not bother checking for octaves. Currently octave is ignored anyhow. ''' notesArr = notesStr.split() noteObjArr = [] for tN in notesArr: tNObj = Note() tNObj.name = tN[0] tNObj.octave = int(tN[1]) noteObjArr.append(tNObj) ballataObj = cadencebook.BallataSheet() searcher1 = NoteSearcher(noteObjArr) streamLily = "" for thisWork in ballataObj: for thisCadence in thisWork.snippets: if (thisCadence is None or thisCadence.streams is None): continue for i in range(len(thisCadence.streams)): if searcher1.compareToStream(thisCadence.streams[i]) is True: notesList = "" for thisNote in thisCadence.streams[i].notes: #thisNote.editorial.color = "blue" if hasattr(thisNote.lily, "value"): notesList += thisNote.lily.value + " " streamLily += "\\score {" + \ "<< \\time " + str(thisCadence.timeSig) + \ "\n \\new Staff {" + str(thisCadence.streams[i].lily) + "} >>" + \ thisCadence.header() + "\n}\n" print("In piece %r found in stream %d: %s" % (thisWork.title, i, notesList)) if streamLily: lS = LilyString(streamLily) lS.showPNG()