tinyNotation is a simple way of specifying single line melodies that uses a notation somewhat similar to Lilypond but with WAY fewer options. It was originally developed to notate trecento (medieval Italian) music, but it is pretty useful for a lot of short examples, so we have made it a generally supported music21 format.
N.B.: TinyNotation is not meant to expand to cover every single case. Instead it is meant to be subclassable to extend to the cases your project needs. See for instance the harmony examples in HarmonyStream and HarmonyNote or the Trecento specific examples in trecento/cadencebook.py
Here are the most important rules:
Note names are: a,b,c,d,e,f,g and r for rest
Flats, sharps, and naturals are notated as #,- (not b), and (if needed) n. If the accidental is above the staff (i.e., editorial), enclose it in parentheses: (#), etc. Make sure that flats in the key signatures are explicitly specified.
Note octaves are specified as follows:
CC to BB = from C below bass clef to second-line B in bass clef
C to B = from bass clef C to B below middle C.
c to b = from middle C to the middle of treble clef
c' to b' = from C in treble clef to B above treble clef
Octaves below and above these are specified by further doublings of letter (CCC) or apostrophes (c’‘) – this is one of the note name standards found in many music theory books.
After the note name, a number may be placed indicating the note length: 1 = whole note, 2 = half, 4 = quarter, 8 = eighth, 16 = sixteenth. etc. If the number is omitted then it is assumed to be the same as the previous note. I.e., c8 B c d is a string of eighth notes.
After the number, a ~ can be placed to show a tie to the next note. A ”.” indicates a dotted note. (If you are entering data via Excel or other spreadsheet, be sure that “capitalize the first letter of sentences” is turned off under “Tools->AutoCorrect,” otherwise the next letter will be capitalized, and the octave will be screwed up.)
For triplets use this notation: trip{c4 d8} indicating that these two notes both have “3s” over them. For 4 in the place of 3, use quad{c16 d e8}. No other tuplets are supported.
Again, see the HarmonyStream (below) and trecento.cadencebook examples to see how to make TinyNotation useful for your own needs.
(Currently, final notes with fermatas (or any very long final note), take 0 for the note length. But expect this to disappear from the TinyNotation specification soon, as it’s too Trecento specific.)
Class defining a single note in TinyNotation. The “note” attribute returns a Note object.
See docs for TinyNotationStream for usage.
Simple example:
>>> tnN = tinyNotation.TinyNotationNote("c8")
>>> m21Note = tnN.note
>>> m21Note
<music21.note.Note C>
>>> m21Note.octave
4
>>> m21Note.duration
<music21.duration.Duration 0.5>
Very complex example:
>>> tnN = tinyNotation.TinyNotationNote("AA-4.~=aflat_hel-")
>>> m21Note = tnN.note
>>> m21Note.name
'A-'
>>> m21Note.octave
2
>>> m21Note.lyric
'hel'
>>> m21Note.id
'aflat'
The optional third element is a dictionary of stored information from previous notes that might affect parsing of this note:
>>> storedDict = {}
>>> storedDict['lastNoteTied'] = True
>>> storedDict['inTrip'] = True
>>> tnN = tinyNotation.TinyNotationNote("d''#4", storedDict)
>>> tnN.note.tie
<music21.tie.Tie stop>
>>> tnN.note.duration.quarterLength
Fraction(2, 3)
TinyNotationNote read-only properties
TinyNotationNote methods
method to create a note object in sub classes of tiny notation. Should return a Note-like object or None
Subclassable method to set the dots attributes of the duration object.
It is subclassed in music21.trecento.cadencebook.TrecentoNote where double dots are redefined as referring to multiply by 2.25 (according to a practice used by some Medieval musicologists).
helper method that takes the dictionary self.regularExpressions (which should be a shared, class-level object) and compiles each one if it hasn’t already been compiled and makes it an attribute of the class. See setupRegularExpressions() in TinyNotationStream for more details.
A TinyNotationStream takes in a string representation similar to Lilypond format but simplified somewhat.
Can also take in an optional time signature string (or TimeSignature object) as a second argument, but this is mostly for historical reasons.
Example in 3/4:
>>> stream1 = tinyNotation.TinyNotationStream("3/4 E4 r f# g=lastG trip{b-8 a g} c4~ c")
>>> stream1.show('text')
{0.0} <music21.meter.TimeSignature 3/4>
{0.0} <music21.note.Note E>
{1.0} <music21.note.Rest rest>
{2.0} <music21.note.Note F#>
{3.0} <music21.note.Note G>
{4.0} <music21.note.Note B->
{4.3333} <music21.note.Note A>
{4.6667} <music21.note.Note G>
{5.0} <music21.note.Note C>
{6.0} <music21.note.Note C>
>>> stream1.getElementById("lastG").step
'G'
>>> stream1.notesAndRests[1].isRest
True
>>> stream1.notesAndRests[0].octave
3
>>> stream1.notes[-2].tie.type
'start'
>>> stream1.notes[-1].tie.type
'stop'
Changing time signatures are supported:
>>> s1 = converter.parse('tinynotation: 3/4 C4 D E 2/4 F G A B 1/4 c')
>>> s1.show('t')
{0.0} <music21.meter.TimeSignature 3/4>
{0.0} <music21.note.Note C>
{1.0} <music21.note.Note D>
{2.0} <music21.note.Note E>
{3.0} <music21.meter.TimeSignature 2/4>
{3.0} <music21.note.Note F>
{4.0} <music21.note.Note G>
{5.0} <music21.note.Note A>
{6.0} <music21.note.Note B>
{7.0} <music21.meter.TimeSignature 1/4>
{7.0} <music21.note.Note C>
>>> s2 = s1.makeMeasures()
>>> s2.show('t')
{0.0} <music21.stream.Measure 1 offset=0.0>
{0.0} <music21.clef.BassClef>
{0.0} <music21.meter.TimeSignature 3/4>
{0.0} <music21.note.Note C>
{1.0} <music21.note.Note D>
{2.0} <music21.note.Note E>
{3.0} <music21.stream.Measure 2 offset=3.0>
{0.0} <music21.meter.TimeSignature 2/4>
{0.0} <music21.note.Note F>
{1.0} <music21.note.Note G>
{5.0} <music21.stream.Measure 3 offset=5.0>
{0.0} <music21.note.Note A>
{1.0} <music21.note.Note B>
{7.0} <music21.stream.Measure 4 offset=7.0>
{0.0} <music21.meter.TimeSignature 1/4>
{0.0} <music21.note.Note C>
{1.0} <music21.bar.Barline style=final>
TinyNotationStream bases
TinyNotationStream read-only properties
Read-only properties inherited from Stream:
Read-only properties inherited from Music21Object:
TinyNotationStream read/write properties
Read/write properties inherited from Stream:
Read/write properties inherited from Music21Object:
TinyNotationStream methods
called out so as to be subclassable, returns a TinyNotationNote object
helper method that takes the dictionary self.regularExpressions (which should be a shared, class-level object) and compiles each one if it hasn’t already been compiled and makes it an attribute of the class.
For instance, if you have:
>>> regularExpressions = {'PUNCTUS': 'p', 'BREVE': 'b+'}
calling self.setupRegularExpressions will replace p and b+ with re.compile versions of the same and make self.PUNCTUS = re.compile(‘p’), etc.
Methods inherited from Stream:
Methods inherited from Music21Object:
TinyNotationStream instance variables
Instance variables inherited from Stream:
Instance variables inherited from Music21Object:
HarmonyStream provides an example of subclassing TinyNotationStream to include harmonies and lyrics encoded in a simple format.
>>> michelle = "c2*F*_Mi- c_chelle r4*B-m7* d-_ma A-2_belle "
>>> michelle += "G4*E-*_these c_are A-_words G_that "
>>> michelle += "F*Ddim*_go A-_to- Bn_geth- A-_er"
>>> hns = tinyNotation.HarmonyStream(michelle, "4/4")
>>> ns = hns.notesAndRests
>>> ns[0].step
'C'
>>> ns[0].editorial.misc['harmony']
'F'
>>> ns[0].lyric # note that hyphens are removed
'Mi'
>>> ns[2].isRest
True
>>> ns[5].name
'G'
>>> ns[7].name
'A-'
HarmonyStream bases
HarmonyStream read-only properties
Read-only properties inherited from Stream:
Read-only properties inherited from Music21Object:
HarmonyStream read/write properties
Read/write properties inherited from Stream:
Read/write properties inherited from Music21Object:
HarmonyStream methods
Methods inherited from TinyNotationStream:
Methods inherited from Stream:
Methods inherited from Music21Object:
HarmonyStream instance variables
Instance variables inherited from TinyNotationStream:
|
|
|
Instance variables inherited from Stream:
Instance variables inherited from Music21Object:
HarmonyNote bases
HarmonyNote read-only properties
Read-only properties inherited from TinyNotationNote:
HarmonyNote methods
checks to see if a note has markup in the form TEXT and if so, stores TEXT in the notes editorial.misc[] dictionary object
See the demonstration in the docs for class HarmonyLine.
Methods inherited from TinyNotationNote: