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
setandanimate. - Extract cubic bezier calculation.
- Extract the updating of active automations and the semantics of preserving
tovalues afterdurationends. - Ensure the ability to obtain the actual
VoiceControlStateover time or iterate the state along the timeline. - Migrate
synthesizeScenarioto this runtime. - Migrate
ScenarioVisualizerto 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:
initialis 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.