Skip to main content

Module primitives

Module primitives 

Source
Expand description

The values a score’s metadata is made of: music21’s metadata.primitives.

A metadata value is not only a string. A title has a language and may be a translation; a contributor has a role; and a date may be approximate, uncertain, a date before or after which something happened, a span between two dates, or a choice among several. These are the types that say so.

A date is music21’s own, not a calendar date. Any part of it may be missing – a year alone, or a year and a month – and any part may be marked approximate or uncertain, which is why music21 wrote a type of its own rather than using Python’s datetime. A date in the distant past is as good as a recent one; what is not modelled is a date before the common era, which music21 does not model either, nor milliseconds, which it drops on purpose (“this is a tool for musicology and not for file timestamps”).

Structs§

Contributor
Somebody who had a hand in a work: music21’s metadata.Contributor. A composer, a lyricist, an arranger, or anybody else, under one or more names.
Date
A date as music21 keeps one: music21’s metadata.Date. Any part may be missing, and any part may say how sure it is.
DatePrimitive
One or more dates and what they say: music21’s DatePrimitive and the four classes under it, which differ only in the relevances they take and in how they are written.
Text
One piece of text a score says about itself: music21’s metadata.Text. It keeps the language it is written in, whether it is a translation, and the scheme it was encoded by.

Enums§

Certainty
How sure one part of a Date is: music21’s error strings, written as the symbols it writes them with.
DateKind
Which of music21’s four date classes a DatePrimitive is.
DatePart
One part of a Date, in the order music21 writes them.
Relevance
What a DatePrimitive says about the dates it holds: music21’s relevance, which is what tells its four date classes apart.

Constants§

ROLE_ABBREVIATIONS
The ten roles Humdrum writes an abbreviation for: music21’s Contributor.roleAbbreviationsDict.

Functions§

strip_certainty
A written number with its certainty taken off it: music21’s Date._stripError. Only one symbol is expected, and the first one met is the one read. A fraction is read as the whole number before the point – music21 drops milliseconds on purpose.