Music21 class for dealing with Roman Numeral analysis
return a RomanNumeral object from the given chord in the given key.
>>> from music21 import *
>>> dim7chord = chord.Chord(["E2", "C#3", "B-3", "G4"])
>>> viio65 = roman.fromChordAndKey(dim7chord, key.Key('D'))
>>> viio65
'VII'
>>> roman.fromChordAndKey(["E-3","G4","B-5"], key.Key('D'))
'bII'
>>> roman.fromChordAndKey(["G#3","B#4","D#5"], key.Key('D'))
'#IV'
#>>> viio65.pitches # retains octave #[‘E2’, ‘C#3’, ‘B-3’, ‘G4’] #>>> viio65.figure #’viio65’
expands shorthand notation into comma notation
>>> from music21.roman import expandShortHand
>>> expandShortHand("64")
'6,4'
>>> expandShortHand("973")
'9,7,3'
>>> expandShortHand("11b3")
'11,b3'
>>> expandShortHand("b13#9-6")
'b13,#9,-6'
>>> expandShortHand("-")
'5,-3'
>>> expandShortHand("6/4")
'6,4'
Inherits from: Chord, NotRest, GeneralNote, Music21Object, JSONSerializer
>>> from music21 import *
>>> V = roman.RomanNumeral('V') # could also use 5
>>> V.quality
'major'
>>> V.inversion()
0
>>> V.forteClass
'3-11B'
>>> V.scaleDegree
5
>>> V.pitches # default key-- C Major
[G4, B4, D5]
>>> neapolitan = roman.RomanNumeral('N6', 'c#') # could also use "bII6"
>>> neapolitan.isMajorTriad()
True
>>> neapolitan.scaleDegreeWithAlteration
(2, <accidental flat>)
>>> neapolitan.pitches # default octaves
[F#4, A4, D5]
>>> neapolitan2 = roman.RomanNumeral('bII6', 'g#')
>>> neapolitan2.pitches
[C#5, E5, A5]
>>> neapolitan2.scaleDegree
2
>>> em = key.Key('e')
>>> dominantV = roman.RomanNumeral('V7', em)
>>> dominantV.pitches
[B4, D#5, F#5, A5]
>>> minorV = roman.RomanNumeral('V43', em, caseMatters = False)
>>> minorV.pitches
[F#4, A4, B4, D5]
>>> majorFlatSeven = roman.RomanNumeral('VII', em)
>>> majorFlatSeven.pitches
[D5, F#5, A5]
>>> diminishedSharpSeven = roman.RomanNumeral('vii', em)
>>> diminishedSharpSeven.pitches
[D#5, F#5, A5]
>>> majorFlatSix = roman.RomanNumeral('VI', em)
>>> majorFlatSix.pitches
[C5, E5, G5]
>>> minorSharpSix = roman.RomanNumeral('vi', em)
>>> minorSharpSix.pitches
[C#5, E5, G#5]
Either of these is the same way of getting a minor iii in a minor key:
>>> minoriii = roman.RomanNumeral('iii', em, caseMatters = True)
>>> minoriii.pitches
[G4, B-4, D5]
>>> minoriiiB = roman.RomanNumeral('IIIb', em, caseMatters = False)
>>> minoriiiB.pitches
[G4, B-4, D5]
Can also take a scale object, here we build a first-inversion chord on the raised-three degree of D-flat major, that is, F#-major (late Schubert would be proud...)
>>> sharp3 = roman.RomanNumeral('#III6', scale.MajorScale('D-'))
>>> sharp3.scaleDegreeWithAlteration
(3, <accidental sharp>)
>>> sharp3.pitches
[A#4, C#5, F#5]
>>> leadingToneSeventh = roman.RomanNumeral('viio', scale.MajorScale('F'))
>>> leadingToneSeventh.pitches
[E5, G5, B-5]
A little modal mixture:
>>> lessObviousDiminished = roman.RomanNumeral('vio', scale.MajorScale('c'))
>>> lessObviousDiminished.pitches
[A4, C5, E-5]
>>> diminished7th = roman.RomanNumeral('vio7', scale.MajorScale('c'))
>>> diminished7th.pitches
[A4, C5, E-5, G-5]
>>> diminished7th1stInv = roman.RomanNumeral('vio65', scale.MajorScale('c'))
>>> diminished7th1stInv.pitches
[C4, E-4, G-4, A4]
>>> halfDim7th2ndInv = roman.RomanNumeral('iv/o43', scale.MajorScale('F'))
>>> halfDim7th2ndInv.pitches
[F-4, A-4, B-4, D-5]
>>> alteredChordHalfDim3rdInv = roman.RomanNumeral('bii/o42', scale.MajorScale('F'))
>>> alteredChordHalfDim3rdInv.pitches
[F-4, G-4, B--4, D--5]
>>> alteredChordHalfDim3rdInv.intervalVector
[0, 1, 2, 1, 1, 1]
>>> alteredChordHalfDim3rdInv.commonName
'half-diminished seventh chord'
>>> alteredChordHalfDim3rdInv.romanNumeral
'-ii'
>>> alteredChordHalfDim3rdInv.romanNumeralAlone
'ii'
>>> openFifth = roman.RomanNumeral('V[no3]', key.Key('F'))
>>> openFifth.pitches
[C5, G5]
Some theoretical traditions express a viio7 as a V9 chord with omitted root. Music21 allows that:
>>> fiveOhNine = roman.RomanNumeral('V9[no1]', key.Key('g'))
>>> fiveOhNine.pitches
[F#5, A5, C6, E-6]
Just for kicks (no worries if this is goobley-gook):
>>> ots = scale.OctatonicScale("C2")
>>> rn = roman.RomanNumeral('I9', ots, caseMatters=False)
>>> rn.pitches
[C2, E-2, G-2, A2, C3]
>>> rn2 = roman.RomanNumeral('V7#5b3', ots, caseMatters = False)
>>> rn2.pitches
[G-2, A-2, C#3, E-3]
>>> r = roman.RomanNumeral('v64/V', key.Key('e'))
>>> r.figure
'v64/V'
>>> r.pitches
[C#5, F#5, A5]
>>> r2 = roman.RomanNumeral('V42/V7/vi', key.Key('C'))
>>> r2.pitches
[A4, B4, D#5, F#5]
RomanNumeral attributes
Attributes without Documentation: scale, impliedScale, caseMatters, scaleCardinality, figure
Attributes inherited from Chord: isChord, isNote, isRest, beams
Attributes inherited from NotRest: stemDirection
Attributes inherited from GeneralNote: articulations, expressions, editorial, lyrics
Attributes inherited from Music21Object: classSortOrder, hideObjectOnPrint, id, groups
RomanNumeral properties
Properties inherited from Chord: pitches, chordTablesAddress, commonName, duration, fifth, forteClass, forteClassNumber, forteClassTn, forteClassTnI, hasZRelation, intervalVector, intervalVectorString, isPrimeFormInversion, midiEvents, midiFile, multisetCardinality, mx, normalForm, normalFormString, orderedPitchClasses, orderedPitchClassesString, pitchClassCardinality, pitchClasses, pitchNames, pitchedCommonName, primeForm, primeFormString, quality, scaleDegrees, seventh, third, tie
Properties inherited from GeneralNote: color, lily, lyric, musicxml, quarterLength
Properties inherited from Music21Object: activeSite, beat, beatDuration, beatStr, beatStrength, classes, derivationHierarchy, measureNumber, offset, priority
Properties inherited from JSONSerializer: json
RomanNumeral methods
- bassScaleDegreeFromNotation(notationObject)¶
given a notationObject from music21.figuredBass.notation.Notation return the scaleDegree of the bass.
>>> from music21 import * >>> fbn = figuredBass.notation.Notation('6,3') >>> V = roman.RomanNumeral('V') >>> V.bassScaleDegreeFromNotation(fbn) 7 >>> fbn2 = figuredBass.notation.Notation('#6,4') >>> vi = roman.RomanNumeral('vi') >>> vi.bassScaleDegreeFromNotation(fbn2) 3
- setKeyOrScale(keyOrScale)¶
Provide a new key or scale, and re-configure the RN with the existing figure.
>>> from music21 import * >>> r1 = RomanNumeral('V') >>> r1.pitches [G4, B4, D5] >>> r1.setKeyOrScale(key.Key('A')) >>> r1.pitches [E5, G#5, B5] >>> r1 <music21.roman.RomanNumeral V in A major>Methods inherited from Chord: annotateIntervals(), areZRelations(), bass(), canBeDominantV(), canBeTonic(), closedPosition(), containsSeventh(), containsTriad(), findRoot(), getChordStep(), getTie(), getZRelation(), hasAnyRepeatedDiatonicNote(), hasRepeatedChordStep(), intervalFromChordStep(), inversion(), inversionName(), isAugmentedTriad(), isConsonant(), isDiminishedSeventh(), isDiminishedTriad(), isDominantSeventh(), isFalseDiminishedSeventh(), isHalfDiminishedSeventh(), isIncompleteMajorTriad(), isIncompleteMinorTriad(), isMajorTriad(), isMinorTriad(), isSeventh(), isTriad(), removeRedundantPitchClasses(), removeRedundantPitchNames(), removeRedundantPitches(), root(), seekChordTablesAddress(), semiClosedPosition(), semitonesFromChordStep(), setTie(), sortAscending(), sortChromaticAscending(), sortDiatonicAscending(), sortFrequencyAscending(), transpose()
Methods inherited from GeneralNote: addLyric(), augmentOrDiminish(), compactNoteInfo(), hasLyrics()
Methods inherited from Music21Object: addContext(), addLocation(), addLocationAndActiveSite(), freezeIds(), getAllContextsByClass(), getCommonSiteIds(), getCommonSites(), getContextAttr(), getContextByClass(), getOffsetBySite(), getSiteIds(), getSites(), getSpannerSites(), hasContext(), mergeAttributes(), purgeLocations(), removeLocationBySite(), removeLocationBySiteId(), searchParentByAttr(), setContextAttr(), setOffsetBySite(), show(), splitAtDurations(), splitAtQuarterLength(), splitByQuarterLengths(), unfreezeIds(), unwrapWeakref(), wrapWeakref(), write()
Methods inherited from JSONSerializer: jsonAttributes(), jsonComponentFactory(), jsonPrint(), jsonRead(), jsonWrite()