cuthbertLab / music21

music21 is a Toolkit for Computational Musicology
https://www.music21.org/
Other
2.09k stars 397 forks source link

Adding artist in stream metadatas #676

Open louisbigo opened 3 years ago

louisbigo commented 3 years ago

Stream metadatas include the field Metadata.composer, which is very relevant for corpus analysis of classical music. But when it comes to analysis of popular music, it might sometime be more relevant to group songs by their performing artist (like a singer or a band) rather than the actual composer of the songs. Is there any metadata in streams intended to store artist information ?

jacobtylerwalls commented 3 years ago

You can store arbitrary contributor roles:

http://web.mit.edu/music21/doc/moduleReference/moduleMetadata.html?highlight=addcontributor#music21.metadata.Metadata.addContributor

The .composer property is just a convenience property for setting a composer or getting the first (of however many) composer(s).

louisbigo commented 3 years ago

Thanks for the answer. It works well and I can now specify my artistfield by writing the following :

c = metadata.Contributor()
c.name='David Bowie'
c.role='artist'
s.metadata.addContributor(c)

and access it with

s.metadata.getContributorsByRole('artist')[0].name

It woud be great to be able to avoid the list syntax (ie specifying that there can only be one single 'artist' and therefore accessing it with something like s.metadata.artist) but I understand that this is not how contributors work.

mscuthbert commented 3 years ago

I think that the notion that there is one and only one composer (also incorrect) is more common than saying that there is only one artist. I don't know of any a cappella Bowie. I think if anything we're more likely to make everything a list rather than making artist a single entity.

But maybe in the future, we can have '.getContributorByRole' as well as 'getContributorsByRole' (plural) and have the first return just the first entry and the latter return a list?

louisbigo commented 3 years ago

Thanks for the answer. I get your point and I agree that there are rarely only one single artist properly speaking. I was here thinking about corpus referencing commodity rather than precise metadata, which again makes sense in my case because I'm dealing with popular music corpora (more precisely pop/rock), in which it is usual to identify a song with the couple [artist+title].

I would certainly use the '.getContributorByRole' feature (returning first item) if it was available, but I would understand that it could make things confusing if some people use it instead of '.getContributorsByRole', therefore missing secondary roles stored in metadatas. I'll prefer to let you the decision, I'll be fine anyway :)