Generation
ci / checks (push) Successful in 1h10m52s

This commit is contained in:
khodowany
2026-09-26 17:26:22 -05:00
parent 11222a9f8c
commit c8581ea51a
11 changed files with 343 additions and 186 deletions
+4 -15
View File
@@ -63,7 +63,7 @@ def context(measure: dict, previous: dict | None) -> Context:
@functools.lru_cache(maxsize=4096)
def sounding_rhythm(bar, offset, intervals):
attacks = tuple(t - offset for t in bar.attacks() if any(a <= t - offset < b for a, b in intervals))
spans = tuple((max(event.onset - offset, a), min(event.onset + event.duration - offset, b)) for event in bar.events if event.sounding and event.onset + event.duration > offset for a, b in intervals if a <= max(event.onset - offset, 0) < b)
spans = tuple((max(event.onset - offset, a), min(event.onset + event.duration - offset, b)) for event in bar.events if event.sounding and not event.continuation and event.onset + event.duration > offset for a, b in intervals if a <= max(event.onset - offset, 0) < b)
return attacks, spans
def sounding_attacks(bar: generator.rhythm.Bar, item: Context) -> tuple[fractions.Fraction, ...]:
@@ -186,20 +186,11 @@ def realize(measure: dict, bar: generator.rhythm.Bar, previous: dict | None, *,
continue
chord = active_chord(measure, start, previous) if source.sounding else None
continuation = source.continuation and source.onset - item.offset == start
preceding = previous
if continuation:
for change in measure['harmonies']:
if generator.model.fraction(change['onset']) >= start:
break
preceding = change
if not same_chord(chord, preceding):
chord = None
chord = None
sounding_end = end
if chord and lane == 'electric':
if continuation:
chord = None
else:
sounding_end = min(end, start + 1)
sounding_end = min(end, start + 1)
for change in measure['harmonies']:
time = generator.model.fraction(change['onset'])
if chord and start < time < sounding_end and not same_chord(chord, active_chord(measure, time, previous)):
@@ -210,8 +201,6 @@ def realize(measure: dict, bar: generator.rhythm.Bar, previous: dict | None, *,
event['_harmony'] = chord
if lane:
event.update(_guitar_profile='electric' if lane == 'electric' else 'acoustic', _guitar_lane=lane)
if continuation:
event['_rhythm_continuation'] = True
if source.beams and written and chord:
event['beams'] = [{'level': level, 'type': kind} for level, kind in source.beams]
events.append(event)
@@ -257,7 +246,7 @@ def prepare_basses(document: dict) -> None:
if not same_chord(chord, previous):
attack, current_bass = 0, root
explicit = 'bass' in chord or 'inversion' in chord
if any(n['_guitar_lane'] == 'bass' and not n.get('_rhythm_continuation') for n in group):
if any(n['_guitar_lane'] == 'bass' for n in group):
degrees = generator.harmony.degrees(chord)
current_bass = (root + generator.harmony.degree_semitones(5, degrees[5])) % 12 if not explicit and attack % 2 and 5 in degrees else root
attack += 1