DSP instruments written in Faust. One source for each instrument, built for several hosts: SuperCollider UGens first, Pd externals and CLAP plugins later.
This repository holds the DSP sources and the scripts that make host code from them. The SuperCollider builds are here: a plugin to install in SuperCollider, and static UGen sources for engines that link the UGens into the server (see below). The other builds are not here yet.
| File | What it is |
|---|---|
woodbar.dsp |
A struck wooden bar: claves, wood stick, xylophone or marimba bar. Modal bar with the wood damping law and a Hertz-timed mallet. |
wood.lib |
Shared parts for the wooden instruments: damping law, mallet strike, noise modes. |
native/superpos/ |
IsoSuperPos, a granular UGen in hand-written C++: overlapping grains from a mono buffer, started at a moving read pointer, with random grain times (regularity, probability), a window shape (texture) and a level control by 1/√n (normalize) as in Mutable Instruments Clouds, and with per-grain detune, scatter and pan in stereo. With normalize 0 and the other controls at their defaults, its output is the same as a graph of SuperCollider's Impulse, Phasor and two-channel GrainBuf (see superpos_core.h). IsoSuperPosLive uses the same grain engine on a circular record buffer: it records its input (any signal: a bus, a UGen, a device input), with freeze, and its grains never read across the record head. See native/superpos/README.md. |
native/pulsar/ |
IsoPulsar, a pulsar synthesis UGen in hand-written C++: three trains of sine grains (the fundamental and two formants) in stereo, after the pulsar SynthDef of Alik Rustamoff's Musical sound design in SuperCollider. An energy input (usually an envelope from the SynthDef) sets the levels, the grain durations and the LFO rates, so the timbre follows the note. It processes only the grains that play, so it costs less CPU and much less real-time memory than the GrainSin SynthDef. reference/pulsar.dsp is the design in Faust; it is not in the release. See native/pulsar/Pulsar.md. |
Each GitHub release has a plugin for scsynth and supernova, with the class files and help pages: isospin-sc-<version>-linux-x86_64.zip, -macos-universal.zip (Apple silicon and Intel) or -windows-x86_64.zip. Needs SuperCollider 3.14 or later. Put the isospin folder of the zip into your extension folder (Platform.userExtensionDir.openOS; opens it), then recompile the class library. The README.md in the zip has the details, also for macOS, where the plugin is not notarized.
Compile with the Faust compiler. Give the repository as an include path, so that woodbar.dsp finds wood.lib:
faust -I . woodbar.dsp -o woodbar.cppYou can also paste woodbar.dsp and wood.lib into the Faust IDE.
scripts/build-sc-static.py makes C++ sources for UGens that are linked into the server binary, as SuperSonic needs (it cannot load plugins at run time). supercollider.toml lists the UGens. For each UGen the script runs Faust with the supercollider.cpp architecture and then scripts/faust-static-ugen.py, which gives each UGen its own names and a <Class>_Load function. The output also has the Faust headers, a CMake file with the source list and build settings (isospin.cmake) and a header with Isospin_Load() (isospin_sc_static.h). For sclang, the output has the class file of each UGen (classes/<Unit>.sc, for example classes/IsoWoodbar.sc). The script makes it from the Faust JSON description, with the same arguments and defaults as faust2sc.py.
The output also has a help page for each UGen (help/<Unit>.schelp). md2misc makes it from the Markdown file next to the UGen source: woodbar.md, native/superpos/SuperPos.md. For a Faust UGen, the build adds the arguments from the tooltips and ranges of the controls. The build stops if a page is missing, or if its arguments are not those of the class file.
Development build into a folder (writes only the files that changed):
python3 -I scripts/build-sc-static.py --out build/sc-staticRelease build (needs a clean working tree; the same commit and Faust version give the same bytes):
python3 -I scripts/build-sc-static.py --release 0.1.0 --tarball distPush a tag v<version> to release. The workflow .github/workflows/release.yml builds isospin-sc-static-<version>.tar.gz with Faust from a pinned nixpkgs, builds the plugin zips from it (see the next section), and attaches all of them and their .sha256 files to a GitHub release. flux-engine takes its UGens from these releases.
Needs Faust (the releases use 2.85.9) and Python 3.11 or later.
md2misc is a git submodule in external/md2misc. Clone with git clone --recurse-submodules, or run git submodule update --init. md2misc is GPL-3.0; it is a build tool and is not in the release.
With Nix, flake.nix gives a shell with the same Faust, Python and C++ compiler as CI (the same pinned nixpkgs), and just. Run nix develop, or nix develop -c <command> for one command. With direnv and nix-direnv, run direnv allow once; the shell then loads when you go into the folder.
scripts/build-sc-plugin.py builds the same sources as a loadable plugin, with CMake (sc-plugin/CMakeLists.txt): isospin for scsynth and isospin_supernova for supernova (.so on Linux, .scx on macOS and Windows), and installs a SuperCollider extension folder isospin/ with the plugins, the class files and the help pages. It takes a static build folder or a release tarball (--static) and the include folder of the SuperCollider source (--sc-include); without --static it makes a development build first. --zip DIR also writes isospin-sc-<version>-<platform>.zip. On macOS the plugin is one universal binary.
scripts/check-sc-plugin.py loads the extension folder in scsynth and supernova, as the only user extension, and renders each UGen in non-real-time mode. Each render must have sound and no bad values.
The workflow .github/workflows/sc-plugin.yml builds the plugin on Linux (Ubuntu 22.04, so glibc 2.35 or later), macOS and Windows (MSVC), and runs the load check on Linux and macOS. check.yml runs it on each pull request with a development build; release.yml runs it with the release tarball.
For your own use, just sc-plugin builds and checks the plugin in build/sc-plugin/isospin, and just sc-install links that folder into your user extension folder. After the next just sc-plugin, recompile the class library to use the new build. just sc-install stops if another copy of an isospin class is installed. Needs CMake 3.16 or later (in the Nix shell).
A UGen can also be hand-written C++ (a [[native]] table in supercollider.toml; the comments there give the fields). The release gets its sources without change. Keep the DSP core apart from the UGen wrapper: the core uses no SuperCollider headers, so that test programs can run it under the sanitizers. The wrapper includes isospin/sc_plugin_table.h, which makes the same source work in SuperSonic (more than one engine in a process) and with stock scsynth headers. Mark each core function that runs on the audio thread with ISOSPIN_NONBLOCKING from isospin/realtime.h: such a function must not allocate, lock or block, and the checks below test this. tests/fixtures/native/fixture is a small example.
scripts/check-native.py makes a development build and compiles every UGen source with GCC and with Clang, two ways each: against stock SuperCollider headers (linked into a loadable scsynth plugin) and against SuperSonic's headers with the defines of its engine. The hand-written sources compile with strict warnings, among them the warnings for implicit conversions that change a value or its precision. With Clang, -Wfunction-effects stops the build when a function marked ISOSPIN_NONBLOCKING calls a function that Clang cannot show to be nonblocking. Then, for the hand-written UGens, it:
- runs the tests with AddressSanitizer and UndefinedBehaviorSanitizer (with
float-cast-overflow) and the assertions of the hardened C++ standard library (_GLIBCXX_ASSERTIONS); - runs the tests again with RealtimeSanitizer, which stops a test when a marked function calls
malloc,free, a lock or another call that can block; - runs each libFuzzer target (
fuzzin the manifest) for a fixed time (--fuzz-time, default 30 s). libFuzzer is a coverage-guided fuzzer: it changes its inputs to reach new branches of the core. The corpus and any input that fails stay inbuild/fuzz/<target>/; - runs clang-tidy on the core and wrapper sources, with the checks of
.clang-tidy.
Each hand-written UGen has a fuzz test among its tests (native/superpos/test/superpos_fuzz.cpp, native/pulsar/test/pulsar_fuzz.cpp); the checks run it with seed 1, and <program> <sets> <seed> gives a longer run. The libFuzzer target of each UGen uses the same parameter sets and checks. By default the script uses tests/fixtures/supercollider.toml, which has a hand-written test UGen next to woodbar; --manifest supercollider.toml checks the release list. just fuzz [seconds] runs the libFuzzer targets of the release list for longer (default 600 s each).
Mutation testing checks how well the tests of a UGen catch wrong results: just mutation <name> runs Mull on the DSP core in a throwaway container (see tools/mutation/README.md). It is not part of the checks; CONTRIBUTING.md says when to run it.
python3 -I scripts/check-native.py \
--sc-include <SuperCollider source>/include \
--supersonic <SuperSonic source>scripts/check-help.py renders each help page with SCDoc (SuperCollider 3.14 or later) and compiles the code of the page. Without sclang it is skipped.
The workflow .github/workflows/check.yml runs both checks on each pull request (check-native.py for both lists), with the headers of SuperCollider 3.14.1 and SuperSonic v0.97.0. Needs GCC and Clang 20 or later with their sanitizers, and clang-tidy (from the same nixpkgs in CI, and in the Nix development shell).
AGPL-3.0-or-later. See LICENSE. scripts/faust-static-ugen.py is GPL-3.0-or-later. The generated UGen sources contain code from the Faust supercollider.cpp architecture (GPL-3.0-or-later) and copies of Faust headers (LGPL-2.1-or-later with the Faust architecture exception); the NOTICE.md in each release gives the details.