17 lines
738 B
Python
17 lines
738 B
Python
from __future__ import annotations
|
|
|
|
from typing import List, Dict, Any
|
|
|
|
|
|
class Sonifier:
|
|
def map_to_cues(self, risk: float, allocation: Dict[str, float], constraints: Dict[str, Any] | None = None) -> List[Dict[str, Any]]:
|
|
cues: List[Dict[str, Any]] = []
|
|
# Simple mapping: higher risk -> alert cue, otherwise steady cue per asset
|
|
base_note = 60 # MIDI note C4
|
|
if risk > 0.6:
|
|
cues.append({"note": base_note + 12, "duration": 0.5, "type": "alert", "message": "High risk"})
|
|
for i, (asset, val) in enumerate(allocation.items()):
|
|
note = base_note + i
|
|
cues.append({"note": note, "duration": 0.25, "type": "beat", "asset": asset, "value": val})
|
|
return cues
|