Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit f457a2b
Merge: fdb126c 8b76a3f
Author: Michael Scott Asato Cuthbert <[email protected]>
Date:   Wed Aug 30 22:54:36 2023 -1000

    Merge pull request cuthbertLab#1634 from malcolmsailor/add-2-digit-figures

    TSV converter bug fix: don't add 'd' prefix to 2-digit added tones like `[add13]`

commit fdb126c
Author: malcolmsailor <[email protected]>
Date:   Sun Aug 27 10:42:42 2023 -0600

    Roman Numerals: Don't substitute `d` for `0` in `add10` (cuthbertLab#1635)

commit 8b76a3f
Author: Malcolm Sailor <[email protected]>
Date:   Sat Aug 19 10:20:48 2023 -0400

    remove trailing ws

commit 9b5e387
Author: Malcolm Sailor <[email protected]>
Date:   Sat Aug 19 09:50:07 2023 -0400

    update

commit d3af7bf
Author: Malcolm Sailor <[email protected]>
Date:   Sat Aug 19 08:04:09 2023 -0400

    wip

commit 3babd94
Author: Malcolm Sailor <[email protected]>
Date:   Mon Jul 17 14:10:56 2023 -0600

    don't match 'add13' when performing dominant 'd' substitution

commit 8baa273
Merge: 2a28ab1 9f35bbb
Author: Michael Scott Asato Cuthbert <[email protected]>
Date:   Thu Jul 13 14:07:36 2023 -1000

    Merge pull request cuthbertLab#1629 from TimFelixBeyer/patch-5

commit 9f35bbb
Author: Tim Beyer <[email protected]>
Date:   Thu Jul 13 23:56:39 2023 +0200

    fix flake

commit 4c5ee5f
Author: Tim Beyer <[email protected]>
Date:   Tue Jul 11 23:46:22 2023 +0200

    Remove use of hasElement

commit 8141355
Author: TimFelix <[email protected]>
Date:   Sat Jul 8 20:28:08 2023 +0200

    Remove uses of `hasElement`

commit d43ec76
Author: Tim Beyer <[email protected]>
Date:   Sat Jul 8 20:16:18 2023 +0200

    Speed up __contains__ by 2x and deprecate `hasElement`
  • Loading branch information
TimFelixBeyer committed Sep 2, 2023
1 parent 27fef76 commit 6dae7e0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion music21/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ def purgeOrphans(self, excludeStorageStreams=True) -> None:
# if the site does not actually have this Music21Object in
# its elements list, it is an orphan and should be removed
# note: this permits non-site context Streams to continue
if s.isStream and not self in s:
if s.isStream and self not in s:
if excludeStorageStreams:
# only get those that are not Storage Streams
if ('SpannerStorage' not in s.classes
Expand Down
6 changes: 5 additions & 1 deletion music21/roman.py
Original file line number Diff line number Diff line change
Expand Up @@ -2415,7 +2415,7 @@ def __init__(

# immediately fix low-preference figures
if isinstance(figure, str):
figure = figure.replace('0', 'o') # viio7
figure = re.sub(r'(?<!\d)0', 'o', figure) # viio7 (but don't alter 10.)
figure = figure.replace('º', 'o')
figure = figure.replace('°', 'o')
# /o is just a shorthand for ø -- so it should not be stored.
Expand Down Expand Up @@ -4347,6 +4347,10 @@ def testZeroForDiminished(self):
self.assertEqual([p.name for p in rn.pitches], ['B', 'D', 'F', 'A-'])
rn = roman.RomanNumeral('vii/07', 'c')
self.assertEqual([p.name for p in rn.pitches], ['B', 'D', 'F', 'A'])
# However, when there is a '10' somewhere in the figure, don't replace
# the 0 (this occurs in DCML corpora)
rn = roman.RomanNumeral('V7[add10]', 'c')
self.assertEqual([p.name for p in rn.pitches], ['G', 'B-', 'B', 'D', 'F'])

def testIII7(self):
c = chord.Chord(['E4', 'G4', 'B4', 'D5'])
Expand Down
18 changes: 15 additions & 3 deletions music21/romanText/tsvConverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,21 @@ 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 [add4] and the like
self.chord = re.sub(r'(\d+)(?!])', r'd\1', self.chord)
# 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,
flags=re.VERBOSE)

# Local - relative and figure
if isMinor(self.local_key):
Expand Down Expand Up @@ -869,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)
Expand Down
5 changes: 4 additions & 1 deletion music21/romanText/tsvEg_v2major.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 6dae7e0

Please sign in to comment.