ELVIS-Project / vis-framework

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

indexed_piece not working? #371

Closed minamouse closed 8 years ago

minamouse commented 8 years ago

@crantila in indexed_piece.py, it seems that _import_score(), which assigns values to the metadata fields doesn't get called. That is, when I do this, I get nothing back:

score = IndexedPiece('Ock1005a-Missa_De_plus_en_plus-Kyrie.mei')
print(score.metadata('parts'))

but this works:

score = IndexedPiece('Ock1005a-Missa_De_plus_en_plus-Kyrie.mei')
test = score._import_score()
print(score.metadata('parts'))

Is there a reason for this, or something I'm missing?

crantila commented 8 years ago

_import_score() is called from run() when required, and not called from __init__(). This is intentional lazy loading to help reduce peak memory consumption of music21 Score objects. In summer 2013, 16 GB of RAM wasn't enough for even 20 average Score objects at once. This is much better now, but I still defend the lazy loading strategy here.

Many other things could use improvement though! You could make _import_score() into a public method, add an autoload kwarg to __init__() that calls import_score() immediately, and/or other things.

(If you start wondering about the init_metadata() inner function in __init__(): there's no good reason for it).

alexandermorgan commented 8 years ago

Perhaps @mborsodi you could have any changes you think would be useful ready for the hack day and the three of us could look over them all together. This issue also interests me because I recently found out that the length of a pick-up is stored in the metadata. This could be useful to make the offset filter start on the first downbeat or other reasonable starting point rather than just the first note of the piece as it does now (these offset filter comments are related to #173 and #356).

minamouse commented 8 years ago

I don't think we need to change anything here.

minamouse commented 8 years ago

So, I realized that the reason it wasn't working is because there was no run() function in _indexed_piece(). I added it and called import score from there.