Fix Generation
This commit is contained in:
@@ -53,11 +53,15 @@ class AcousticVoicingTests(unittest.TestCase):
|
||||
self.assertLessEqual(len(uppers), 1)
|
||||
grip = tuple(sorted({p for n in span.notes for p in shape(n)}, reverse=True))
|
||||
required, allowed, bass = generator.guitar.chord_requirements(span.harmony, 'acoustic')
|
||||
bass_classes = {bass}
|
||||
degrees = generator.harmony.degrees(span.harmony)
|
||||
if 'bass' not in span.harmony and 'inversion' not in span.harmony and 5 in degrees:
|
||||
bass_classes.add((bass + generator.harmony.degree_semitones(5, degrees[5])) % 12)
|
||||
if basses and uppers:
|
||||
self.assertIn(tuple(p.string_number for p in grip), generator.guitar.ACOUSTIC_STRINGS)
|
||||
self.assertTrue(set(required) <= {p.midi % 12 for p in grip} <= set(allowed))
|
||||
if basses:
|
||||
self.assertEqual(min(p.midi for p in grip) % 12, bass)
|
||||
self.assertIn(min(p.midi for p in grip) % 12, bass_classes)
|
||||
self.assertTrue(generator.guitar.within_fret_span(grip))
|
||||
self.assertTrue(all(0 <= p.fret <= 20 for p in grip))
|
||||
for note in span.notes:
|
||||
@@ -74,6 +78,25 @@ class AcousticVoicingTests(unittest.TestCase):
|
||||
generator.acoustic.combine(document)
|
||||
self.assertEqual(tests.test_acoustic.sounding(document), before)
|
||||
generator.model.validate_document(document)
|
||||
def test_simpler_fifth_bass_can_win_without_alternating(self):
|
||||
document = planned_document([[(0, 'Cdim7')], []])
|
||||
spans = self.place(document)
|
||||
self.assertEqual(len(spans), 1)
|
||||
bass = [p for n in spans[0].notes for p in shape(n) if p.string_number >= 5]
|
||||
self.assertTrue(bass)
|
||||
self.assertEqual({p.midi % 12 for p in bass}, {6})
|
||||
root_shapes = generator.guitar.chord_positions(*generator.guitar.chord_requirements(spans[0].harmony, 'acoustic'), profile='acoustic')
|
||||
selected = tuple(sorted({p for n in spans[0].notes for p in shape(n)}, reverse=True))
|
||||
self.assertLess(generator.guitar.voicing_cost(selected, 'acoustic'), min(generator.guitar.voicing_cost(s, 'acoustic') for s in root_shapes))
|
||||
def test_bass_options_follow_defined_fifth_and_explicit_basses(self):
|
||||
inversion = generator.harmony.parse_symbol('Cdim7') | {'inversion': 0}
|
||||
for chord, expected in (('C7', {0, 7}), ('Cdim7', {0, 6}), ('Caug', {0, 8}), ('Cno5', {0}), ('C7/E', {4}), (inversion, {0})):
|
||||
with self.subTest(chord=chord):
|
||||
span = generator.acoustic.harmony_spans(planned_document([[(0, chord)]]))[0]
|
||||
candidates = list(generator.guitar.acoustic_candidates(span))
|
||||
self.assertEqual({min(p.midi for p in c.shape) % 12 for c in candidates}, expected)
|
||||
required, allowed, _ = generator.guitar.chord_requirements(span.harmony, 'acoustic')
|
||||
self.assertTrue(all(set(required) <= {p.midi % 12 for p in c.shape} <= set(allowed) for c in candidates))
|
||||
def test_same_grip_survives_repeated_symbols_rest_bars_and_sections(self):
|
||||
attacks = [([(0, 1), (2, 1)], [(0, 1), (3, 1)]), ([], []), ([(2, 1)], [(1, 1), (3, 1)])]
|
||||
document = planned_document([[(0, 'C7')], [], [(0, 'C7'), (2, 'C7')]], attacks)
|
||||
@@ -95,7 +118,7 @@ class AcousticVoicingTests(unittest.TestCase):
|
||||
document = planned_document([changes], [([(i, 1) for i in range(4)], [(i, 1) for i in range(4)])])
|
||||
spans = self.place(document)
|
||||
self.assertEqual(len(spans), 4)
|
||||
self.assertEqual([min(p.midi for n in span.notes for p in shape(n)) % 12 for span in spans], [0, 4, 7, 0])
|
||||
self.assertEqual([min(p.midi for n in span.notes for p in shape(n)) % 12 for span in spans], [0, 4, 7, 6])
|
||||
def test_non_accompaniment_passage_ends_the_span(self):
|
||||
document = planned_document([[(0, 'C7')], [], []])
|
||||
measure = document['staves'][0]['measures'][1]
|
||||
|
||||
Reference in New Issue
Block a user