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, JSONSerializer
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, expressions, editorial, tie, lyrics, 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.
- midiEvents¶
Get or set this chord as a list of music21.midi.base.MidiEvent objects.
>>> from music21 import * >>> n = note.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 based on the Note. The music21.midi.base.MidiFile object can be used to write a MIDI file of this Note with default parameters using the music21.midi.base.MidiFile.write() method, given a file path. The file must be opened in ‘wb’ mode.
>>> from music21 import * >>> n = note.Note() >>> mf = n.midiFile >>> mf.open('/Volumes/xdisc/_scratch/midi.mid', 'wb') >>> mf.write() >>> mf.close()
- mx¶
- No documentation.
- pitchClassString¶
- Return or set the pitch class string from the Pitch object. See pitchClassString.
- pitchNames¶
Return a list of Pitch names from name. This property is designed to provide an interface analogous to that found on Chord.
>>> from music21 import * >>> n = note.Note('g#') >>> n.name 'G#' >>> n.pitchNames ['G#'] >>> n.pitchNames = [pitch.Pitch('c2'), pitch.Pitch('g2')] >>> n.name 'C' >>> n.pitchNames ['C']
- pitches¶
Return the Pitch object in a list. This property is designed to provide an interface analogous to that found on Chord.
>>> from music21 import * >>> n = note.Note('g#') >>> n.nameWithOctave 'G#' >>> n.pitches [G#] >>> n.pitches = [pitch.Pitch('c2'), pitch.Pitch('g2')] >>> n.nameWithOctave 'C2' >>> n.pitches [C2]
- 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, color, lily, lyric, musicxml
Properties inherited from Music21Object: duration, activeSite, beat, beatDuration, beatStr, beatStrength, classes, measureNumberLocal, offset, priority
Properties inherited from JSONSerializer: json
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 GeneralNote: addLyric(), augmentOrDiminish(), compactNoteInfo()
Methods inherited from Music21Object: addContext(), addLocation(), addLocationAndParent(), freezeIds(), getAllContextsByClass(), getContextAttr(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), hasContext(), isClass(), mergeAttributes(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), searchParentByAttr(), setContextAttr(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()
Methods inherited from JSONSerializer: jsonAttributes(), jsonComponentFactory(), jsonPrint(), jsonRead(), jsonWrite()
Inherits from: GeneralNote, Music21Object, JSONSerializer
General rest class
Rest attributes
- isNote¶
- Boolean read-only value describing if this GeneralNote object is a Note. Is False
- isRest¶
- Boolean read-only value describing if this GeneralNote object is a Rest. Is False
Attributes without Documentation: isUnpitched, name
Attributes inherited from GeneralNote: editorial, isChord, expressions, tie, lyrics, articulations
Attributes inherited from Music21Object: classSortOrder, id, groups
Rest properties
- 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, color, lily, lyric, musicxml
Properties inherited from Music21Object: duration, activeSite, beat, beatDuration, beatStr, beatStrength, classes, measureNumberLocal, offset, priority
Properties inherited from JSONSerializer: json
Rest methods
Methods inherited from GeneralNote: addLyric(), augmentOrDiminish(), compactNoteInfo()
Methods inherited from Music21Object: addContext(), addLocation(), addLocationAndParent(), freezeIds(), getAllContextsByClass(), getContextAttr(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), hasContext(), isClass(), mergeAttributes(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), searchParentByAttr(), setContextAttr(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()
Methods inherited from JSONSerializer: jsonAttributes(), jsonComponentFactory(), jsonPrint(), jsonRead(), jsonWrite()
Inherits from: Note, NotRest, GeneralNote, Music21Object, JSONSerializer
Inherits from: Music21Object, JSONSerializer
A GeneralNote object is the base class 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 GeneralNote object is a Chord. Is True
- tie¶
- either None or a Tie object.
Attributes without Documentation: expressions, 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
- color¶
- Return the Note color.
- lily¶
read-only property that returns a LilyString of the lilypond representation of a note (or via subclassing, rest or chord)
>>> from music21 import * >>> n1 = note.Note("C#5") >>> n1.tie = tie.Tie('start') >>> n1.articulations = [articulations.Accent()] ## DOES NOTHING RIGHT NOW >>> n1.quarterLength = 1.25 >>> n1.lily cis''4~ cis''16~ >>> r1 = note.Rest() >>> r1.duration.type = "half" >>> r1.lily r2 >>> r2 = note.Rest() >>> r2.quarterLength = 1.25 >>> r2.lily r4 r16 >>> c1 = chord.Chord(["C#2", "E4", "D#5"]) >>> c1.quarterLength = 2.5 # BUG: 2.333333333 doesnt work yet >>> c1.lily <cis, e' dis''>2~ <cis, e' dis''>8
- 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, activeSite, beat, beatDuration, beatStr, beatStrength, classes, measureNumberLocal, offset, priority
Properties inherited from JSONSerializer: json
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 >>> 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)
Methods inherited from Music21Object: addContext(), addLocation(), addLocationAndParent(), freezeIds(), getAllContextsByClass(), getContextAttr(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), hasContext(), isClass(), mergeAttributes(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), searchParentByAttr(), setContextAttr(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()
Methods inherited from JSONSerializer: jsonAttributes(), jsonComponentFactory(), jsonPrint(), jsonRead(), jsonWrite()
Inherits from: Note, NotRest, GeneralNote, Music21Object, JSONSerializer
Inherits from: GeneralNote, Music21Object, JSONSerializer
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, expressions, tie, lyrics, articulations
Attributes inherited from Music21Object: classSortOrder, id, groups
NotRest properties
Properties inherited from GeneralNote: quarterLength, color, lily, lyric, musicxml
Properties inherited from Music21Object: duration, activeSite, beat, beatDuration, beatStr, beatStrength, classes, measureNumberLocal, offset, priority
Properties inherited from JSONSerializer: json
NotRest methods
Methods inherited from GeneralNote: addLyric(), augmentOrDiminish(), compactNoteInfo()
Methods inherited from Music21Object: addContext(), addLocation(), addLocationAndParent(), freezeIds(), getAllContextsByClass(), getContextAttr(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), hasContext(), isClass(), mergeAttributes(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), searchParentByAttr(), setContextAttr(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()
Methods inherited from JSONSerializer: jsonAttributes(), jsonComponentFactory(), jsonPrint(), jsonRead(), jsonWrite()
Inherits from: Note, NotRest, GeneralNote, Music21Object, JSONSerializer
Inherits from: GeneralNote, Music21Object, JSONSerializer
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 GeneralNote object is a Note. Is False
- isRest¶
- Boolean read-only value describing if this GeneralNote object is a Rest. Is False
Attributes without Documentation: displayOctave, displayStep, isUnpitched
Attributes inherited from GeneralNote: editorial, isChord, expressions, tie, lyrics, articulations
Attributes inherited from Music21Object: classSortOrder, id, groups
Unpitched properties
Properties inherited from GeneralNote: quarterLength, color, lily, lyric, musicxml
Properties inherited from Music21Object: duration, activeSite, beat, beatDuration, beatStr, beatStrength, classes, measureNumberLocal, offset, priority
Properties inherited from JSONSerializer: json
Unpitched methods
Methods inherited from GeneralNote: addLyric(), augmentOrDiminish(), compactNoteInfo()
Methods inherited from Music21Object: addContext(), addLocation(), addLocationAndParent(), freezeIds(), getAllContextsByClass(), getContextAttr(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), hasContext(), isClass(), mergeAttributes(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), searchParentByAttr(), setContextAttr(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()
Methods inherited from JSONSerializer: jsonAttributes(), jsonComponentFactory(), jsonPrint(), jsonRead(), jsonWrite()
Inherits from: Note, NotRest, GeneralNote, Music21Object, JSONSerializer