Classes and functions for creating and manipulating notes, ties, and durations. The Pitch object is stored within, and used to configure, Note objects.
Inherits from: NotRest, GeneralNote, Music21Object
Note class for notes (not rests or unpitched elements) that can be represented by one or more notational units A Note knows both its total duration and how to express itself as a set of tied notes of different lengths. For instance, a note of 2.5 quarters in length could be half tied to eighth or dotted quarter tied to quarter. A ComplexNote will eventually be smart enough that if given a duration in quarters it will try to figure out a way to express itself as best it can if it needs to be represented on page. It does not know this now.
Note attributes
- isNote¶
- Boolean read-only value describing if this object is a Note.
- isRest¶
- Boolean read-only value describing if this is a Rest.
- isUnpitched¶
- Boolean read-only value describing if this is Unpitched.
- beams¶
- A Beams object.
Attributes inherited from NotRest: stemDirection
Attributes inherited from GeneralNote: isChord, lyrics, notations, editorial, tie, articulations
Attributes inherited from Music21Object: classSortOrder, id, groups
Note properties
- nameWithOctave¶
- Return or set the pitch name with octave from the Pitch object. See nameWithOctave.
- pitchClass¶
- Return or set the pitch class from the music21.pitch.Pitch object. See music21.pitch.Pitch.pitchClass.
- accidental¶
- Return or set the Accidental object from the Pitch object.
- diatonicNoteNum¶
- Return the diatonic note number from the Pitch object. See diatonicNoteNum.
- lily¶
- The name of the note as it would appear in Lilypond format.
- midiEvents¶
Get or set this chord as a list of music21.midi.base.MidiEvent objects.
>>> n = Note() >>> n.midiEvents [<MidiEvent DeltaTime, t=0, track=None, channel=None>, <MidiEvent NOTE_ON, t=None, track=None, channel=1, pitch=60, velocity=90>, <MidiEvent DeltaTime, t=1024, track=None, channel=None>, <MidiEvent NOTE_OFF, t=None, track=None, channel=1, pitch=60, velocity=0>]
- midiFile¶
Return a complete music21.midi.base.MidiFile object.
>>> n = Note() >>> mf = n.midiFile
- mx¶
- Returns a List of mxNotes Attributes of notes are merged from different locations: first from the duration objects, then from the pitch objects. Finally, GeneralNote attributes are added
- pitchClassString¶
- Return or set the pitch class string from the Pitch object. See pitchClassString.
- ps¶
- Return or set the numerical pitch space representation from the music21.pitch.Pitch object. See music21.pitch.Pitch.ps.
Properties inherited from GeneralNote: quarterLength, beat, beatDuration, beatStr, color, lyric, musicxml
Properties inherited from Music21Object: duration, classes, offset, parent, priority
Note methods
- setAccidental(accidental)¶
- This method is obsolete: use the accidental property instead.
- transpose(value, inPlace=False)¶
Transpose the Note by the user-provided value. If the value is an integer, the transposition is treated in half steps. If the value is a string, any Interval string specification can be provided.
>>> from music21 import * >>> a = note.Note('g4') >>> b = a.transpose('m3') >>> b <music21.note.Note B-> >>> aInterval = interval.Interval(-6) >>> b = a.transpose(aInterval) >>> b <music21.note.Note C#> >>> a.transpose(aInterval, inPlace=True) >>> a <music21.note.Note C#>Methods inherited from NotRest: splitNoteAtPoint()
Methods inherited from GeneralNote: addLyric(), augmentOrDiminish(), compactNoteInfo(), splitAtDurations(), splitByQuarterLengths()
Methods inherited from Music21Object: addContext(), addLocation(), addLocationAndParent(), freezeIds(), getContextAttr(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), hasContext(), isClass(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), searchParentByAttr(), setContextAttr(), setOffsetBySite(), show(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()
Inherits from: GeneralNote, Music21Object
General rest class
Rest attributes
- isNote¶
- Boolean read-only value describing if this object is a Chord. Is False
- isRest¶
- Boolean read-only value describing if this is a Rest. Is False
Attributes without Documentation: isUnpitched, name
Attributes inherited from GeneralNote: editorial, isChord, lyrics, notations, tie, articulations
Attributes inherited from Music21Object: classSortOrder, id, groups
Rest properties
- lily¶
The name of the rest as it would appear in Lilypond format.
>>> from music21 import * >>> r1 = note.Rest() >>> r1.duration.type = "half" >>> r1.lily 'r2'
- mx¶
- Returns a List of mxNotes Attributes of notes are merged from different locations: first from the duration objects, then from the pitch objects. Finally, GeneralNote attributes are added
Properties inherited from GeneralNote: quarterLength, beat, beatDuration, beatStr, color, lyric, musicxml
Properties inherited from Music21Object: duration, classes, offset, parent, priority
Rest methods
Methods inherited from GeneralNote: addLyric(), augmentOrDiminish(), compactNoteInfo(), splitAtDurations(), splitByQuarterLengths()
Methods inherited from Music21Object: addContext(), addLocation(), addLocationAndParent(), freezeIds(), getContextAttr(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), hasContext(), isClass(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), searchParentByAttr(), setContextAttr(), setOffsetBySite(), show(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()
Inherits from: Note, NotRest, GeneralNote, Music21Object
Inherits from: Music21Object
A GeneralNote object is the parent object for the Note, Rest, Chord, and related objects.
GeneralNote attributes
- editorial¶
- a NoteEditorial object that stores editorial information (comments, harmonic information, ficta) and certain display information (color, hidden-state).
- isChord¶
- Boolean read-only value describing if this object is a Chord.
Attributes without Documentation: notations, articulations
Attributes inherited from Music21Object: classSortOrder, id, groups
GeneralNote properties
- quarterLength¶
Return the Duration as represented in Quarter Length.
>>> from music21 import * >>> n = note.Note() >>> n.quarterLength = 2.0 >>> n.quarterLength 2.0
- beat¶
Return the beat of this Note as found in the most recently positioned Measure. Beat values count from 1 and contain a floating-point designation between 0 and 1 to show proportional progress through the beat.
>>> from music21 import * >>> n = note.Note() >>> n.quarterLength = .5 >>> m = stream.Measure() >>> m.timeSignature = meter.TimeSignature('3/4') >>> m.repeatAppend(n, 6) >>> [m.notes[i].beat for i in range(6)] [1.0, 1.5, 2.0, 2.5, 3.0, 3.5] >>> m.timeSignature = meter.TimeSignature('6/8') >>> [m.notes[i].beat for i in range(6)] [1.0, 1.3333333..., 1.666666666..., 2.0, 2.33333333..., 2.66666...]
- beatDuration¶
Return a Duration of the beat active for this Note as found in the most recently positioned Measure.
>>> from music21 import * >>> n = note.Note() >>> n.quarterLength = .5 >>> m = stream.Measure() >>> m.timeSignature = meter.TimeSignature('3/4') >>> m.repeatAppend(n, 6) >>> [m.notes[i].beatDuration.quarterLength for i in range(6)] [1.0, 1.0, 1.0, 1.0, 1.0, 1.0] >>> m.timeSignature = meter.TimeSignature('6/8') >>> [m.notes[i].beatDuration.quarterLength for i in range(6)] [1.5, 1.5, 1.5, 1.5, 1.5, 1.5]
- beatStr¶
Return a string representation of the beat of this Note as found in the most recently positioned Measure. Beat values count from 1 and contain a fractional designation to show progress through the beat.
>>> from music21 import * >>> n = note.Note() >>> n.quarterLength = .5 >>> m = stream.Measure() >>> m.timeSignature = meter.TimeSignature('3/4') >>> m.repeatAppend(n, 6) >>> [m.notes[i].beatStr for i in range(6)] ['1', '1 1/2', '2', '2 1/2', '3', '3 1/2'] >>> m.timeSignature = meter.TimeSignature('6/8') >>> [m.notes[i].beatStr for i in range(6)] ['1', '1 1/3', '1 2/3', '2', '2 1/3', '2 2/3']
- color¶
- Return the Note color.
- lyric¶
- The lyric property can be used to get and set a lyric for this Note, Chord, or Rest. In most cases the addLyric() method should be used.
- musicxml¶
- Return a complete musicxml representation.
Properties inherited from Music21Object: duration, classes, offset, parent, priority
GeneralNote methods
- addLyric(text, lyricNumber=None)¶
Adds a lyric, or an additional lyric, to a Note, Chord, or Rest’s lyric list. If lyricNumber is not None, a specific line of lyric text can be set.
>>> from music21 import * >>> n1 = note.Note() >>> n1.addLyric("hello") >>> n1.lyrics[0].text 'hello' >>> n1.lyrics[0].number 1 >>> # note that the option number specified gives the lyric number, not the list position >>> n1.addLyric("bye", 3) >>> n1.lyrics[1].text 'bye' >>> n1.lyrics[1].number 3 >>> # replace existing lyric >>> n1.addLyric("ciao", 3) >>> n1.lyrics[1].text 'ciao' >>> n1.lyrics[1].number 3
- augmentOrDiminish(scalar, inPlace=True)¶
Given a scalar greater than zero, return a Note with a scaled Duration. If inPlace is True, this is done in-place and the method returns None. If inPlace is False, this returns a modified deep copy.
>>> from music21 import * >>> n = note.Note('g#') >>> n.quarterLength = 3 >>> n.augmentOrDiminish(2) >>> n.quarterLength 6 >>> from music21 import chord >>> c = chord.Chord(['g#','A#','d']) >>> n.quarterLength = 2 >>> n.augmentOrDiminish(.25) >>> n.quarterLength 0.5 >>> n = note.Note('g#') >>> n.augmentOrDiminish(-1) Traceback (most recent call last): NoteException: scalar must be greater than zero
- compactNoteInfo()¶
- A debugging info tool, returning information about a note E- E 4 flat 16th 0.166666666667 & is a tuplet (in fact STOPS the tuplet)
- splitAtDurations()¶
Takes a Note and returns a list of Notes with only a single duration.DurationUnit in each. Ties are added.
>>> from music21 import * >>> a = note.Note() >>> a.duration.clear() # remove defaults >>> a.duration.addDurationUnit(duration.Duration('half')) >>> a.duration.quarterLength 2.0 >>> a.duration.addDurationUnit(duration.Duration('whole')) >>> a.duration.quarterLength 6.0 >>> b = a.splitAtDurations() >>> b[0].pitch == b[1].pitch True >>> b[0].duration.type 'half' >>> b[1].duration.type 'whole'
- splitByQuarterLengths(quarterLengthList)¶
Given a list of quarter lengths, return a list of Note objects, copied from this Note, that are partitioned and tied with the specified quarter length list durations.
>>> n = Note() >>> n.quarterLength = 3 >>> post = n.splitByQuarterLengths([1,1,1]) >>> [n.quarterLength for n in post] [1, 1, 1]Methods inherited from Music21Object: addContext(), addLocation(), addLocationAndParent(), freezeIds(), getContextAttr(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), hasContext(), isClass(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), searchParentByAttr(), setContextAttr(), setOffsetBySite(), show(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()
Inherits from: Note, NotRest, GeneralNote, Music21Object
Inherits from: GeneralNote, Music21Object
Parent class for objects that are not rests; or, object that can be tied.
NotRest attributes
Attributes without Documentation: stemDirection
Attributes inherited from GeneralNote: editorial, isChord, lyrics, notations, tie, articulations
Attributes inherited from Music21Object: classSortOrder, id, groups
NotRest properties
Properties inherited from GeneralNote: quarterLength, beat, beatDuration, beatStr, color, lyric, musicxml
Properties inherited from Music21Object: duration, classes, offset, parent, priority
NotRest methods
- splitNoteAtPoint(quarterLength)¶
Split a Note into two Notes.
>>> from music21 import * >>> a = note.NotRest() >>> a.duration.type = 'whole' >>> b, c = a.splitNoteAtPoint(3) >>> b.duration.type 'half' >>> b.duration.dots 1 >>> b.duration.quarterLength 3.0 >>> c.duration.type 'quarter' >>> c.duration.dots 0 >>> c.duration.quarterLength 1.0Methods inherited from GeneralNote: addLyric(), augmentOrDiminish(), compactNoteInfo(), splitAtDurations(), splitByQuarterLengths()
Methods inherited from Music21Object: addContext(), addLocation(), addLocationAndParent(), freezeIds(), getContextAttr(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), hasContext(), isClass(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), searchParentByAttr(), setContextAttr(), setOffsetBySite(), show(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()
Inherits from: Note, NotRest, GeneralNote, Music21Object
Inherits from: Music21Object
Object added to notes that are tied to other notes. The type value is generally one of start or stop.
>>> from music21 import *
>>> note1 = note.Note()
>>> note1.tie = Tie("start")
>>> note1.tieStyle = "normal" # or could be dotted or dashed
>>> note1.tie.type
'start'
Differences from MusicXML:
notes do not need to know if they are tied from a
previous note. i.e., you can tie n1 to n2 just with
a tie start on n1. However, if you want proper musicXML output
you need a tie stop on n2
one tie with "continue" implies tied from and tied to
optional (to know what notes are next:)
.to = note() # not implimented yet, b/c of garbage coll.
.from = note()
Tie attributes
Attributes without Documentation: type
Attributes inherited from Music21Object: classSortOrder, id, groups
Tie properties
- mx¶
- Return a MusicXML object representation.
Properties inherited from Music21Object: classes, duration, offset, parent, priority
Tie methods
Methods inherited from Music21Object: searchParentByAttr(), getContextAttr(), setContextAttr(), addContext(), addLocation(), addLocationAndParent(), freezeIds(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), hasContext(), isClass(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), setOffsetBySite(), show(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()
Inherits from: GeneralNote, Music21Object
General class of unpitched objects which appear at different places on the staff. Examples: percussion notation
Unpitched attributes
- isNote¶
- Boolean read-only value describing if this object is a Chord. Is False
- isRest¶
- Boolean read-only value describing if this is a Rest. Is False
Attributes without Documentation: displayOctave, displayStep, isUnpitched
Attributes inherited from GeneralNote: editorial, isChord, lyrics, notations, tie, articulations
Attributes inherited from Music21Object: classSortOrder, id, groups
Unpitched properties
Properties inherited from GeneralNote: quarterLength, beat, beatDuration, beatStr, color, lyric, musicxml
Properties inherited from Music21Object: duration, classes, offset, parent, priority
Unpitched methods
Methods inherited from GeneralNote: addLyric(), augmentOrDiminish(), compactNoteInfo(), splitAtDurations(), splitByQuarterLengths()
Methods inherited from Music21Object: addContext(), addLocation(), addLocationAndParent(), freezeIds(), getContextAttr(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), hasContext(), isClass(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), searchParentByAttr(), setContextAttr(), setOffsetBySite(), show(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()
Inherits from: Note, NotRest, GeneralNote, Music21Object