Task: Extract VoiceScenario runtime into a shared module for synthesizer and visualizer

Extract VoiceScenario runtime into a shared module for synthesizer and visualizer

Eliminate duplication of VoiceScenario execution logic between synthesizeScenario and ScenarioVisualizer.

Task

Extract the common execution logic of VoiceScenario into a single runtime module and use it simultaneously in both the synthesizer and the visualizer.

Currently, the logic for prepareScenario, evaluateBezier, updateAutomations, executeCommand, and the computation of the current VoiceControlState is essentially duplicated. This creates a risk of divergence: the visualizer might display a state different from the one actually used by the DSP.

What needs to be done

  • Create a shared runtime module for VoiceScenario (e.g., VoiceSynthesizer/src/runtime.ts).
  • Extract the preparation of scenario composition and the general timeline there.
  • Extract the interpretation of set and animate.
  • Extract cubic bezier calculation.
  • Extract the updating of active automations and the semantics of preserving to values after duration ends.
  • Ensure the ability to obtain the actual VoiceControlState over time or iterate the state along the timeline.
  • Migrate synthesizeScenario to this runtime.
  • Migrate ScenarioVisualizer to the same runtime so that the chart reflects the actual state of the synthesizer rather than a separate interpretation of the scenario.
  • Preserve the existing semantics of scenario array composition: initial is present only on the first scenario, while subsequent ones continue the current state without a reset.

Acceptance Criteria

For the exact same VoiceScenario, the synthesizer and the visualizer use the exact same state machine implementation. After changing the runtime semantics, situations where the DSP executes a scenario one way and the visualizer displays it another way become impossible.