Music21 class for dealing with Roman Numeral analysis
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'
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]
>>> 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]
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'
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]
RomanNumeral attributes
Attributes inherited from Chord: isChord, isNote, isRest
Attributes inherited from NotRest: stemDirection
Attributes inherited from Music21Object: classSortOrder, id
RomanNumeral properties
Properties inherited from Chord: pitches, chordTablesAddress, commonName, duration, forteClass, forteClassNumber, forteClassTn, forteClassTnI, hasZRelation, intervalVector, intervalVectorString, isPrimeFormInversion, midiEvents, midiFile, multisetCardinality, mx, normalForm, normalFormString, orderedPitchClasses, orderedPitchClassesString, pitchClassCardinality, pitchClasses, pitchNames, pitchedCommonName, primeForm, primeFormString, quality, scaleDegrees
Properties inherited from GeneralNote: color, lily, lyric, musicxml, quarterLength
Properties inherited from Music21Object: activeSite, beat, beatDuration, beatStr, beatStrength, classes, measureNumberLocal, 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) 3Methods inherited from Chord: annotateIntervals(), areZRelations(), bass(), canBeDominantV(), canBeTonic(), closedPosition(), containsSeventh(), containsTriad(), fifth(), findBass(), findRoot(), hasAnyRepeatedScale(), hasFifth(), hasRepeatedScaleX(), hasScaleX(), hasSeventh(), hasSpecificX(), hasThird(), inversion(), inversionName(), isAugmentedTriad(), isConsonant(), isDiminishedSeventh(), isDiminishedTriad(), isDominantSeventh(), isFalseDiminishedSeventh(), isHalfDiminishedSeventh(), isIncompleteMajorTriad(), isIncompleteMinorTriad(), isMajorTriad(), isMinorTriad(), isSeventh(), isTriad(), removeRedundantPitchClasses(), removeRedundantPitchNames(), removeRedundantPitches(), root(), scaleX(), seekChordTablesAddress(), semiClosedPosition(), seventh(), sortAscending(), sortChromaticAscending(), sortDiatonicAscending(), sortFrequencyAscending(), third(), transpose()
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()