ELVIS-Project / vis-framework

Thoroughly modern symbolic musical data analysis suite.
http://elvisproject.ca/
31 stars 6 forks source link

Calculate duration based on noterest indexer results. #412

Closed alexandermorgan closed 8 years ago

alexandermorgan commented 8 years ago

It's pretty messy to calculate durations by actually using the .duration attribute of a note, rest, or chord. This is because it's kind of a hassle to find all the notes that are tied together, then add up all their durations and assign this value to the position of the first note in the group. Let's use pandas instead. The code for a single part would look something like this:

ip = IndexedPiece(piecepath) 
part = ip._get_noterest().iloc[:,0].dropna() # get the noterest results of the highest part as a series
indx = part.index.copy()
end_of_part = ip._get_part_streams()[0].highestTime()
indx.append(end_of_part)
part_durations = indx[1:] - indx[:-1]

Just throw that in a little loop for each part and you're set!

crantila commented 8 years ago

I remember we considered this already but ruled it out. Do you remember why? I don't...

alexandermorgan commented 8 years ago

As I was coding this up, I had the same vague recollection of a previous conversation about this. I think it was just that what we had worked, so we didn't want to mess with it. It's a little more problematic in VIS 3 though, so I'm planning on going ahead with this change.

alexandermorgan commented 8 years ago

This has been implemented on alex_devel as of commit f5d0ea1c398f6aacd3a89790099e3b6fbfe503f7.