Fret Limit

This commit is contained in:
khodowany
2026-10-01 12:06:02 -05:00
parent 5414caf30a
commit a7b64c5361
16 changed files with 252 additions and 28 deletions
+4 -7
View File
@@ -101,17 +101,14 @@ class VoicingTests(unittest.TestCase):
crossing = grip((12, 13, 14, 14))
self.assertEqual(generator.guitar.voicing_cost(crossing).effort, 6)
self.assertEqual(generator.guitar.voicing_cost(crossing, 'electric').effort, 10)
def test_high_melody_keeps_its_exact_pitch_when_no_anchored_chord_fits(self):
def test_high_melody_fails_when_neither_anchored_chord_nor_single_note_fits(self):
document = tests.test_musicxml.parse(tests.test_musicxml.xml_score(tests.test_musicxml.xml_note('C', octave=6)))
note = tests.test_musicxml.notes(document)[0]
note.update(_harmony=generator.harmony.parse_symbol('CM'), _guitar_profile='electric', _harmonize=True)
before = copy.deepcopy(note['pitches'])
with self.assertLogs('generator.guitar', level='WARNING') as messages:
before = copy.deepcopy(document)
with self.assertRaisesRegex(ValueError, 'single notes need frets 1-12'):
generator.guitar.place_guitar(document)
self.assertIn('1 melody harmonizations kept as single notes', messages.output[0])
self.assertEqual([{k: v for k, v in p.items() if k != 'tablature'} for p in note['pitches']], before)
self.assertEqual(note['pitches'][0]['tablature'], {'string': 1, 'fret': 20})
generator.model.validate_document(document)
self.assertEqual(document, before)
def test_shape_and_movement_share_one_effort_cost(self):
shape = grip((1, 2, 3, 3))
self.assertEqual(generator.guitar.voicing_cost(shape).effort, 2)