Faust plugin support — v1 design
Add support for Faust plugins via libfaust.
Scope: Desktop only (rtaudio/jack) for v1. iOS unsupported (runtime LLVM JIT is
prohibited on iOS); Android deferred. Gated behind a single CMake option, off where
libfaust is unavailable.
Model: Runtime libfaust. Faust factory ≈ Methcla SynthDef; DSP instance ≈ Synth.
Compile a factory once per .dsp; createDSPInstance / deleteDSPInstance per node.
Compilation: On the NRT worker thread. Blocking the serial NRT queue during a compile
is accepted for v1; RT audio is unaffected since the RT thread only ever sees an
already-built def.
Registration — two paths:
- Startup: scan plugin directories for
.dsp, compile + register during
single-threaded init. No race; cost is LLVM at init and slower startup.
- Runtime: new OSC verb (e.g.
/faust/compile) carrying .dsp source/path + target
URI. NRT compiles; the m_synthDefs insertion is bounced onto the RT/engine command
queue via sendFromWorker, so the unlocked map is mutated only in RT context.
Afterwards clients instantiate by URI via /synth/new like any synthdef.
Update semantics: Re-registering a URI replaces the def for future instantiations
only. No live hot-swap of running nodes in v1.
Safe retirement (no RT-thread deallocation of LLVM objects): Factory + heap
Methcla_SynthDef owned by an NRT-side registry — never by a node or a node-droppable
shared_ptr. Replaced defs move to a pending-retirement list with a live-instance
counter. Per-node destroy does deleteDSPInstance only. Each Faust synth, at
end-of-life, fires world_perform_command (RT→NRT; callback allocated from the RT pool)
to decrement the old def's count; NRT calls deleteDSPFactory once it reaches zero.
Existing code: faust/architecture/synth.cpp and src/Methcla/Faust.hpp are AOT-era,
written against the defunct MethclaSynth / MethclaHost C++ API and do not match the
current C Methcla_SynthDef plugin API. Not reusable as-is for the runtime path; remove
or shelve for a possible future AOT/iOS path.
Open items:
- Test-harness integration (
tests/plugins + engine_tests.cpp) — TBD.
- Exact
/faust/compile OSC arg schema (source string vs. file path, URI supply
Faust plugin support — v1 design
Add support for Faust plugins via
libfaust.Scope: Desktop only (rtaudio/jack) for v1. iOS unsupported (runtime LLVM JIT is
prohibited on iOS); Android deferred. Gated behind a single CMake option, off where
libfaust is unavailable.
Model: Runtime libfaust. Faust factory ≈ Methcla
SynthDef; DSP instance ≈Synth.Compile a factory once per
.dsp;createDSPInstance/deleteDSPInstanceper node.Compilation: On the NRT worker thread. Blocking the serial NRT queue during a compile
is accepted for v1; RT audio is unaffected since the RT thread only ever sees an
already-built def.
Registration — two paths:
.dsp, compile + register duringsingle-threaded init. No race; cost is LLVM at init and slower startup.
/faust/compile) carrying.dspsource/path + targetURI. NRT compiles; the
m_synthDefsinsertion is bounced onto the RT/engine commandqueue via
sendFromWorker, so the unlocked map is mutated only in RT context.Afterwards clients instantiate by URI via
/synth/newlike any synthdef.Update semantics: Re-registering a URI replaces the def for future instantiations
only. No live hot-swap of running nodes in v1.
Safe retirement (no RT-thread deallocation of LLVM objects): Factory + heap
Methcla_SynthDefowned by an NRT-side registry — never by a node or a node-droppableshared_ptr. Replaced defs move to a pending-retirement list with a live-instancecounter. Per-node
destroydoesdeleteDSPInstanceonly. Each Faust synth, atend-of-life, fires
world_perform_command(RT→NRT; callback allocated from the RT pool)to decrement the old def's count; NRT calls
deleteDSPFactoryonce it reaches zero.Existing code:
faust/architecture/synth.cppandsrc/Methcla/Faust.hppare AOT-era,written against the defunct
MethclaSynth/MethclaHostC++ API and do not match thecurrent C
Methcla_SynthDefplugin API. Not reusable as-is for the runtime path; removeor shelve for a possible future AOT/iOS path.
Open items:
tests/plugins+engine_tests.cpp) — TBD./faust/compileOSC arg schema (source string vs. file path, URI supply