Skip to content

Commit f457a2b

Browse files
authored
Merge pull request #1634 from malcolmsailor/add-2-digit-figures
TSV converter bug fix: don't add 'd' prefix to 2-digit added tones like `[add13]`
2 parents fdb126c + 8b76a3f commit f457a2b

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

music21/romanText/tsvConverter.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,21 @@ def _changeRepresentation(self) -> None:
256256
if self.dcml_version == 2:
257257
self.chord = self.chord.replace('%', 'ø')
258258
self.chord = handleAddedTones(self.chord)
259+
# prefix figures for Mm7 chords on degrees other than 'V' with 'd'
259260
if (
260261
self.extra.get('chord_type', '') == 'Mm7'
261262
and self.numeral != 'V'
262263
):
263-
# we need to make sure not to match [add4] and the like
264-
self.chord = re.sub(r'(\d+)(?!])', r'd\1', self.chord)
264+
# However, we need to make sure not to match [add13] and
265+
# the like, otherwise we will end up with [addd13]
266+
self.chord = re.sub(
267+
r'''
268+
(\d+) # match one or more digits
269+
(?![\]\d]) # without a digit or a ']' to the right
270+
''',
271+
r'd\1',
272+
self.chord,
273+
flags=re.VERBOSE)
265274

266275
# Local - relative and figure
267276
if isMinor(self.local_key):
@@ -869,7 +878,10 @@ def _m21ToTsv_v2(self) -> list[list[str]]:
869878
relativeroot = characterSwaps(
870879
relativeroot, isMinor(local_key), direction='m21-DCML'
871880
)
872-
thisEntry.chord = thisRN.figure # NB: slightly different from DCML: no key.
881+
# We replace the "d" annotation for Mm7 chords on degrees other than
882+
# V because it is not used by the DCML standard
883+
# NB: slightly different from DCML: no key.
884+
thisEntry.chord = thisRN.figure.replace('d', '', 1)
873885
thisEntry.pedal = None
874886
thisEntry.numeral = thisRN.romanNumeral
875887
thisEntry.form = getForm(thisRN)

music21/romanText/tsvEg_v2major.tsv

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@ mc mn mc_onset mn_onset timesig staff voice volta label globalkey localkey pedal
1010
99 99 1/2 1/2 3/4 4 1 Ger6/vi C V Ger6/vi Ger vii o 65 b3 V/vi Ger 0 0 -1, 3, 0, 9 9 -1
1111
121 121 0 0 3/4 4 1 V/vi C i V/vi V vi M 0 1 -3, 1, -2 -3 -3
1212
125 124 1/16 1/16 2/4 4 1 Fr6 F vi Fr6 Fr V 43 b5 V Fr 0 1 -4, 0, 2, 6 2 -4
13-
142 141 0 0 4/4 #VII+/vi C I #VII+/vi #VII + vi + 0 0
13+
141 140 0 0 4/4 #VII+/vi C I #VII+/vi #VII + vi + 0 0
14+
142 141 0 0 4/4 VI43 G iii VI43 VI 43 vi Mm7 0 0
15+
143 142 0 0 4/4 VI43(13) G iii VI43(13) VI 43 13 vi Mm7 0 0
16+
144 143 0 0 4/4 V13 G I V13 V 13 Mm7 0 0

0 commit comments

Comments
 (0)