Generation
This commit is contained in:
@@ -3,10 +3,7 @@ from __future__ import annotations
|
||||
import dataclasses
|
||||
import fractions
|
||||
import functools
|
||||
import itertools
|
||||
|
||||
import generator.guitar
|
||||
import generator.harmony
|
||||
import generator.model
|
||||
import generator.rhythm
|
||||
|
||||
@@ -232,26 +229,3 @@ def connect_continuations(document: dict) -> bool:
|
||||
changed = True
|
||||
previous[voice['id']] = note
|
||||
return changed
|
||||
|
||||
def prepare_basses(document: dict) -> None:
|
||||
previous, attack, current_bass = None, 0, None
|
||||
for measure in document['staves'][0]['measures']:
|
||||
if measure.get('section_label'):
|
||||
previous, attack = None, 0
|
||||
notes = sorted((n for v in measure['voices'] for n in v['notes'] if n.get('_guitar_profile') == 'acoustic'), key=lambda n: generator.model.fraction(n['onset']))
|
||||
for _, group in itertools.groupby(notes, key=lambda n: generator.model.fraction(n['onset'])):
|
||||
group = list(group)
|
||||
chord = group[0]['_harmony']
|
||||
root = (generator.model.NATURAL[chord['root']['letter']] + generator.model.alteration(chord['root']['alter'])) % 12
|
||||
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' 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
|
||||
if explicit:
|
||||
current_bass = generator.guitar.chord_requirements(chord, 'acoustic')[2]
|
||||
for note in group:
|
||||
note['_bass_pc'] = current_bass
|
||||
previous = chord
|
||||
|
||||
Reference in New Issue
Block a user