Objects for processing roman numeral analysis text files, as defined and demonstrated by Dmitri Tymoczko.
Inherits from: RTKeyTypeAtom, RTAtom, RTToken
An RTAnalyticKey(RTKeyTypeAtom) only defines a change in the key being analyzed. It does not in itself create a :class:~’music21.key.Key’ object
>>> from music21 import *
>>> gminor = romanText.RTAnalyticKey('g:')
>>> gminor
<RTAnalyticKey 'g:'>
>>> gminor.getKey()
<music21.key.Key of g minor>
>>> bminor = romanText.RTAnalyticKey('bb:')
>>> bminor
<RTAnalyticKey 'bb:'>
>>> bminor.getKey()
<music21.key.Key of b- minor>
RTAnalyticKey attributes
RTAnalyticKey methods
Methods inherited from RTKeyTypeAtom: getKey(), getKeySignature()
Methods inherited from RTAtom: isAtom()
Methods inherited from RTToken: isAnalyst(), isComposer(), isForm(), isKeySignature(), isMeasure(), isMovement(), isNote(), isPedal(), isPiece(), isProofreader(), isTimeSignature(), isTitle(), isWork()
Inherits from: RTToken
In RomanText, definitions of chords, phrases boundaries, open/close parenthesis, beat indicators, etc. appear within measures (RTMeasure objects). These individual elements will be called Atoms, as they are data that is not tagged.
Each atom store a reference to its container (normally an RTMeasure).
>>> from music21 import *
>>> chordIV = romanText.RTAtom('IV')
>>> beat4 = romanText.RTAtom('b4')
however, see RTChord, RTBeat, etc. which are subclasses of RTAtom specifically for storing chords, beats, etc.
RTAtom attributes
Attributes without Documentation: container
Attributes inherited from RTToken: src
RTAtom methods
- isAtom()¶
No documentation.
Methods inherited from RTToken: isAnalyst(), isComposer(), isForm(), isKeySignature(), isMeasure(), isMovement(), isNote(), isPedal(), isPiece(), isProofreader(), isTimeSignature(), isTitle(), isWork()
Inherits from: RTAtom, RTToken
An RTAtom subclass that defines a beat definition. Also contains a reference to the container.
>>> from music21 import *
>>> beatFour = romanText.RTBeat('b4')
RTBeat attributes
RTBeat methods
- getOffset(timeSignature)¶
Given a time signature, return the offset position specified by this beat.
>>> from music21 import * >>> rtb = romanText.RTBeat('b1.5') >>> rtb.getOffset(meter.TimeSignature('3/4')) 0.5 >>> rtb.getOffset(meter.TimeSignature('6/8')) 0.75 >>> rtb.getOffset(meter.TimeSignature('2/2')) 1.0 >>> rtb = romanText.RTBeat('b2') >>> rtb.getOffset(meter.TimeSignature('3/4')) 1.0 >>> rtb.getOffset(meter.TimeSignature('6/8')) 1.5>>> rtb = romanText.RTBeat('b1.66') >>> rtb.getOffset(meter.TimeSignature('6/8')) 1.0 >>> rtc = romanText.RTBeat('b1.66.5') >>> rtc.getOffset(meter.TimeSignature('6/8')) 1.25Methods inherited from RTAtom: isAtom()
Methods inherited from RTToken: isAnalyst(), isComposer(), isForm(), isKeySignature(), isMeasure(), isMovement(), isNote(), isPedal(), isPiece(), isProofreader(), isTimeSignature(), isTitle(), isWork()
Inherits from: RTAtom, RTToken
An RTAtom subclass that defines a chord. Also contains a reference to the container.
>>> from music21 import *
>>> chordIV = romanText.RTChord('IV')
RTChord attributes
RTChord methods
Methods inherited from RTAtom: isAtom()
Methods inherited from RTToken: isAnalyst(), isComposer(), isForm(), isKeySignature(), isMeasure(), isMovement(), isNote(), isPedal(), isPiece(), isProofreader(), isTimeSignature(), isTitle(), isWork()
Inherits from: RTAtom, RTToken
>>> from music21 import *
Inherits from: RTPhraseMarker, RTAtom, RTToken
>>> from music21 import *
>>> phrase = romanText.RTEllisonStart('|*')
>>> phrase
<RTEllisonStart '|*'>
Inherits from: RTPhraseMarker, RTAtom, RTToken
>>> from music21 import *
>>> phrase = romanText.RTEllisonStop('*|')
>>> phrase
<RTEllisonStop '*|'>
Roman Text File access
RTFile methods
- close()¶
No documentation.
- open(filename)¶
Open a file for reading, trying a variety of codecs and then trying them again with an ignore if it is not possible.
- openFileLike(fileLike)¶
Assign a file-like object, such as those provided by StringIO, as an open file object.
>>> fileLikeOpen = StringIO.StringIO()
- read()¶
Read a file. Note that this calls readstring, which processes all tokens.
If number is given, a work number will be extracted if possible.
- readstr(strSrc)¶
Read a string and process all Tokens. Returns a ABCHandler instance.
RTHandler properties
- tokens¶
Get or set tokens for this Handler
RTHandler methods
- definesMovement()¶
If this handler has 1 or more movement
>>> from music21 import * >>> rth = romanText.RTHandler() >>> rth.process('Movement: 1 \n \n m1') >>> rth.definesMovements() False >>> rth.definesMovement() True
- definesMovements(countRequired=2)¶
Return True if more than one movement is defined in a RT file.
>>> from music21 import * >>> rth = romanText.RTHandler() >>> rth.process('Movement: 1 \n Movement: 2 \n \n m1') >>> rth.definesMovements() True >>> rth.process('Movement: 1 \n m1') >>> rth.definesMovements() False
- process(src)¶
Given an entire specification as a single source string, strSrc. This is usually provided in a file.
- splitByMovement(duplicateHeader=True)¶
If we have movements defined, return a list of RTHandler objects, representing header information and each movement, in order.
>>> from music21 import * >>> rth = romanText.RTHandler() >>> rth.process('Title: Test \n Movement: 1 \n m1 \n Movement: 2 \n m1') >>> post = rth.splitByMovement(False) >>> len(post) 3 >>> len(post[0]) 1 >>> post[0].__class__ <class 'music21.romanText.base.RTHandler'> >>> len(post[1]), len(post[2]) (2, 2) >>> post = rth.splitByMovement(duplicateHeader=True) >>> len(post) 2 >>> len(post[0]), len(post[1]) (3, 3)
- tokenize(src)¶
Walk the RT string, creating RT objects along the way.
Inherits from: RTKeyTypeAtom, RTAtom, RTToken
RTKey attributes
RTKey methods
Methods inherited from RTKeyTypeAtom: getKey(), getKeySignature()
Methods inherited from RTAtom: isAtom()
Methods inherited from RTToken: isAnalyst(), isComposer(), isForm(), isKeySignature(), isMeasure(), isMovement(), isNote(), isPedal(), isPiece(), isProofreader(), isTimeSignature(), isTitle(), isWork()
Inherits from: RTAtom, RTToken
An RTKeySignature(RTAtom) only defines a change in the KeySignature. It does not in itself create a :class:~’music21.key.Key’ object, nor does it change the analysis taking place.
The number after KS defines the number of sharps (negative for flats)
>>> from music21 import *
>>> gminor = romanText.RTKeySignature('KS-2')
>>> gminor
<RTKeySignature 'KS-2'>
>>> gminor.getKeySignature()
<music21.key.KeySignature of 2 flats>
>>> Amajor = romanText.RTKeySignature('KS3')
>>> Amajor.getKeySignature()
<music21.key.KeySignature of 3 sharps>
RTKeySignature attributes
RTKeySignature methods
- getKeySignature()¶
No documentation.
Methods inherited from RTAtom: isAtom()
Methods inherited from RTToken: isAnalyst(), isComposer(), isForm(), isKeySignature(), isMeasure(), isMovement(), isNote(), isPedal(), isPiece(), isProofreader(), isTimeSignature(), isTitle(), isWork()
Inherits from: RTAtom, RTToken
RTKeyTypeAtoms contain utility functions for all Key-type tokens i.e., RTKey, RTAnalyticKey. (no longer KeySignature)
RTKeyTypeAtom attributes
RTKeyTypeAtom methods
- getKey()¶
This returns a Key, not a KeySignature object
- getKeySignature()¶
Get a KeySignature object.
Methods inherited from RTAtom: isAtom()
Methods inherited from RTToken: isAnalyst(), isComposer(), isForm(), isKeySignature(), isMeasure(), isMovement(), isNote(), isPedal(), isPiece(), isProofreader(), isTimeSignature(), isTitle(), isWork()
Inherits from: RTToken
In RomanText, measures are given one per line and always start with ‘m’. For instance:
m4 i b3 v b4 VI m5 b2 g: IV b4 V m6 i m7 D: V
Measure ranges can be used and copied, such as:
m8-m9=m4-m5
RTMeasure objects can also define variant readings for a measure:
m1 ii m1var1 ii b2 ii6 b3 IV
Variants are not part of the tag, but are read into an attribute.
Endings are indicated by a single letter after the measure number, such as “a” for first ending.
>>> from music21 import *
>>> rtm = romanText.RTMeasure('m15a V6 b1.5 V6/5 b2 I b3 viio6')
>>> rtm.data
'V6 b1.5 V6/5 b2 I b3 viio6'
>>> rtm.number
[15]
>>> rtm.repeatLetter
['a']
RTMeasure attributes
Attributes without Documentation: isCopyDefinition, repeatLetter, number, atoms, tag, variantLetter, variantNumber, data
Attributes inherited from RTToken: src
RTMeasure methods
- getCopyTarget()¶
If this measure defines a copy operation, return two lists defining the measures to copy; the second list has the repeat data.
>>> from music21 import * >>> rtm = romanText.RTMeasure('m35-36 = m29-30') >>> rtm.number [35, 36] >>> rtm.getCopyTarget() ([29, 30], ['', '']) >>> rtm = romanText.RTMeasure('m4 = m1') >>> rtm.number [4] >>> rtm.getCopyTarget() ([1], [''])
- isMeasure()¶
No documentation.
Methods inherited from RTToken: isAnalyst(), isAtom(), isComposer(), isForm(), isKeySignature(), isMovement(), isNote(), isPedal(), isPiece(), isProofreader(), isTimeSignature(), isTitle(), isWork()
Inherits from: RTAtom, RTToken
>>> from music21 import *
Inherits from: RTAtom, RTToken
Marks the end of an optional Key area which does not affect the roman numeral analysis. (For instance, it is possible to analyze in Bb major, while remaining in g minor)
>>> from music21 import *
>>> possibleKey = romanText.RTOptionalKeyClose('?)Bb:')
>>> possibleKey
<RTOptionalKeyClose '?)Bb:'>
>>> possibleKey.getKey()
<music21.key.Key of B- major>
RTOptionalKeyClose attributes
RTOptionalKeyClose methods
- getKey()¶
No documentation.
Methods inherited from RTAtom: isAtom()
Methods inherited from RTToken: isAnalyst(), isComposer(), isForm(), isKeySignature(), isMeasure(), isMovement(), isNote(), isPedal(), isPiece(), isProofreader(), isTimeSignature(), isTitle(), isWork()
Inherits from: RTAtom, RTToken
Marks the beginning of an optional Key area which does not affect the roman numeral analysis. (For instance, it is possible to analyze in Bb major, while remaining in g minor)
>>> from music21 import *
>>> possibleKey = romanText.RTOptionalKeyOpen('?(Bb:')
>>> possibleKey
<RTOptionalKeyOpen '?(Bb:'>
>>> possibleKey.getKey()
<music21.key.Key of B- major>
RTOptionalKeyOpen attributes
RTOptionalKeyOpen methods
- getKey()¶
No documentation.
Methods inherited from RTAtom: isAtom()
Methods inherited from RTToken: isAnalyst(), isComposer(), isForm(), isKeySignature(), isMeasure(), isMovement(), isNote(), isPedal(), isPiece(), isProofreader(), isTimeSignature(), isTitle(), isWork()
Inherits from: RTPhraseMarker, RTAtom, RTToken
>>> from music21 import *
>>> phrase = romanText.RTPhraseBoundary('||')
>>> phrase
<RTPhraseBoundary '||'>
Inherits from: RTAtom, RTToken
Inherits from: RTAtom, RTToken
>>> from music21 import *
>>> repeat = romanText.RTRepeat('||:')
>>> repeat
<RTRepeat '||:'>
Inherits from: RTRepeat, RTAtom, RTToken
>>> from music21 import *
>>> repeat = romanText.RTRepeatStart()
>>> repeat
<RTRepeatStart u'||:'>
Inherits from: RTRepeat, RTAtom, RTToken
>>> from music21 import *
>>> repeat = romanText.RTRepeatStop()
>>> repeat
<RTRepeatStop u':||'>
Inherits from: RTToken
In romanText, some data elements are tags, that is a tag name, a colon, optional whitespace, and data. In non-RTTagged elements, there is just data.
All tagged tokens are subclasses of this class. Examples are:
Title: Die Jahrzeiten Composer: Fanny Mendelssohn
>>> from music21 import *
>>> rttag = romanText.RTTagged('Title: Die Jahrzeiten')
>>> rttag.tag
'Title'
>>> rttag.data
'Die Jahrzeiten'
>>> rttag.isTitle()
True
>>> rttag.isComposer()
False
RTTagged attributes
Attributes without Documentation: tag, data
Attributes inherited from RTToken: src
RTTagged methods
- isAnalyst()¶
No documentation.
- isComposer()¶
>>> from music21 import * >>> rth = romanText.RTTagged('Composer: Claudio Monteverdi') >>> rth.isComposer() True >>> rth.isTitle() False >>> rth.isWork() False >>> rth.data 'Claudio Monteverdi'
- isForm()¶
No documentation.
- isKeySignature()¶
KeySignatures are a type of tagged data found outside of measures, such as”Key Signature: Bb,” meaning one flat.
Note: this is not the same as a key definition found inside of a Measure: these are represented by RTKey objects, defined below, and are not RTTagged objects, but RTAtom subclasses.
- isMovement()¶
No documentation.
- isNote()¶
No documentation.
- isPedal()¶
No documentation.
- isPiece()¶
No documentation.
- isProofreader()¶
No documentation.
- isTimeSignature()¶
TimeSignature header data can be found intermingled with measures.
- isTitle()¶
No documentation.
- isWork()¶
The “work” is not defined as a header tag, but is used to represent all tags, often placed after Composer, for the work or pieces designation.
>>> from music21 import * >>> rth = romanText.RTTagged('Madrigal: 4.12') >>> rth.isTitle() False >>> rth.isWork() True >>> rth.tag 'Madrigal' >>> rth.data '4.12'Methods inherited from RTToken: isAtom(), isMeasure()
Stores each linear, logical entity of a RomanText.
A multi-pass parsing procedure is likely necessary, as RomanText permits variety of groupings and markings.
>>> from music21 import *
>>> rtt = romanText.RTToken('||:')
>>> rtt
<RTToken '||:'>
RTToken attributes
Attributes without Documentation: src
RTToken methods
- isAnalyst()¶
No documentation.
- isAtom()¶
Atoms are any untagged data; generally only found inside of a measure definition.
- isComposer()¶
No documentation.
- isForm()¶
Occasionally found in header.
- isKeySignature()¶
No documentation.
- isMeasure()¶
No documentation.
- isMovement()¶
No documentation.
- isNote()¶
No documentation.
- isPedal()¶
No documentation.
- isPiece()¶
No documentation.
- isProofreader()¶
No documentation.
- isTimeSignature()¶
No documentation.
- isTitle()¶
No documentation.
- isWork()¶
No documentation.