Skip to main content

A Cython wrapper of the Faust interpreter and signal processing library with RtAudio support.

Project description

cyfaust

The cyfaust project provides a minimal, modular, self-contained, cross-platform cython wrapper of the Faust DSP language and the RtAudio cross-platform audio driver.

  • Dual Backends: Interpreter (default, ~8MB) or LLVM JIT (~71MB, faster execution)
  • Box API: Fully wrapped with both functional and object-oriented interfaces
  • Signal API: Fully wrapped with both functional and object-oriented interfaces
  • Platform Support: macOS, Linux, and Windows
  • Build Variants: Dynamic (libfaust.so|dylib) and static (libfaust.a|lib)
  • Faust Version: 2.83.1

Installation

pip install cyfaust

Features

  • Python-oriented cross-platform implementation of the Faust DSP language

  • Two backend options:

    • Interpreter (default): Compact ~8MB binary, good for development and most use cases
    • LLVM JIT: ~71MB binary with native code compilation for maximum performance
  • Provides the following submodules (in the default build):

    • cyfaust.interp: wraps the faust interpreter and the rtaudio audio driver

    • cyfaust.box: wraps the faust box api

    • cyfaust.signal: wraps the faust signal api

    • cyfaust.common: common utilities and classes

  • Self-contained, minimal, and modular design

  • Default build uses interpreter backend to keep binary size low (~8MB vs ~71MB with LLVM)

  • Can generate code using the following backends:

    • c++
    • c
    • rust
    • codebox
  • Can generate auxiliary files such as svg block diagrams of dsp

  • Dual functional/oo design for box and signal apis with minimal code duplication.

  • Implements Memorviews for read/write buffer using numpy or array.array.

  • Both dynamic and static build variants can be packaged as a self-contained python wheel.

  • Includes several github workflows to automate the testing and building of cyfaust wheels for a number of supported platforms

  • Command-line interface for common operations

Command-Line Interface

cyfaust provides a CLI accessible via the cyfaust command or python -m cyfaust:

cyfaust <command> [options]
# or: python -m cyfaust <command> [options]

Commands

version - Show cyfaust and libfaust version information:

cyfaust version

info - Display DSP metadata, inputs, outputs, and dependencies:

cyfaust info synth.dsp

compile - Compile Faust DSP to target backend (cpp, c, rust, codebox):

cyfaust compile synth.dsp -b cpp -o synth.cpp
cyfaust compile synth.dsp -b rust -o synth.rs

expand - Expand Faust DSP to self-contained code with all imports resolved:

cyfaust expand filter.dsp -o filter_expanded.dsp
cyfaust expand filter.dsp --sha-only  # output only SHA1 key

diagram - Generate SVG block diagrams:

cyfaust diagram synth.dsp -o output_dir

play - Play a DSP file with RtAudio:

cyfaust play osc.dsp              # play until Ctrl+C
cyfaust play osc.dsp -d 5         # play for 5 seconds
cyfaust play osc.dsp -r 48000     # use 48kHz sample rate

params - List all DSP parameters (sliders, buttons, etc.):

cyfaust params synth.dsp

validate - Check a DSP file for errors:

cyfaust validate filter.dsp
cyfaust validate filter.dsp --strict  # treat warnings as errors

bitcode - Save/load compiled DSP as bitcode for faster loading:

cyfaust bitcode save synth.dsp -o synth.fbc
cyfaust bitcode load synth.fbc

json - Export DSP metadata as JSON:

cyfaust json instrument.dsp --pretty
cyfaust json instrument.dsp -o metadata.json

For detailed help on any command:

cyfaust <command> --help

Building

It has two build variants:

  1. The default build is dynamically linked to libfaust.dylib, libfaust.so or faust.dll depending on your platform and consists of a python package with multiple compiled submodules and embedded resources (faust libraries and architecture files):

    % tree -L 3
    .
    └── cyfaust
        ├── __init__.py
        ├── box.cpython-311-darwin.so
        ├── common.cpython-311-darwin.so
        ├── interp.cpython-311-darwin.so
        ├── signal.cpython-311-darwin.so
        └── resources
            ├── architecture
            └── libraries
    
  2. The static build is statically linked (with libfaust.a or libfaust.lib) and consists of a python package with a single compiled submodule and embedded resources (faust libraries and architecture files):

    % tree -L 3
    .
    └── cyfaust
        ├── __init__.py
        ├── cyfaust.cpython-311-darwin.so
        └── resources
            ├── architecture
            └── libraries
    

While this project was initially developed and tested primarily on macOS (x86_64, arm64), Linux (amd64, aarch64) and Windows (amd64) are now supported in recent releases.

See the project's TODO for remaining enhancements.

Setup and Requirements

