This commit is contained in:
khodowany
2026-10-04 18:48:02 -05:00
parent 68df7292ee
commit 0e68f5364b
58 changed files with 1416 additions and 7567 deletions
+4 -35
View File
@@ -8,10 +8,10 @@ import generator.arrange.form
import generator.model
import generator.parts
import generator.solo.arrangement
from generator.solo import analysis, profiles, placement, themes, types, harmonic, gesture_rhythm, phrasing
from tests.test_solo import song
from tests.test_solo_development import note
from tests.test_solo_passages import choices
from generator.solo import analysis, profiles, placement, types, harmonic
from tests.solo_fixtures import song
from tests.solo_fixtures import note
from tests.solo_fixtures import choices
import tests.rhythm_fixtures
@@ -75,34 +75,3 @@ class SoloInstrumentAndIdentity(unittest.TestCase):
self.assertEqual(acoustic.melody_range,electric.melody_range)
self.assertEqual(acoustic.cost(acoustic.reference+4),0)
self.assertGreater(acoustic.cost(acoustic.reference+9),0)
def test_return_keeps_opening_instead_of_later_largest_turn(self):
notes=tuple(note(i,i+1,p,event_id=str(i)) for i,p in enumerate(('d','f','g','f','c','b')))
home=types.RealizedMotif('home','seed',notes,F(6),'introduce','contour',signature=notes[:4])
reference=themes.home_reference(home,'return')
self.assertEqual(reference.notes,notes[:4])
self.assertEqual(reference.treatment,'return')
self.assertEqual(len(themes.home_reference(home,'develop_contour').notes),3)
def test_endings_distinguish_local_cadence_and_handoff(self):
harmony=harmonic.Harmony(choices(('Em7b5','A7','Dm','Dm')))
self.assertEqual(phrasing.ending_effect(F(2),harmony),'local_settle')
self.assertEqual(phrasing.ending_effect(F(9),harmony),'cadential_arrival')
self.assertEqual(phrasing.ending_effect(F(15),harmony,True),'handoff')
anchor=types.Anchor('comma',F(1),F(1),note(0,1,'g').pitch,frozenset({7}),(41,76),F(2),'terminal','Em7b5',hold_until=F(3))
self.assertEqual(set(phrasing.next_destination(anchor,harmony)),{2,5,9})
def test_rhythm_revision_connects_without_changing_attacks_or_arrival(self):
notes=(note(0,1,'g',event_id='a'),note(F(3,2),2,'e',event_id='b'),note(F(5,2),3,'g',event_id='c'),note(3,6,'e',event_id='end'))
anchor=types.Anchor('end',F(3),F(3),notes[-1].pitch,frozenset({4}),(41,76),F(3),'terminal','C7',hold_until=F(6))
draft=types.MelodicDraft('gesture',F(),F(6),notes,(),(),(),(anchor,),None,'develop',sustained_tails=(types.SustainedTail(F(3),F(6),64),))
revised,edits=gesture_rhythm.revise(draft,harmonic.Harmony(choices(('C7','C7'))))
self.assertTrue(edits)
self.assertEqual(tuple(n.pitch for n in revised.notes),tuple(n.pitch for n in notes))
self.assertEqual(revised.notes[-1],notes[-1])
self.assertLess(gesture_rhythm.fragmentation(revised.notes),gesture_rhythm.fragmentation(notes))
protected=dataclasses.replace(draft,protected=tuple(n.event_id for n in notes))
self.assertEqual(gesture_rhythm.revise(protected,harmonic.Harmony(choices(('C7','C7'))))[0].notes,notes)
if __name__=='__main__':unittest.main()