Skip to content

Platforms

Platform base class, registry, and helper functions. Each platform implements generate_project(), build(), clean(), find_output().

base

Abstract base class for platform implementations.

Provides common functionality shared across all platforms.

PluginCategory

Bases: Enum

Plugin category based on I/O configuration.

EFFECT: has audio inputs (processes existing audio) GENERATOR: no audio inputs (synthesizes audio)

from_num_inputs staticmethod

from_num_inputs(num_inputs: int) -> PluginCategory

Detect category from number of audio inputs.

Platform

Bases: ABC

Abstract base class for platform implementations.

extension abstractmethod property

extension: str

File extension for built externals (e.g. '.pd_darwin', '.clap').

generate_project abstractmethod

generate_project(
    manifest: Manifest,
    output_dir: Path,
    lib_name: str,
    config: Optional[ProjectConfig] = None,
) -> None

Generate project files for this platform.

Parameters:

Name Type Description Default
manifest Manifest

Front-end-agnostic manifest with I/O, params, buffers.

required
output_dir Path

Directory to generate project in.

required
lib_name str

Name for the external library.

required
config Optional[ProjectConfig]

Optional ProjectConfig for platform-specific options.

None

build abstractmethod

build(
    project_dir: Path,
    clean: bool = False,
    verbose: bool = False,
) -> BuildResult

Build the project for this platform.

Parameters:

Name Type Description Default
project_dir Path

Path to the project directory.

required
clean bool

If True, clean before building.

False
verbose bool

If True, print build output.

False

Returns:

Type Description
BuildResult

BuildResult with build status and output file.

clean abstractmethod

clean(project_dir: Path) -> None

Clean build artifacts for this platform.

Parameters:

Name Type Description Default
project_dir Path

Path to the project directory.

required

find_output abstractmethod

find_output(project_dir: Path) -> Optional[Path]

Find the built external file.

Parameters:

Name Type Description Default
project_dir Path

Path to the project directory.

required

Returns:

Type Description
Optional[Path]

Path to the built external or None if not found.

get_build_instructions

get_build_instructions() -> list[str]

Get build instructions for this platform.

Returns:

Type Description
list[str]

List of command strings to show the user.

copy_voice_alloc_header

copy_voice_alloc_header(
    output_dir: Path, config: Optional[ProjectConfig] = None
) -> None

Copy voice_alloc.h to output_dir when polyphony is enabled (NUM_VOICES > 1).

Only copies when the config has a MIDI mapping with num_voices > 1.

copy_remap_header

copy_remap_header(output_dir: Path) -> None

Copy gen_remap_inputs.h to output_dir.

This header is always included by ext*.cpp bridges but compiles to nothing unless REMAP_INPUT_COUNT is defined, so it is safe to copy unconditionally.

generate_ext_header

generate_ext_header(
    output_dir: Path, platform_key: str
) -> None

Generate the standard ext{platform}.h header from shared template.

Used by platforms with the identical wrapper interface (all except PD, Max, and ChucK which have genuinely different headers).

generate_buffer_header

generate_buffer_header(
    template_path: Path,
    output_path: Path,
    buffers: list[str],
    header_comment: str = "Buffer configuration for gen_dsp wrapper",
) -> None

Generate gen_buffer.h from template.

This is a common operation across all platforms with identical logic.

Parameters:

Name Type Description Default
template_path Path

Path to the template file.

required
output_path Path

Path to write the generated header.

required
buffers list[str]

List of buffer names.

required
header_comment str

Comment to include in fallback generation.

'Buffer configuration for gen_dsp wrapper'

run_command

run_command(
    cmd: list[str], cwd: Path, verbose: bool = False
) -> subprocess.CompletedProcess[str]

Run a subprocess command with optional output streaming.

This provides a consistent way to run build commands across platforms.

Parameters:

Name Type Description Default
cmd list[str]

Command and arguments to run.

required
cwd Path

Working directory for the command.

required
verbose bool

If True, stream output in real-time.

False

Returns:

Type Description
CompletedProcess[str]

CompletedProcess with captured output.

cmake_platform

Intermediate base class for CMake-based platform implementations.

Provides shared build(), clean(), get_build_instructions(), and shared cache resolution that are identical across AU, CLAP, VST3, LV2, SC, and Max.

CMakePlatform

Bases: Platform

Base class for platforms that use CMake as their build system.

build

build(
    project_dir: Path,
    clean: bool = False,
    verbose: bool = False,
) -> BuildResult

Build project using CMake.

clean

clean(project_dir: Path) -> None

Clean build artifacts.

get_build_instructions

get_build_instructions() -> list[str]

Get build instructions for CMake-based platforms.

resolve_shared_cache

resolve_shared_cache(
    config: Optional[ProjectConfig] = None,
) -> tuple[str, str]

Resolve shared FetchContent cache settings from config.

Returns:

Type Description
str

Tuple of (use_shared_cache, cache_dir) where use_shared_cache

str

is "ON" or "OFF" and cache_dir is the path string (or empty).

platforms

Platform implementations for gen_dsp.

Each platform (PureData, Max/MSP, etc.) has its own implementation of the build and project generation logic.

The PLATFORM_REGISTRY provides dynamic lookup of platforms by name, making it easy to add new backends without modifying multiple files.

PLATFORM_REGISTRY module-attribute

PLATFORM_REGISTRY: dict[str, Type[Platform]] = {
    "pd": PureDataPlatform,
    "max": MaxPlatform,
    "chuck": ChuckPlatform,
    "au": AudioUnitPlatform,
    "clap": ClapPlatform,
    "vst3": Vst3Platform,
    "lv2": Lv2Platform,
    "sc": SuperColliderPlatform,
    "vcvrack": VcvRackPlatform,
    "daisy": DaisyPlatform,
    "circle": CirclePlatform,
    "webaudio": WebAudioPlatform,
    "standalone": StandalonePlatform,
    "csound": CsoundPlatform,
    "auv3": Auv3Platform,
}

get_platform

get_platform(name: str) -> Platform

Get a platform instance by name.

Parameters:

Name Type Description Default
name str

Platform identifier (e.g., 'pd', 'max').

required

Returns:

Type Description
Platform

Platform instance.

Raises:

Type Description
ValueError

If platform name is not recognized.

get_platform_class

get_platform_class(name: str) -> Type[Platform]

Get a platform class by name.

Parameters:

Name Type Description Default
name str

Platform identifier (e.g., 'pd', 'max').

required

Returns:

Type Description
Type[Platform]

Platform class (not instantiated).

Raises:

Type Description
ValueError

If platform name is not recognized.

list_platforms

list_platforms() -> list[str]

List all available platform names.

Returns:

Type Description
list[str]

Sorted list of platform identifiers.

list_cmake_platforms

list_cmake_platforms() -> list[str]

List platform names that use CMake (i.e. subclass CMakePlatform).

Returns:

Type Description
list[str]

Sorted list of CMake-based platform identifiers.

is_valid_platform

is_valid_platform(name: str) -> bool

Check if a platform name is valid.

Parameters:

Name Type Description Default
name str

Platform identifier to check.

required

Returns:

Type Description
bool

True if platform exists in registry.