Hello, I was hoping that someone could explain how I might go about recording measure number as I parse through a piece. To briefly explain what I'm doing, I'm grabbing each part and parsing through each element in the part.recurse(), as shown below:
for part in score:
for element in part.recurse():
record pitch, offset, etc.
I then add all of that to a dataframe, where each element is an entry in the database. What I've not been able to figure out is how to get the measure while I'm parsing through. I've thought about figuring it out with math, but that would depend on the entire piece being in the same time signature, and it must be in music21's model of the part somewhere I'm thinking, so do you guys have any suggestions?
Thank you in advance!
Best,
Taylor