Previous topic

music21.tie

Next topic

music21.trecento.cadencebook

Table Of Contents

Table Of Contents

music21.tinyNotation

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:

  1. Note names are: a,b,c,d,e,f,g and r for rest

  2. 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.

  3. 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.

  4. 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.

  5. 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.)

  6. 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.)

TinyNotationNote

class music21.tinyNotation.TinyNotationNote(stringRep=None, storedDict={})

Class defining a single note in TinyNotation. The “note” attribute returns a Note object.

See docs for TinyNotationStream for usage.

Simple example:

>>> from music21 import *
>>> 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
0.6666666...

TinyNotationNote attributes

storedDict

A replacement for dictionaries that behave a bit more like perl hashes. No more KeyErrors. The difference between DefaultHash and defaultdict is that the Dict values come first in the definition and that default can be set to None (which it is) or to any object.

If you want a factory that makes hashes with a particular different default, use:

falsehash = lambda h = None: common.DefaultHash(h, default = False) a = falsehash({“A”: falsehash(), “B”: falsehash()}) print(a[“A”][“hi”]) # returns False

there’s probably a way to use this to create a data structure of arbitrary dimensionality, though it escapes this author.

if callDefault is True then the default is called:

common.DefaultHash(default = list, callDefault = True)

will create a new List for each element

Attributes without Documentation: debug, stringRep

TinyNotationNote properties

note

No documentation.

TinyNotationNote methods

customNotationMatch(m21NoteObject, stringRep, storedDict)

No documentation.

customPitchMatch(stringRep, storedDict)

method to create a note object in sub classes of tiny notation. Should return a Note-like object or None

getDots(stringRep, noteObj)

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).

TinyNotationStream

Inherits from: Stream, Music21Object, JSONSerializer

class music21.tinyNotation.TinyNotationStream(stringRep='', timeSignature=None)

A TinyNotationStream takes in a string representation similar to Lilypond format but simplified somewhat and an optional time signature string (or TimeSignature object).

Example in 3/4:

>>> from music21 import *
>>> 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.33333333333} <music21.note.Note A>
{4.66666666667} <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'

TinyNotationStream attributes

Attributes without Documentation: stringRep

Attributes inherited from Stream: isMeasure, isStream, isFlat, autoSort, isSorted, flattenedRepresentationOf

Attributes inherited from Music21Object: classSortOrder, isSpanner, isVariant, id, groups, hideObjectOnPrint

TinyNotationStream properties

TinyNotationStream methods

getNote(stringRep, storedDict={})

called out so as to be subclassable, returns a TinyNotationNote object

Methods inherited from Stream: append(), insert(), insertAndShift(), transpose(), augmentOrDiminish(), scaleOffsets(), scaleDurations(), activateVariants(), addGroupForElements(), allPlayingWhileSounding(), analyze(), attachIntervalsBetweenStreams(), attachMelodicIntervals(), attributeCount(), bestClef(), chordify(), expandRepeats(), explode(), extendDuration(), extendDurationAndGetBoundaries(), extendTies(), extractContext(), findConsecutiveNotes(), findGaps(), flattenUnnecessaryVoices(), getClefs(), getElementAfterElement(), getElementAfterOffset(), getElementAtOrAfter(), getElementAtOrBefore(), getElementBeforeElement(), getElementBeforeOffset(), getElementById(), getElementByObjectId(), getElementsByClass(), getElementsByGroup(), getElementsByOffset(), getElementsNotOfClass(), getInstrument(), getInstruments(), getKeySignatures(), getOffsetByElement(), getOverlaps(), getSimultaneous(), getTimeSignatures(), groupCount(), groupElementsByOffset(), hasElement(), hasElementByObjectId(), hasElementOfClass(), hasMeasures(), hasPartLikeStreams(), hasVoices(), haveAccidentalsBeenMade(), haveBeamsBeenMade(), index(), insertAtNativeOffset(), insertIntoNoteOrChord(), internalize(), invertDiatonic(), isSequence(), isTwelveTone(), isWellFormedNotation(), makeAccidentals(), makeBeams(), makeChords(), makeImmutable(), makeMeasures(), makeMutable(), makeNotation(), makeRests(), makeTies(), makeTupletBrackets(), makeVoices(), measure(), measureOffsetMap(), measureTemplate(), measures(), melodicIntervals(), mergeElements(), metronomeMarkBoundaries(), pitchAttributeCount(), playingWhenAttacked(), plot(), pop(), quantize(), realizeOrnaments(), recurse(), remove(), removeByClass(), removeByNotOfClass(), repeatAppend(), repeatInsert(), replace(), restoreActiveSites(), setDerivation(), setupSerializationScaffold(), shiftElements(), showVariantAsOssialikePart(), simultaneousAttacks(), sliceAtOffsets(), sliceByBeat(), sliceByGreatestDivisor(), sliceByQuarterLengths(), sort(), splitAtQuarterLength(), splitByClass(), storeAtEnd(), stripTies(), teardownSerializationScaffold(), toSoundingPitch(), toWrittenPitch(), transferOffsetToElements(), trimPlayingWhileSounding(), unwrapWeakref(), voicesToParts(), wrapWeakref()

Methods inherited from Music21Object: addContext(), addLocation(), addLocationAndActiveSite(), freezeIds(), getAllContextsByClass(), getCommonSiteIds(), getCommonSites(), getContextAttr(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), getSpannerSites(), hasContext(), hasSite(), hasSpannerSite(), hasVariantSite(), isClassOrSubclass(), mergeAttributes(), next(), previous(), purgeLocations(), purgeOrphans(), purgeUndeclaredIds(), removeLocationBySite(), removeLocationBySiteId(), searchActiveSiteByAttr(), setContextAttr(), setOffsetBySite(), show(), splitAtDurations(), splitByQuarterLengths(), unfreezeIds(), write()

Methods inherited from JSONSerializer: jsonAttributes(), jsonComponentFactory(), jsonPrint(), jsonRead(), jsonWrite()

HarmonyStream

Inherits from: TinyNotationStream, Stream, Music21Object, JSONSerializer

class music21.tinyNotation.HarmonyStream(stringRep='', timeSignature=None)

HarmonyStream provides an example of subclassing TinyNotationStream to include harmonies and lyrics encoded in a simple format.

>>> from music21 import *

>>> 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-'

HarmonyNote

Inherits from: TinyNotationNote

class music21.tinyNotation.HarmonyNote(stringRep=None, storedDict={})