Files
product-vamp/generator/solo/policy.py
T
khodowany a0bd19b3ba Solo
2026-10-02 00:35:31 -05:00

57 lines
2.1 KiB
Python

"""One curated, deterministic composition policy; all times are quarter-note beats."""
from __future__ import annotations
import dataclasses
import hashlib
import json
@dataclasses.dataclass(frozen=True)
class Policy:
acoustic_activity: float = 1.125
electric_activity: float = 1.125
active_occupancy: float = 0.925
arrival_occupancy: float = 0.9
weights: tuple[tuple[str, float], ...] = (('activity', 4), ('occupancy', 4), ('landmarks', 3), ('register', 1), ('contour', 1), ('connection', 1), ('repetition', 1), ('movement', 0.5), ('harmonic_exposure', 2), ('draft_preservation', 3), ('development', 2), ('direction', 1), ('join_coherence', 2), ('ending_integration', 2))
beam_width: int = 64
extensions: int = 32
retrieval: int = 32
alternatives: int = 4
long_note: float = 2.0
stopping_note: float = 1.0
suspension_preparation: float = 0.5
suspension_resolution: float = 1.0
replan_attempts: int = 2
anchor_lines: int = 8
draft_frontier: int = 16
phrase_alternatives: int = 8
join_alternatives: int = 8
revision_sweeps: int = 2
revision_joins: int = 2
refinement_alternatives: int = 4
join_window: float = 2.0
activity_deadband: float = 1.0
occupancy_deadband: float = 0.1
lead_activity_range: tuple[float, float] = (1.0, 1.5)
lead_occupancy_range: tuple[float, float] = (0.85, 1.0)
source_variations: int = 8
chorus_frontier: int = 8
theme_copy_threshold: float = 0.8
theme_copy_beats: float = 8.0
theme_copy_attacks: int = 4
theme_seed_limit: int = 8
theme_unit_alternatives: int = 8
composition_version: str = 'thematic-recomposition-1'
# Preserve the former default root seeds while decoupling them from policy edits.
SEED_NAMESPACE = 'a85abb240d7cfa9d054375b654bcb5c23c746201fd4aed7acf81cb3f4ee720e1'
DEFAULT = Policy()
def describe():
values = dataclasses.asdict(DEFAULT)
identity = hashlib.sha256(json.dumps(values, sort_keys=True).encode()).hexdigest()
return {'fingerprint': identity, 'seed_namespace': SEED_NAMESPACE, 'parameters': values}
def stable_rank(seed, value):
return hashlib.sha256((seed + repr(value)).encode()).hexdigest()