Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

write 'slow 3/8' etc. #1418

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 28 additions & 4 deletions music21/romanText/writeRoman.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,14 @@ def prepSequentialListOfLines(self):
tsThisMeasure = thisMeasure.getElementsByClass(meter.TimeSignature)
if tsThisMeasure:
firstTS = tsThisMeasure[0]
self.combinedList.append(f'Time Signature: {firstTS.ratioString}')
if (firstTS.ratioString in ('3/8', '6/8')
and firstTS.beatDivisionCountName == 'Simple'):
tsPrefix = 'slow '
else:
tsPrefix = ''
self.combinedList.append(
f'Time Signature: {tsPrefix}{firstTS.ratioString}'
)
if len(tsThisMeasure) > 1:
unprocessedTSs = [x.ratioString for x in tsThisMeasure[1:]]
msg = f'further time signature change(s) unprocessed: {unprocessedTSs}'
Expand Down Expand Up @@ -443,7 +450,8 @@ class Test(unittest.TestCase):
along with two test by modifying those scores.

Additional tests for the standalone functions rnString and intBeat and
for handling the special case of opus objects.
for handling the special case of opus objects, plus a test to verify
handling of 'slow' 6/8 and 3/8.
'''

def testOpus(self):
Expand Down Expand Up @@ -572,6 +580,24 @@ def testTypeParses(self):
rn = roman.RomanNumeral('viio6', 'G')
RnWriter(rn) # and even (perhaps dubiously) directly on other music21 objects

def test_slow_meters(self):
from io import StringIO
from itertools import product
import textwrap
from music21 import converter
for ts, fast_or_slow in product(('3/8', '6/8'), ('slow ', 'fast ', '')):
rntxt = textwrap.dedent(f'''Time Signature: {fast_or_slow}{ts}
m1 C: I
''')
text_stream = StringIO()
s = converter.parse(rntxt, format='romanText')
s.write('romanText', text_stream)
new_rntxt = text_stream.getvalue()
# Since the default is 'fast', it is not written out.
if fast_or_slow == 'fast ':
fast_or_slow = ''
self.assertIn(f'Time Signature: {fast_or_slow}{ts}', new_rntxt)

def testRepeats(self):
from music21 import converter
rntxt = textwrap.dedent('''
Expand All @@ -587,9 +613,7 @@ def testRepeats(self):
writer = RnWriter(s)
assert '\n'.join(writer.combinedList).strip().endswith(rntxt.strip())


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

def testRnString(self):

test = rnString(1, 1, 'G: I')
Expand Down