Previous topic

music21.dynamics

Next topic

music21.environment

Table Of Contents

Table Of Contents

This Page

music21.editorial

Editorial objects store comments and other meta-data associated with specific Note objects or other music21 objects.

Functions

music21.editorial.getObjectsWithEditorial(listToSearch, editorialStringToFind, listOfValues=None)

Provided a list of objects (typically note objects) to search through, this method returns only those objects that have the editorial attribute defined by the editorialStringToFind. An optional parameter, listOfValues, is a list of all the possible values the given object’s editorialString can have.

The editorialStringToFind can be any of the pre-defined editorial attributes (such as “ficta” or “harmonicIntervals”) but it may also be the dictionary key of editorial notes stored in the miscellaneous (misc) dictionary. For example, “isPassingTone” or “isNeighborTone”

>>> n1 = note.Note()
>>> n1.editorial.misc['isPassingTone'] = True
>>> n2 = note.Note()
>>> n2.editorial.comment = 'consider revising'
>>> s = stream.Stream()
>>> s.repeatAppend(n1, 5)
>>> s.repeatAppend(note.Note(), 2)
>>> s.repeatAppend(n2, 3)
>>> listofNotes = s.getElementsByClass(note.Note)
>>> listOfValues = ['consider revising', 'remove']
>>> listofNotesWithEditorialisPassingTone = editorial.getObjectsWithEditorial(
...     listofNotes, "isPassingTone")
>>> listofNotesWithEditorialComment = editorial.getObjectsWithEditorial(
...     listofNotes, "comment", listOfValues)
>>> print(len(listofNotesWithEditorialisPassingTone))
5
>>> print(len(listofNotesWithEditorialComment))
3

NoteEditorial

class music21.editorial.NoteEditorial

Editorial comments and special effects that can be applied to notes Standard ones are stored as attributes. Non-standard/one-off effects are stored in the dict called “misc”:

>>> a = editorial.NoteEditorial()
>>> a.color = "blue"  # a standard editorial effect
>>> a.misc['backgroundHighlight'] = 'yellow'  # non-standard.

Every GeneralNote object already has a NoteEditorial object attached to it at object.editorial. Normally you will just change that object instead.

For instance, take the case where a scribe wrote F in the score, knowing that a good singer would automatically sing F-sharp instead. We can store the editorial suggestion to sing F-sharp as a “musica ficta” accidental object:

>>> fictaSharp = pitch.Accidental("Sharp")
>>> n = note.Note("F")
>>> n.editorial.ficta = fictaSharp
>>> n.show('lily.png')  # only Lilypond currently supports musica ficta
../_images/noteEditorialFictaSharp.png

NoteEditorial bases

NoteEditorial methods

NoteEditorial.colorLilyStart()

Returns color “theColorName” – called out so it is more easily subclassed.

NoteEditorial.fictaLilyStart()

Returns ficta – called out so it is more easily subclassed

NoteEditorial.lilyAttached()

Returns any information that should be attached under the note, currently just returns self.comment.lily or “”.

NoteEditorial.lilyEnd()

Returns a string of editorial lily instructions to come after the note. Currently it is just info to turn off hidding of notes.

NoteEditorial.lilyStart()

A method that returns a string containing the lilypond output that comes before the note.

>>> n = note.Note()
>>> n.editorial.lilyStart()
u''
>>> n.editorial.ficta = pitch.Accidental("Sharp")
>>> n.editorial.color = "blue"
>>> n.editorial.hidden = True
>>> print(n.editorial.lilyStart())
\ficta \color "blue" \hideNotes

NoteEditorial instance variables

NoteEditorial.color

the color of the note (x11 colors and extended x11colors are allowed), only displays properly in lilypond

NoteEditorial.comment

a reference to a Comment object

NoteEditorial.ficta

a Accidental object that specifies musica ficta for the note. Will only be displayed in LilyPond and then only if there is no Accidental object on the note itself

NoteEditorial.harmonicInterval

an Interval object that specifies the harmonic interval between this note and a single other note (useful for storing information post analysis

NoteEditorial.harmonicIntervals

a list for when you want to store more than one harmonicInterval

NoteEditorial.hidden

boolean value about whether to hide the note or not (only works in lilypond)

NoteEditorial.melodicInterval

an Interval object that specifies the melodic interval to the next note in this part/voice/stream, etc.

NoteEditorial.melodicIntervalOverRests

same as melodicInterval but ignoring rests; MIGHT BE REMOVED SOON

NoteEditorial.melodicIntervals

a list for storing more than one melodic interval

NoteEditorial.melodicIntervalsOverRests

same thing but a list

NoteEditorial.misc

A dict to hold anything you might like to store.

Comment

class music21.editorial.Comment

An object that adds text above or below a note:

>>> n = note.Note()
>>> n.editorial.comment.text = "hello"
>>> n.editorial.comment.position = "above"
>>> n.editorial.comment.lily
u'^"hello"'

Comment bases

Comment read-only properties

Comment.lily