+7
-7
@@ -166,7 +166,7 @@ class EventPlacement:
|
||||
|
||||
def continued_sources(notes):
|
||||
result = {p['tie_from'] for n in notes for p in n['pitches'] if 'tie_from' in p}
|
||||
result.update(f'{n["_continue_from"]}-s{s}' for n in notes if '_continue_from' in n for s, _ in generator.fretboard.STANDARD_TUNING)
|
||||
result.update(f'{n["_continue_from"]}_s{s}' for n in notes if '_continue_from' in n for s, _ in generator.fretboard.STANDARD_TUNING)
|
||||
return result
|
||||
|
||||
def has_attack(notes: list[dict]) -> bool:
|
||||
@@ -206,11 +206,11 @@ def attack_candidates(notes: list[dict], tones: dict[str, GuitarTone], active: d
|
||||
compatible = False
|
||||
break
|
||||
if '_continue_from' in note:
|
||||
previous = {p for i, p in active.items() if i.startswith(note['_continue_from'] + '-s')}
|
||||
previous = {p for i, p in active.items() if i.startswith(note['_continue_from'] + '_s')}
|
||||
if previous != set(added):
|
||||
compatible = False
|
||||
break
|
||||
assignment.update((f'{note["id"]}-s{p.string_number}', p) for p in added)
|
||||
assignment.update((f'{note["id"]}_s{p.string_number}', p) for p in added)
|
||||
choices.append(EventPlacement(note, tuple((p, exact_positions[p['id']]) for p in note['pitches']), added))
|
||||
if not compatible:
|
||||
continue
|
||||
@@ -220,7 +220,7 @@ def attack_candidates(notes: list[dict], tones: dict[str, GuitarTone], active: d
|
||||
shape = tuple(p for _, p in exact) + positions
|
||||
if len({p.string_number for p in shape}) != len(shape) or not generator.fretboard.within_fret_span(shape):
|
||||
continue
|
||||
assignment = tuple(sorted((*exact, *((f'{chord["id"]}-s{p.string_number}', p) for p in positions)))) if chord else exact
|
||||
assignment = tuple(sorted((*exact, *((f'{chord["id"]}_s{p.string_number}', p) for p in positions)))) if chord else exact
|
||||
choices = tuple(EventPlacement(n, tuple((p, exact_positions[p['id']]) for p in n['pitches']), positions if n is chord else ()) for n in notes)
|
||||
cost = voicing_cost(shape, profile, requirements.allowed, melody) if fresh else VoicingCost()
|
||||
yield AttackCandidate(assignment, choices, shape, cost)
|
||||
@@ -244,7 +244,7 @@ def guitar_events(document: dict) -> tuple[list, dict[str, GuitarTone]]:
|
||||
if source and '_harmony' in source:
|
||||
note['_continue_from'] = source['id']
|
||||
for string, _ in generator.fretboard.STANDARD_TUNING:
|
||||
tones[f'{source["id"]}-s{string}'].pitch['tie_to'] = f'{note["id"]}-s{string}'
|
||||
tones[f'{source["id"]}_s{string}'].pitch['tie_to'] = f'{note["id"]}_s{string}'
|
||||
elif not note['pitches']:
|
||||
note.pop('_harmony', None)
|
||||
note['kind'] = 'rest'
|
||||
@@ -264,7 +264,7 @@ def guitar_events(document: dict) -> tuple[list, dict[str, GuitarTone]]:
|
||||
tones[tone['id']] = GuitarTone(tone, absolute + onset + generator.model.fraction(tone['duration']), options)
|
||||
if '_harmony' in note:
|
||||
for string, _ in generator.fretboard.STANDARD_TUNING:
|
||||
tones[f'{note["id"]}-s{string}'] = GuitarTone({}, absolute + onset + generator.model.fraction(note['duration']), ())
|
||||
tones[f'{note["id"]}_s{string}'] = GuitarTone({}, absolute + onset + generator.model.fraction(note['duration']), ())
|
||||
if note['pitches'] or '_harmony' in note:
|
||||
events.append((absolute + onset, not bool(note.get('grace')), order if note.get('grace') else -1, note))
|
||||
absolute += generator.model.fraction(measure['duration'])
|
||||
@@ -328,7 +328,7 @@ def place_guitar(document: dict) -> None:
|
||||
tone['tablature'] = {'string': position.string_number, 'fret': position.fret}
|
||||
if definition := note.pop('_harmony', None):
|
||||
for pitch in generator.fretboard.chord_pitches(definition, choice.added):
|
||||
note['pitches'].append({**pitch, 'id': f'{note["id"]}-s{pitch["tablature"]["string"]}', 'duration': note['duration'], 'written': note['written']})
|
||||
note['pitches'].append({**pitch, 'id': f'{note["id"]}_s{pitch["tablature"]["string"]}', 'duration': note['duration'], 'written': note['written']})
|
||||
if note.get('_harmonize') and not choice.added and not note.get('_rhythm_continuation'):
|
||||
skipped.append(note['id'])
|
||||
selected = selected.previous
|
||||
|
||||
Reference in New Issue
Block a user