cyfaust has a build management script, scripts/manage.py, which simplifies cross-platform project setup and builds and also build automation in the case of github workflows.

usage: manage.py [-h] [-v]  ...

cyfaust build manager

options:
  -h, --help     show this help message and exit
  -v, --version  show program's version number and exit

subcommands:
  valid subcommands

                 additional help
    build        build packages
    clean        clean detritus
    setup        setup prerequisites
    test         test modules
    wheel        build wheels

A brief guide to its use is provided in the following table:

# platform step command
1* common install prerequisites python3 scripts/manage.py setup --deps
2 common build/install faustlib python3 scripts/manage.py setup --faust
3 common build cyfaust (dynamic) python3 scripts/manage.py build
4 common build cyfaust (static) python3 scripts/manage.py build --static
5 common test cyfaust python3 scripts/manage.py test or pytest
6 common build cyfaust wheels python3 scripts/manage.py wheel --release
7 common test cyfaust wheels python3 scripts/manage.py wheel --test

[*] Prerequisites consists of general and platform-specific requirements.

The general requirements are:

  1. libfaust configured to be built with the c, c++, codebox, interp_comp, and rust backends and the executable, static and dynamic targets.

  2. libsndfile and libsamplerate for faust soundfile primitive support

Platform specific requirements are covered in the next sections.

Windows

To build cyfaust you will need python to be installed (3.10+), a c++ compiler such as visual studio community edition and make sure to install c++ and Windows SDK development support, as well as git, and cmake.

Then do something like the following in a terminal:

git clone https://github.com/shakfu/cyfaust.git
cd cyfaust
pip install -r requirements.txt # or python3 scripts/manage.py setup --deps
python scripts/manage.py setup --faust
# then pick from 3, 4 or 6. For example
python scripts/manage.py build
pytest
# etc..

macOS & Linux

On macOS and Linux, a Makefile is available as a frontend to the above manage.py script to make it a little quicker to use.

The following setup sequence is illustrative of this and is also useful if you want to setup cyfaust manually.

For macOS, having Xcode or the CommandLine tools (xcode-select --install) installed is required, and then you will need to have python and cmake installed. If you use Homebrew, this is simply:

brew install python cmake

For Linux, if you are on a Debian-derived system, you will need something like the following:

sudo apt update
sudo apt install build-essential git cmake python3-dev # you probably have these already
sudo apt install libasound2-dev patchelf # for alsa sound driver and fixing dynamic libs
sudo apt install libsndfile1-dev libsamplerate0-dev # specifically for faust

Then

git clone https://github.com/shakfu/cyfaust.git
cd cyfaust
make # or python3 scripts/manage.py setup --faust
  • This will download faust into the build directory, then configure (and patch) it for an interpreter build, build it, and install it into the following (.gitignored) folders in the project directory:

    • bin, containing the faust executables,
    • lib, the dynamic and static versions of libfaust and
    • share, the faust standard libs and examples.
  • Faust version 2.83.1 will be used as it is a stable reference to work with and is used by the setup scripts.

  • The script can be run again and will create (and overwrite) the corresponding files in the bin, include, lib and share folders.

To build the default dynamically-linked package and/or wheel:

make

or using uv (the project now uses scikit-build-core):

uv build --wheel

For a wheel:

make wheel

For the static variant, set the STATIC=1 environment variable with make, or use CMAKE_ARGS for direct builds:

make STATIC=1

or

CMAKE_ARGS="-DSTATIC=ON" uv build --wheel

LLVM Backend (cyfaust-llvm)

The LLVM backend compiles Faust DSP code to native machine code via LLVM JIT, offering significantly faster execution compared to the interpreter backend. It is distributed as a separate package: cyfaust-llvm.

Interpreter vs LLVM

Feature cyfaust (interpreter) cyfaust-llvm
Binary size ~8MB ~33MB
DSP execution Bytecode interpreter Native machine code
Compilation speed Fast Slower (JIT compilation)
Runtime performance Good Best
Use case Development, lightweight deployment Production, performance-critical

Installation

Install from PyPI:

pip install cyfaust-llvm

Both packages provide the same API via from cyfaust import cyfaust - only the backend differs.

Building from Source

Prerequisites

macOS:

# Install Xcode CommandLine tools if not already installed
xcode-select --install

# Install dependencies via Homebrew
brew install python cmake

Linux (Debian/Ubuntu):

