Skip to content

Graph Adapter

Bridges dsp-graph compiled C++ to gen-dsp platform backends. Generates _ext_{platform}.cpp adapters, manifests, and simplified build files.

adapter

gen-dsp adapter: bridge dsp-graph output to gen-dsp platform backends.

Generates adapter C++ code that implements gen-dsp's _ext.h wrapper interface by delegating to the dsp-graph compiled API. Also generates a manifest.json compatible with gen_dsp.core.manifest.Manifest.

SUPPORTED_PLATFORMS module-attribute

SUPPORTED_PLATFORMS = set(keys())

generate_adapter_cpp

generate_adapter_cpp(graph: Graph, platform: str) -> str

Generate the _ext_{platform}.cpp adapter source.

This replaces the genlib-side wrapper with dsp-graph calls while keeping gen-dsp's platform-side code unchanged.

Parameters:

Name Type Description Default
graph Graph

Compiled DSP graph.

required
platform str

gen-dsp platform key (e.g. "chuck", "clap").

required

Returns:

Type Description
str

Complete C++ source as a string.

Raises:

Type Description
ValueError

If platform is not a recognised gen-dsp platform.

generate_manifest_obj

generate_manifest_obj(graph: Graph) -> 'Manifest'

Generate a Manifest dataclass from a DSP graph.

Parameters:

Name Type Description Default
graph Graph

The DSP graph.

required

Returns:

Type Description
'Manifest'

A gen-dsp Manifest instance.

generate_manifest

generate_manifest(graph: Graph) -> str

Generate a manifest.json compatible with gen-dsp's Manifest.

Parameters:

Name Type Description Default
graph Graph

The DSP graph.

required

Returns:

Type Description
str

JSON string.

compile_for_gen_dsp

compile_for_gen_dsp(
    graph: Graph, output_dir: str | Path, platform: str
) -> Path

Compile a graph and generate gen-dsp adapter files.

Writes three files to output_dir:

  • {name}.cpp -- compiled dsp-graph C++
  • _ext_{platform}.cpp -- gen-dsp adapter
  • manifest.json -- gen-dsp-compatible manifest

Parameters:

Name Type Description Default
graph Graph

The DSP graph.

required
output_dir str | Path

Where to write files.

required
platform str

gen-dsp platform key.

required

Returns:

Type Description
Path

Path to the output directory.

generate_graph_build_file

generate_graph_build_file(
    output_dir: Path,
    platform: str,
    lib_name: str,
    gen_name: str,
    num_inputs: int,
    num_outputs: int,
    num_params: int = 0,
    genext_version: str = "0.8.0",
    shared_cache: bool = False,
    midi_defines: str = "",
) -> Path

Generate a simplified build file for a dsp-graph project.

Unlike gen~ projects, dsp-graph projects have no genlib dependency, no gen/ subdirectory, and no json.c/json_builder.c sources. The compiled graph code is included via #include in the adapter.

Parameters:

Name Type Description Default
output_dir Path

Project directory.

required
platform str

gen-dsp platform key.

required
lib_name str

Plugin/external name.

required
gen_name str

Graph name (used in compile definitions).

required
num_inputs int

Number of audio inputs.

required
num_outputs int

Number of audio outputs.

required
num_params int

Number of parameters.

0
genext_version str

gen-dsp version string.

'0.8.0'
shared_cache bool

Whether to use shared FetchContent cache.

False
midi_defines str

Additional MIDI compile definitions.

''

Returns:

Type Description
Path

Path to the generated build file.