@@ -284,6 +284,17 @@ class Canonical:
|
||||
offset = sum((generator.model.fraction(m['duration']) for m, _, i in original_group if i < start), fractions.Fraction())
|
||||
if original_group[0][2] in self.patterns:
|
||||
pattern, anticipate = self.patterns[original_group[0][2]]
|
||||
if offset:
|
||||
# Fit the incoming context before slicing. A raw template sustain
|
||||
# may already have ended at a chord change; projecting it first
|
||||
# would resurrect that note as an unintended new downbeat attack.
|
||||
context = tuple((source if i == index else sources[i], prior if i == index else carried[i], i)
|
||||
for _, _, i in original_group if i <= end)
|
||||
incoming = generator.comping_rhythm.realize(pattern, context, self.part, self.melody, anticipate=anticipate, limit=offset + limit if limit is not None else None, boundary=True)
|
||||
if incoming is None:
|
||||
raise ValueError(f'source measure {source["number"]}: selected groove cannot fit incoming harmony')
|
||||
pattern = {**pattern, 'events': [{'onset': str(e.start), 'duration': str(e.end - e.start),
|
||||
'layer': e.lane, 'anticipate': e.harmonic_time is not None and e.lane in ('upper', 'electric')} for e in incoming.events]}
|
||||
pattern = generator.comping_rhythm.project(pattern, offset, tuple(generator.model.fraction(m['duration']) for m, _, _ in group))
|
||||
rhythm = generator.comping_rhythm.realize(pattern, group, self.part, self.melody, anticipate=anticipate, limit=limit, boundary=True)
|
||||
if rhythm is None:
|
||||
|
||||
Reference in New Issue
Block a user