Skip to content

Conversation

Copy link

Copilot AI commented Nov 20, 2025

The generated processorCode for AudioWorkletProcessors included all runtime helpers (~60 kB) regardless of which features a DSP actually used. Most DSPs don't use MIDI, sensors, or soundfiles, making this dead code.

Changes

Core types

  • Added FaustFeatureFlags interface tracking hasMidi, hasAcc, hasGyr, hasSoundfiles, hasPoly
  • Extended FaustData to include features: FaustFeatureFlags

Feature detection

  • Added FaustBaseWebAudioDsp.detectFeatures() - walks DSP UI metadata to identify required features
  • Added FaustBaseWebAudioDsp.mergeFeatureFlags() - combines flags for poly+effect DSPs

Conditional code generation

  • Modified FaustDspGenerator to serialize only required runtime classes:
    • Core classes (FaustDspInstance, FaustBaseWebAudioDsp, FaustWasmInstantiator) always included
    • Soundfile/WasmAllocator only when hasSoundfiles
    • Sensor stack (FaustSensors, communicators) only when hasAcc or hasGyr
  • Updated dependency injection to match serialized classes

Runtime optimization

  • Modified FaustAudioWorkletProcessor to conditionally initialize sensor communicator
  • Gated sensor polling with feature checks

Result

Basic DSPs drop from ~60 kB to ~10 kB processorCode. DSPs using optional features include only what they need.

// Before: always serializes all 10 classes
// After: selective serialization based on detected features
const featureFlags = FaustBaseWebAudioDsp.detectFeatures(meta);
const runtimeCtors = [/* core classes */];
if (featureFlags.hasSoundfiles) {
    runtimeCtors.push(/* soundfile classes */);
}
Original prompt

Read the full discussion and create the solution.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Create solution based on discussion insights Reduce processorCode size via feature-based conditional code generation Nov 20, 2025
Copilot AI requested a review from sletz November 20, 2025 14:44
@sletz sletz marked this pull request as ready for review November 20, 2025 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants