🧹 Refactor instruments to use BaseSynth abstract class#82
🧹 Refactor instruments to use BaseSynth abstract class#82Pitrat-wav wants to merge 1 commit intomainfrom
Conversation
- Created BaseSynth abstract class in src/logic/BaseSynth.ts - Refactored AcidSynth, FMBass, HarmSynth, PadSynth, DrumMachine, and SamplerInstrument to extend BaseSynth - Standardized initialization (init method), volume management (setVolume with rampTo), and disposal logic - Updated audioStore.ts to ensure instruments are initialized before connection - Updated GlobalSequencer.ts to use standardized setVolume method - Improved type safety and reduced code duplication across instrument logic Co-authored-by: Pitrat-wav <255843145+Pitrat-wav@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
This PR introduces a major architectural improvement by consolidating common instrument logic into a new
BaseSynthabstract class.Key Changes:
BaseSynthClass: Provides a unified interface for all instruments, including:initializedstate tracking.outputGainnode (supporting bothTone.VolumeandTone.Gain).setVolume(db: number)with smoothrampTointerpolation to prevent audible clicks.dispose()method for cascading resource cleanup.AcidSynth,FMBass,HarmSynth,PadSynth,DrumMachine, andSamplerInstrumentnow inherit fromBaseSynth. Internal Tone.js nodes are lazily initialized via a standardizedinit()method.audioStore.tsto callinit()for all instruments during the main audio setup, ensuring thatoutputGainnodes are ready before they are wired to the mixer channels.GlobalSequencer.tsnow interact with instruments through a more predictable and type-safe API, replacing direct property mutations with base class methods.Benefits:
BaseSynthcontract.PR created automatically by Jules for task 4338946224554170690 started by @Pitrat-wav