sudo apt update
sudo apt install build-essential git cmake python3-dev
sudo apt install libasound2-dev patchelf
sudo apt install libsndfile1-dev libsamplerate0-dev
sudo apt install libtinfo-dev  # Required for LLVM
Build Steps (macOS & Linux)
  1. Clone the repository:

    git clone https://github.com/shakfu/cyfaust.git
    cd cyfaust
    
  2. Download the prebuilt LLVM-enabled libfaust:

    # Using make
    make faustwithllvm
    
    # Or using manage.py directly
    python3 scripts/manage.py setup --llvm
    

    This downloads libfaustwithllvm.a (~300MB) from the official Faust releases:

    • macOS: Downloads DMG for your architecture (arm64 or x86_64)
    • Linux: Downloads zip for your architecture (x86_64 or aarch64)
  3. Build for development:

    make build-llvm
    
  4. Run tests:

    make test-llvm
    
Building Wheels

To build a distributable wheel:

make wheel-llvm

This creates dist/cyfaust_llvm-<version>-<platform>.whl.

Or build directly with uv/cmake:

# First ensure libfaustwithllvm.a is downloaded
make faustwithllvm

# Generate static sources
python3 scripts/generate_static.py

# Build wheel
CMAKE_ARGS="-DSTATIC=ON -DLLVM=ON" uv build --wheel

# Rename to cyfaust-llvm (required for PyPI)
python3 scripts/rename_wheel.py dist/cyfaust-*.whl cyfaust-llvm --delete

Usage

The API is identical regardless of backend:

from cyfaust import cyfaust

# Create a DSP factory from Faust code
factory = cyfaust.create_dsp_factory_from_string(
    "volume",
    "process = *(hslider(\"gain\", 0.5, 0, 1, 0.01));"
)

# Create DSP instance
dsp = factory.create_dsp_instance()
print(f"Inputs: {dsp.get_num_inputs()}, Outputs: {dsp.get_num_outputs()}")

Detecting Backend at Runtime

import cyfaust

# Check which backend is available
print(f"LLVM Backend: {cyfaust.LLVM_BACKEND}")

if cyfaust.LLVM_BACKEND:
    # LLVM-specific: get target machine info
    print(cyfaust.get_dsp_machine_target())
    # e.g., 'x86_64-pc-linux-gnu' or 'arm64-apple-darwin24.6.0'

Platform Support

Platform Architecture Status
macOS arm64 (Apple Silicon) ✅ Supported
macOS x86_64 (Intel) ✅ Supported
Linux x86_64 ✅ Supported
Linux aarch64 ✅ Supported
Windows x86_64 🚧 Planned

To run the tests

make test

or

make pytest

Prior Art of Faust + Python

  • DawDreamer by David Braun: Digital Audio Workstation with Python; VST instruments/effects, parameter automation, FAUST, JAX, Warp Markers, and JUCE processors. Full-featured and well-maintained. Use this for actual work! (pybind11)

  • faust_python by Marc Joliet: A Python FAUST wrapper implemented using the CFFI (updated 2015). There's a more recent (updated in 2019) fork by Patrik Lechner. (cffi)

  • pyfaust by Alexandru Stan: Embed Faust DSP Programs in Python. (cffi)

  • faust-ctypes: a port of Marc Joliet's FaustPy from CFFI to Ctypes. (ctypes)

  • faustpp: A post-processor for faust, which enables more flexible code generation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

cyfaust_llvm-0.1.1-cp314-cp314-manylinux_2_39_x86_64.whl (37.2 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.39+ x86-64

cyfaust_llvm-0.1.1-cp314-cp314-macosx_11_0_arm64.whl (32.5 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

cyfaust_llvm-0.1.1-cp313-cp313-manylinux_2_39_x86_64.whl (37.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.39+ x86-64

cyfaust_llvm-0.1.1-cp313-cp313-macosx_15_0_arm64.whl (32.6 MB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

cyfaust_llvm-0.1.1-cp313-cp313-macosx_11_0_arm64.whl (32.5 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

cyfaust_llvm-0.1.1-cp312-cp312-manylinux_2_39_x86_64.whl (37.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.39+ x86-64

cyfaust_llvm-0.1.1-cp312-cp312-macosx_11_0_arm64.whl (32.5 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

cyfaust_llvm-0.1.1-cp311-cp311-manylinux_2_39_x86_64.whl (37.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.39+ x86-64

cyfaust_llvm-0.1.1-cp311-cp311-macosx_11_0_arm64.whl (32.5 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

cyfaust_llvm-0.1.1-cp310-cp310-manylinux_2_39_x86_64.whl (37.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.39+ x86-64

cyfaust_llvm-0.1.1-cp310-cp310-macosx_11_0_arm64.whl (32.5 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file cyfaust_llvm-0.1.1-cp314-cp314-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for cyfaust_llvm-0.1.1-cp314-cp314-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 5409cb598b625ec4bf5ce8953fc5496bdef1e763415cb337e57a4c50b633252c
MD5 b14731c32536ec33521a53628fb302f5
BLAKE2b-256 a76dc16fee8594f4e7e79261fe9f0fc4576f2e91c4493ec5abe3993c18166469

See more details on using hashes here.

File details

Details for the file cyfaust_llvm-0.1.1-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cyfaust_llvm-0.1.1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4f290b428fed383a3494cb9d9873b806c22e27c547955eff86c2381c5d546e8c
MD5 839a4f2f6610bed1d5d4f7dbae807837
BLAKE2b-256 2bb5f495507cfb0f572da2a4e5e3a8dab55de1861bc5f61a0576ac7228c58b1f

See more details on using hashes here.

File details

Details for the file cyfaust_llvm-0.1.1-cp313-cp313-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for cyfaust_llvm-0.1.1-cp313-cp313-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 353b55799311c2d3ccf3750b2cc01194bfd708df103f956e3042179ba92265c3
MD5 0e23499bfbb4f41c25c28b096b07d8ef
BLAKE2b-256 e71e8e081e92918a7f73541cfc92ac933d23da7438b7124f693a6453e6aaa6e1

See more details on using hashes here.

File details

Details for the file cyfaust_llvm-0.1.1-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for cyfaust_llvm-0.1.1-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 52f8bf9cbc996efa5b73cf5b6a5bf14572ba5012205f1dddace26d5ba49260f9
MD5 d3c3303e2d6cc16e7f77269ca21a329f
BLAKE2b-256 f5ab09ecfdee7ce8a44b03c8956a5cfcb4ef8a47e9c4fb25e08ef3268fb7916a

See more details on using hashes here.

File details

Details for the file cyfaust_llvm-0.1.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cyfaust_llvm-0.1.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ce8b5f7533f3ebc8e82c9ef59be1b7c48723f3f94dec3f0f55fb0c79d89345da
MD5 d7cb05168f410b356bf118a86b68f968
BLAKE2b-256 7a006092d377dd2fcf83679604a81d81e0513189a1afdce751380c4fe6d0eb33

See more details on using hashes here.

File details

Details for the file cyfaust_llvm-0.1.1-cp312-cp312-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for cyfaust_llvm-0.1.1-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 6ee5f97d647e3eee801962a003b7c3a6ce9b53d086845e116a98d09502a933fc
MD5 e3bd6986bd909b5c0cb34f0159209898
BLAKE2b-256 fbe7aeb08a61b1966a949ef553ccb534833ade7838b18ff910488cc002cae6e3

See more details on using hashes here.

File details

Details for the file cyfaust_llvm-0.1.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cyfaust_llvm-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 719e83cc30f7a8aeb3029d8c8dbe4dd74a51210876c23a27068f3987bcbf4efe
MD5 39b3a5768af6b0f285d320a2b8e59a23
BLAKE2b-256 4d8ad3fc576fcc7d1d1095878f7dbb8f06334124fb7146622463e0b48e251640

See more details on using hashes here.

File details

Details for the file cyfaust_llvm-0.1.1-cp311-cp311-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for cyfaust_llvm-0.1.1-cp311-cp311-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 ad02c6b2416490b267524d01c4a2ac0f7e97662a5af890f9f3618350dd9738de
MD5 69959ce0d6cc0a1c2eeaad9954089354
BLAKE2b-256 9e7716846b25e7455e2204fbdb49d653e4879ae10b38a45ac2827d3e32969b84

See more details on using hashes here.

File details

Details for the file cyfaust_llvm-0.1.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cyfaust_llvm-0.1.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 54be82059ed720ecfa66e46b34c9b43563680ae07f4e2c5e128353049ea1fc75
MD5 904ef372cad6c267b348e118dbeeea8c
BLAKE2b-256 7082c12051b5347b30d53cd41a261f6d527dc5e9d4fa6fbb4278fbe47ee08ffb

See more details on using hashes here.

File details

Details for the file cyfaust_llvm-0.1.1-cp310-cp310-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for cyfaust_llvm-0.1.1-cp310-cp310-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 c3d5316efdb474cd2cc06557b6701c4afbc046d7bc95106b3560c61f56e521f7
MD5 02a13e97a9ab5cf10c61f3093cec4adc
BLAKE2b-256 4fb95be3ccdf1e5b7d94d746ca5032d167a10cfcbc6637526f0d709fd2168824

See more details on using hashes here.

File details

Details for the file cyfaust_llvm-0.1.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cyfaust_llvm-0.1.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7da7998fc14fce071036c6164c6ead06c63e2d3e6c96b6a4ec471c21e87872e2
MD5 6e6cf3c056750da26d13535ccd0d4a80
BLAKE2b-256 bd8d1821970f730fe75c7d9b7a49770601d7fa8ec088f37aa147dc8a650e3d00

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page