Skip to content

Commit

Permalink
transpose key of RomanNumeral
Browse files Browse the repository at this point in the history
  • Loading branch information
malcolmsailor committed Sep 8, 2022
1 parent 00971f4 commit a40e41a
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions music21/roman.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@

# TODO: setting inversion should change the figure

T = t.TypeVar('T', bound='RomanNumeral')

# -----------------------------------------------------------------------------


Expand Down Expand Up @@ -3089,6 +3091,28 @@ def _updatePitches(self):
f'_updatePitches() was unable to derive pitches from the figure: {self.figure!r}'
) # pragma: no cover

def transpose(self, value, *, inPlace=False) -> t.Optional[T]:
'''
Overrides :meth:`~music21.harmony.Harmony.transpose` so that `key`
attribute is transposed as well.
>>> rn = roman.RomanNumeral('I', 'C')
>>> rn
<music21.roman.RomanNumeral I in C major>
>>> rn.transpose(4)
<music21.roman.RomanNumeral I in E major>
>>> rn.transpose(-4, inPlace=True)
>>> rn
<music21.roman.RomanNumeral I in A- major>
'''
post = super().transpose(value, inPlace=inPlace)
if not inPlace:
post.key = self.key.transpose(value, inPlace=False)
return post
else:
self.key.transpose(value, inPlace=True)
return None


# PUBLIC PROPERTIES #

Expand Down

0 comments on commit a40e41a

Please sign in to comment.