Skip to content

Add support for Faust plugins #150

Description

@kaoskorobase

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions