Skip to content

refactor: Consolidate instrument engine — unify SynthEngine, SamplerEngine, FM plugin #1031

@ChuxiJ

Description

@ChuxiJ

Description

Three parallel instrument implementations in different states of maturity:

  1. SynthEngine.ts — Legacy 6 hard-coded presets (not parameterizable)
  2. SamplerEngine.ts — Sample playback with ADSR (works)
  3. fmSynthPlugin.ts — FM synthesis as WAP plugin (works but isolated)

Proposed Architecture

InstrumentEngine (interface)
├── SubtractiveEngine — Maps SubtractiveTrackInstrument to Tone.js
├── SamplerEngine — Refactored to implement interface
├── FMSynthEngine — Extracted from WAP plugin
└── InstrumentFactory — Creates engine from TrackInstrument type

Acceptance Criteria

  • Unified InstrumentEngine interface: noteOn, noteOff, setParameter, dispose
  • All three types implement same interface
  • Legacy SynthEngine.createSynthForPreset() deprecated
  • Factory creates correct engine from discriminated union
  • Unit tests for each engine type

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions