From 3babd9442e627ff66d9c271b37c413e18f61f3d7 Mon Sep 17 00:00:00 2001 From: Malcolm Sailor Date: Mon, 17 Jul 2023 14:10:56 -0600 Subject: [PATCH 1/4] don't match 'add13' when performing dominant 'd' substitution --- music21/romanText/tsvConverter.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/music21/romanText/tsvConverter.py b/music21/romanText/tsvConverter.py index 145722668b..168ca1984c 100644 --- a/music21/romanText/tsvConverter.py +++ b/music21/romanText/tsvConverter.py @@ -260,8 +260,15 @@ def _changeRepresentation(self) -> None: self.extra.get('chord_type', '') == 'Mm7' and self.numeral != 'V' ): - # we need to make sure not to match [add4] and the like - self.chord = re.sub(r'(\d+)(?!])', r'd\1', self.chord) + # we need to make sure not to match [add13] and the like + self.chord = re.sub( + r''' + (\d+) # match one or more digits + (?![\]\d]) # without a digit or a ']' to the right + ''', + r'd\1', + self.chord, + flags=re.VERBOSE) # Local - relative and figure if isMinor(self.local_key): From d3af7bff0da7a8287b6700673602adb8f5f6ed3c Mon Sep 17 00:00:00 2001 From: Malcolm Sailor Date: Sat, 19 Aug 2023 08:04:09 -0400 Subject: [PATCH 2/4] wip --- music21/romanText/tsvConverter.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/music21/romanText/tsvConverter.py b/music21/romanText/tsvConverter.py index 168ca1984c..8661808e5d 100644 --- a/music21/romanText/tsvConverter.py +++ b/music21/romanText/tsvConverter.py @@ -256,18 +256,20 @@ def _changeRepresentation(self) -> None: if self.dcml_version == 2: self.chord = self.chord.replace('%', 'ΓΈ') self.chord = handleAddedTones(self.chord) + # prefix figures for Mm7 chords on degrees other than 'V' with 'd' if ( self.extra.get('chord_type', '') == 'Mm7' and self.numeral != 'V' ): - # we need to make sure not to match [add13] and the like + # However, we need to make sure not to match [add13] and + # the like, otherwise we will end up with [addd13] self.chord = re.sub( r''' (\d+) # match one or more digits (?![\]\d]) # without a digit or a ']' to the right ''', - r'd\1', - self.chord, + r'd\1', + self.chord, flags=re.VERBOSE) # Local - relative and figure From 9b5e387f0f963469c4a08f24f577e792a4b0c514 Mon Sep 17 00:00:00 2001 From: Malcolm Sailor Date: Sat, 19 Aug 2023 09:50:07 -0400 Subject: [PATCH 3/4] update --- music21/romanText/tsvConverter.py | 5 ++++- music21/romanText/tsvEg_v2major.tsv | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/music21/romanText/tsvConverter.py b/music21/romanText/tsvConverter.py index 8661808e5d..8847e80b21 100644 --- a/music21/romanText/tsvConverter.py +++ b/music21/romanText/tsvConverter.py @@ -878,7 +878,10 @@ def _m21ToTsv_v2(self) -> list[list[str]]: relativeroot = characterSwaps( relativeroot, isMinor(local_key), direction='m21-DCML' ) - thisEntry.chord = thisRN.figure # NB: slightly different from DCML: no key. + # We replace the "d" annotation for Mm7 chords on degrees other than + # V because it is not used by the DCML standard + # NB: slightly different from DCML: no key. + thisEntry.chord = thisRN.figure.replace('d', '', 1) thisEntry.pedal = None thisEntry.numeral = thisRN.romanNumeral thisEntry.form = getForm(thisRN) diff --git a/music21/romanText/tsvEg_v2major.tsv b/music21/romanText/tsvEg_v2major.tsv index 2ab24733bd..7c14e02271 100644 --- a/music21/romanText/tsvEg_v2major.tsv +++ b/music21/romanText/tsvEg_v2major.tsv @@ -10,4 +10,7 @@ mc mn mc_onset mn_onset timesig staff voice volta label globalkey localkey pedal 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 121 121 0 0 3/4 4 1 V/vi C i V/vi V vi M 0 1 -3, 1, -2 -3 -3 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 -142 141 0 0 4/4 #VII+/vi C I #VII+/vi #VII + vi + 0 0 +141 140 0 0 4/4 #VII+/vi C I #VII+/vi #VII + vi + 0 0 +142 141 0 0 4/4 VI43 G iii VI43 VI 43 vi Mm7 0 0 +143 142 0 0 4/4 VI43(13) G iii VI43(13) VI 43 13 vi Mm7 0 0 +144 143 0 0 4/4 V13 G I V13 V 13 Mm7 0 0 From 8b76a3f69dbbe7044ef2eb93a061f9aa5f66b69e Mon Sep 17 00:00:00 2001 From: Malcolm Sailor Date: Sat, 19 Aug 2023 10:20:48 -0400 Subject: [PATCH 4/4] remove trailing ws --- music21/romanText/tsvConverter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/music21/romanText/tsvConverter.py b/music21/romanText/tsvConverter.py index 8847e80b21..ee873642a4 100644 --- a/music21/romanText/tsvConverter.py +++ b/music21/romanText/tsvConverter.py @@ -261,7 +261,7 @@ def _changeRepresentation(self) -> None: self.extra.get('chord_type', '') == 'Mm7' and self.numeral != 'V' ): - # However, we need to make sure not to match [add13] and + # However, we need to make sure not to match [add13] and # the like, otherwise we will end up with [addd13] self.chord = re.sub( r''' @@ -881,7 +881,7 @@ def _m21ToTsv_v2(self) -> list[list[str]]: # We replace the "d" annotation for Mm7 chords on degrees other than # V because it is not used by the DCML standard # NB: slightly different from DCML: no key. - thisEntry.chord = thisRN.figure.replace('d', '', 1) + thisEntry.chord = thisRN.figure.replace('d', '', 1) thisEntry.pedal = None thisEntry.numeral = thisRN.romanNumeral thisEntry.form = getForm(thisRN)