from __future__ import annotations __version__ = "1.5.5" import json import streamlit.components.v1 as components def tone_player( chord_midi, instrument: str, mode: str, tempo_bpm: int, sustain_s: float, trigger_play: bool, ): """ v1.0.3 audio fix: - Piano uses Salamander samples via Tone.Sampler, but waits until loaded before triggering notes. - Includes button inside iframe for browser gesture. - Uses a deterministic component key to force refresh when chord/instrument changes. """ payload = { "midi": chord_midi, "instrument": instrument, "mode": mode, "tempo": int(tempo_bpm), "sustain": float(sustain_s), "autoplay": bool(trigger_play), } payload_json = json.dumps(payload) comp_key = f"tone_{instrument}_{mode}_{tempo_bpm}_{sustain_s}_" + "_".join(str(int(x)) for x in chord_midi) html = """