Contributing
In general, libraries are organised in a stacked manner: the base ones define functions or constants without any dependencies, and additional ones are gradually built on top of simpler ones, layer by layer. Dependency loops must be avoided as much as possible. The resources folder contains tools to build and visualise the libraries dependencies graphs.
If you wish to add a function to any of these libraries or if you plan to add a new library, make sure that you observe the following conventions:
New Functions
- All functions must be preceded by a markdown documentation header respecting the following format (open the source code of any of the libraries for an example):
//-----------------`(pr).functionName`--------------------
// Description
//
// #### Usage
//
// ```
// Usage example
// ```
//
// Where:
//
// * `param1`: parameter 1 description
// * `param2`: parameter 2 description
//
// #### Example
//
// ```
// Additional example
// ```
//
// #### Test
// ```
// functionName_test = some_dsp_code;
// ```
//
// #### References
//
// * <https://some_url1>
// * <https://some_url2>
//-------------------------------------------------
- The
functionNamemust be prefixed by thelibraryNamename prefix, like(pr)in the example. - The title must name every symbol the block documents, exactly, each in its own backquotes:
`(pr).name`, or`(pr).name1`, `(pr).name2`for a block that documents several functions. The tooling does not recognize a title with a space inside the backquotes, an argument list after the name, or a sibling only mentioned in the description: each of them leaves the symbol undocumented formake check-doc. The generic form`(pr).name[N]`matches digit suffixes only (name1toname9), not letter variants. - The environment system (e.g.
os.osc) should be used when calling a function declared in another library (see the section on Library Import). - Try to reuse existing functions as much as possible.
- The
Usageline must show the input/output shape (the number of inputs and outputs) of the function, likegen : _for a mono generator,_ : filter : _for a mono effect, etc. TheWhere:section then allows each parameter to be described individually, using the appropriate surrounding quotes. - The
Usageline is compiled (make check-usage, andmake check-docfor the libraries you changed): it must be a Faust expressioninputs : call : outputswhose buses match the arity of the call,_ : wgr(f,r) : _,_and not_ : wgr(f,r) : _for a filter with two outputs. Its parameters take the values of the same call in the#### Testsection, so name them as in the call, and document each of them, under the same name, inWhere:. A parameter that sets a channel count belongs in the buses:si.bus(N) : f(N) : si.bus(N),_ : bank(N) : par(i,N,_). Write a variable channel count with...on a bus only (_,_, ... : f(N) : _,_, ...); a...in an argument list,etc., a shell command or a sentence is not Faust: put it in the description or in#### Example.scripts/check_usage.py --symbol pr.functionNameprints what is compiled. - In the
Usageline, write the names of the function's own library without their prefix (_ : lowpass(N,fc) : _infilters.lib,bus(N)insignals.lib): the title already gives it. Names of other libraries keep theirs (si.bus(N)infilters.lib).make check-usagerejects a Usage that writes its own prefix. - Name the inputs that have a meaning, and document each of them in
Where::expm1(x) : _,hypot(x,y) : _,ADAA1(EPS, f, F1, x) : _say more than_ : expm1 : _, and Faust accepts the call form for any function (f(x)isx : f). Keep the anonymous_for the audio input of an effect (_ : lowpass(N,fc) : _) and for buses (si.bus(N)). Whenmake check-usagereports aWhere:bullet that the Usage does not use, and the bullet documents an input, name that input in the call: do not delete the bullet. - The
Exampleline can be used to provide additional examples. - The
Testline is used to add a DSP program to test the function. The test name must befunctionName_test. The actual code can be extracted and independently tested using the-pncompiler option (to specify the name of the dsp entry-point instead of process). The test code is a standalone program: it uses the library prefixes (fi.lowpass, notlowpass) and imports all the needed libraries, likean = library("analyzers.lib");if a function from analyzers.lib is used in the test code. - Tests are written in the library first. Every test, for a new function or to pin a bug fix or a behavior change, goes into the
#### Testsection of the function's block, then is copied verbatim, under the same name, into the matchingtests/*.dspfile.tests/*.dspmirrors the.libfiles, never the other way around: a test that exists only there is invisible in the documentation and the JSON export, and drifts from them. A fix that changes behavior comes with a test whose output the old definition gets wrong.scripts/lib_tests.py add xx.lib new_tests.dspinserts new tests in both places at once. - Test names must be unique across all of
tests/*.dsp, since each one becomestests/reference/<name>.ref, and must not differ from an existing name only by letter case: the.reffiles would collide on a case-insensitive filesystem (macOS). Prefix with the library's short name (mm_,tu_,inst_) when the natural name is taken. - A test must produce a nonzero output: a gate defaulting to 0 or a slider defaulting to silence makes an all-zero reference, which validates nothing (see
make check-weakbelow). - The
Referencesline can be used to add links to references. - Some functions use parameters that are constant numerical expressions. The convention is to label them in capital letters and document them preferably to be constant numerical expressions (or known at compile time in existing libraries).
- Functions with several parameters should better be written by putting the more constant parameters (like control, setup...) at the beginning of the parameter list, and audio signals to be processed at the end. This allows to do partial-application. So prefer the following
clip(low, high, x) = min(max(x, low), high);form whereclip(-1, 1)partially applied version can be used later on in different contexts, better thanclip(x, low, high) = min(max(x, low), high);version. - Every time a function is added or its documentation changes, regenerate the documentation pages with
make -C doc build, which rebuildsdoc/docs/libs/*.mdfrom the doc blocks, then the symbol indexdoc/docs/libs/index.md, then the site (see Documentation).
Layering UI-ready variants
Many functions benefit from two public faces so the same DSP can serve both low-level reuse and ready-to-tweak usage:
- Core function: exposes all parameters, no UI or side effects; best for reuse, composition, and testing.
- UI wrapper: fixes sensible defaults and exposes only runtime-tuned parameters as UI controls; leaves signals that must be provided externally as arguments.
Use the UI-free core for correctness and performance work; build the UI variant when you need something directly tweakable in examples or end-user contexts.
A generic core/UI pair could be:
// Core: parameters explicit, no UI
coreEffect(paramA, paramB, mix) =
fooProcessing(mix, wet)
with {
wet = *(paramA) : barProcessing(paramB); // barProcessing is your DSP
};
// UI wrapper: binds smoothed controls to the core
coreEffect_ui =
coreEffect(paramA_ui, paramB_ui, mix_ui)
with {
paramA_ui = hslider("Param A", 1.0, 0.0, 2.0, 0.01) : si.smoo;
paramB_ui = hslider("Param B", 0.5, 0.0, 1.0, 0.01) : si.smoo;
mix_ui = hslider("Mix", 1.0, 0.0, 1.0, 0.01) : si.smoo;
};
process = coreEffect_ui;
This keeps the core reusable (no UI dependencies) and the wrapper ready for immediate tweaking; process points to the UI layer for quick testing.
Instrument-specific three-layer pattern
Instrument models often add a third, ready-to-play layer. The clarinet model is a reference:
pm.clarinetModel(tubeLength, pressure, reedStiffness, bellOpening): core DSP with every parameter explicit and no UI.pm.clarinetModel_ui(pressure): wraps the core and adds UI sliders for tube length, reed stiffness, bell opening, and output gain; keepspressureas an argument.pm.clarinet_ui_MIDI: builds a playable instrument by pairing the core with a blower/envelope plus MIDI-mapped UI (pitch bend, sustain, vibrato, gain, etc.).
When adding similar models, start with the UI-free core, add a minimal UI wrapper, then optionally provide a controller-specific wrapper (MIDI or otherwise). Keep the core independent so it remains reusable.
Variables and identifiers scoping
To avoid name clashes between libraries, keep identifiers as local as possible. Prefer defining intermediate constants and helpers inside with { ... } blocks or environment { ... } sections, and only expose the intended public entry points. This minimizes collisions when several libraries are imported together and keeps global namespace usage limited to documented, public-facing functions.
When a helper cannot live inside a with/environment block (for instance
because several public functions share it), prefix its name with an
underscore: _helperName. The underscore marks it as internal: it is not
part of the library's public API, needs no documentation block, is excluded
from the documentation coverage accounting (scripts/audit2.py,
make check-doc), and may change or disappear without notice. Do not use
underscore-prefixed symbols from another library.
Hiding or renaming a symbol that is public by accident (undocumented, but
reachable) does not remove the old name at once: it survives one published
release as a deprecated alias, grouped at the end of the file
(declare oldname deprecated "...renamed _name"; then oldname = _name;, or
a frozen copy of the old body when the definition moved into a with). Before
hiding anything, check that no other library, no documented example and no
explicit substitution (os[SAFE=1;]) uses it: any of those makes the symbol
public in practice, and it should be documented instead.
Inside a library, call its own functions by their bare name, never
through the library's own prefix (lowpass(N,fc) in filters.lib, not
fi.lowpass(N,fc)). Functions of other libraries keep their prefix
(ma.PI in filters.lib). Two reasons:
fi.lowpasswritten infilters.libdoes not point to the definition of the same file: it reloads the library as a new environment. That copy ignores a substitution made by the user, a documented mechanism (os[SAFE=1;].phasor). With a libraryzz.libholdingGAIN = 1; bare = _ * GAIN; prefixed = _ * zz.GAIN;, the programlibrary("zz.lib")[GAIN = 2;]gets 2 forbareand 1 forprefixed.- The reloaded copy is the first
filters.libfaust finds, in the current directory before the-Iones: when a modified copy of the library is tested outside the repository, or when several versions are installed, the function can call another version of itself.
The prefix stays required where the code is a standalone program: the
#### Test sections, the examples and tests/*.dsp (ho.encoder(1, x, a)),
which is also where code gets copied. A parameter or a local definition
must not reuse the name of a public function of the library it lives in,
since it would hide that function from the bare calls. Ten libraries
still define their own prefix (fi = library("filters.lib"); in
filters.lib, and likewise in analyzers, basics, debug, hoa,
maths, misceffects, noises, phaflangers and signals). Their code
no longer uses it since November 2026; the line stays for the programs
that import("filters.lib") and write fi.lowpass, which removing it
would break. Do not use it in library code.
New Libraries
- Any new "standard" library should be declared in
stdfaust.libwith its own environment (2 letters - seestdfaust.lib) and inall.lib. - Some of the new library functions should be demonstrated in demos.lib.
- Any new "standard" library must be added to
doc.lib, the list of files from whichdoc/Makefilegenerates the documentation pages. - Functions must be organized by sections.
- Any new library should at least
declareanameand aversion. - Any new library has to use a prefix declared in the header section with the following kind of syntax:
Its official prefix is 'qu'(look at an existing library to follow the exact syntax). - Be sure to add the appropriate kind of
ma = library("maths.lib");import library line, for each external library function used in the new library (for instancema.foothat would be used somewhere in the code). - The comment based markdown documentation of each library must respect the following format (open the source code of any of the libraries for an example):
//############### libraryName ##################
// Description
//
// * Section Name 1
// * Section Name 2
// * ...
//
// It should be used using the `[...]` environment:
//
// ```
// [...] = library("libraryName");
// process = [...].functionCall;
// ```
//
// Another option is to import `stdfaust.lib` which already contains the `[...]`
// environment:
//
// ```
// import("stdfaust.lib");
// process = [...].functionCall;
// ```
//##############################################
//================= Section Name ===============
// Description
//==============================================
Coding Conventions
In order to have a uniformized library system, we established the following conventions (that hopefully will be followed by others when making modifications to them).
Function Naming
The libraries historically mix snake_case and camelCase in roughly equal
proportion, sometimes inside a single file. Renaming existing public symbols
is not an option (it breaks user code), so the rule applies to new code:
- a new function added to an existing library follows the dominant style of that library (and of the section it lands in, when the library is mixed);
- a new library picks one style in its header section and uses it consistently;
- internal helpers follow the underscore convention described in Variables and identifiers scoping.
For terminology, use the terms of the digital signal processing field (JOS proposal):
impulse: ...,0,1,0,...pulse: ...,0,1,1,0,... or longerimpulse_trainpulse_traingate= pulse controlled externally (e.g., by NoteOn,NoteOff)trigger= impulse controlled externally (gate - gate' > 0) == gate rising edge
Variable Argument List
Strictly speaking, there are no lists in Faust. But list operations can be simulated (in part) using the parallel binary composition operation , and pattern matching.
Thus functions expecting a variable number of arguments can use this mechanism, like a foo function that would be used this way: foo((a,b,c,d)). See fi.iir and fi.fir examples.
Documentation
- All the functions that we want to be "public" are documented.
- We used the
faust2md"standards" for each library://###for main title (library name - equivalent to#in markdown),//===for section declarations (equivalent to##in markdown) and//---for function declarations (equivalent to####in markdown - seebasics.libfor an example). - Sections in function documentation should be declared as
####markdown title. - Each function documentation provides a "Usage" section (see
basics.lib). - The full documentation is generated by
doc/Makefile(make -C doc helplists its commands). Commit the regenerated files with the library change that caused them, but never edit them by hand:doc/docs/libs/*.md, the library pages, anddoc/docs/libs/index.md, the symbol index built from those pages:make -C doc buildregenerates both, in that order, then the site.make -C doc mdalone leaves the index behind, so a new function is missing from it;doc/docs/standardFunctions.md:scripts/build_standard_functions.py;- the figures of
doc/docs/img/:make plots(see Figures).
- Each function can have
declare author "name";anddeclare copyright "XXX";declarations. - Every new function must carry a
declare functionName license "ID";line whoseIDis a canonical SPDX identifier -- e.g.MIT,GPL-3.0-only,LGPL-2.1-or-later,BSD-3-Clause,ISC, or the repository'sLicenseRef-STK-4.3andLicenseRef-LGPL-2.1-or-later-with-Faust-exceptionfor the two licenses without an SPDX-listed id. The accepted spellings are theCANONICAL/ALLOWEDtables ofscripts/normalize_licenses.py; runscripts/normalize_licenses.py --check(included inmake check-doc) to verify, and plainscripts/normalize_licenses.pyto fix legacy spellings. - Each library has a
declare version "xx.yy.zz";semantic version number to be raised each time a modification is done, and the globalversiontriplet inversion.libfollows — see Versioning for the exact rules.
Versioning
Version numbers live at two levels, and both follow semantic versioning:
- each library carries its own
declare version "MAJOR.MINOR.PATCH";, raised in the same commit as the change it describes; version.libholds the globalvl.versiontriplet for the library set as a whole, raised once per batch of changes according to the highest-ranking change since it was last raised.
Which component to raise:
- MAJOR — any backwards-incompatible change to the public API: removing or renaming a documented function, changing its arity, its parameter order or units, or its audible semantics; and in particular removing deprecated aliases at the end of their grace period.
- MINOR — backwards-compatible functionality: a new function or library, new optional behavior, documenting a previously undocumented symbol, or marking a function deprecated (the alias still works, so deprecation itself is not a breaking change).
- PATCH — backwards-compatible bug fixes and internal improvements: wrong coefficients or constants, performance work, documentation fixes, and any change confined to underscore-prefixed internal symbols (they are not API — see Variables and identifiers scoping).
The deprecation lifecycle ties into this: deprecating a name is MINOR,
and its removal must wait until at least one published release has
shipped with the declare ... deprecated warning, at which point the
removal is the MAJOR change of the next version. When in doubt about
whether a change is breaking, treat the documented behavior — the
function's doc block and its regression test — as the contract: if an
existing test reference has to be regenerated because the output changed,
the change is at least a bug fix worth calling out, and if callers must
edit their code, it is MAJOR.
Library Import
To prevent cross-references between libraries, we generalized the use of the library("") system for function calls in all the libraries. This means that every time a function declared in another library is called, the environment corresponding to this library needs to be called too. Each library declares at its top the environments it uses (ma = library("maths.lib");), with the prefixes that stdfaust.lib defines for programs:
aa = library("aanl.lib");
sf = library("all.lib");
an = library("analyzers.lib");
ba = library("basics.lib");
co = library("compressors.lib");
db = library("debug.lib");
de = library("delays.lib");
dm = library("demos.lib");
dx = library("dx7.lib");
en = library("envelopes.lib");
fa = library("fastmath.lib");
fd = library("fds.lib");
fi = library("filters.lib");
ho = library("hoa.lib");
hy = library("hysteresis.lib");
it = library("interpolators.lib");
la = library("linearalgebra.lib");
ma = library("maths.lib");
mi = library("mi.lib");
ef = library("misceffects.lib");
mo = library("motion.lib");
no = library("noises.lib");
os = library("oscillators.lib");
pf = library("phaflangers.lib");
pl = library("platform.lib");
pm = library("physmodels.lib");
pt = library("pinktrombone.lib");
qu = library("quantizers.lib");
rm = library("reducemaps.lib");
re = library("reverbs.lib");
ro = library("routes.lib");
sp = library("spats.lib");
si = library("signals.lib");
so = library("soundfiles.lib");
sy = library("synths.lib");
ve = library("vaeffects.lib");
vl = library("version.lib");
wa = library("webaudio.lib");
wd = library("wdmodels.lib");
For example, if we wanted to use the smooth function which is now declared in signals.lib, we would do the following:
import("stdfaust.lib");
process = si.smooth(0.999);
This standard is only used within the libraries: nothing prevents coders to still import signals.lib directly and call smooth without si., etc. It means symbols and function names defined within a library have to be unique to not collide with symbols of any other libraries.
"Demo" Functions
"Demo" functions are placed in demos.lib and have a built-in user interface (UI). Their name ends with the _demo suffix. Each of these function have a .dsp file associated to them in the Faust project examples folder.
Any function containing UI elements should be placed in this library and respect these standards.
"Standard" Functions
"Standard" functions are here to simplify the life of new (or not so new) Faust coders. They are listed in doc/docs/standardFunctions.md, generated from the libraries by scripts/build_standard_functions.py (make check-doc fails when it is stale), and allow to point programmers to preferred functions to carry out a specific task. For example, there are many different types of lowpass filters declared in filters.lib and only one of them is considered to be standard, etc.
Testing the library
Before preparing a pull-request, the new library must be carefully tested:
- all functions defined in the library must be tested by preparing a DSP test program, to be added using the
#### Testsyntax - the compatibility library
all.libimports all libraries in a same namespace, so check functions names collisions using the following test program:import("all.lib"); process = _; - reference files for all tests can be generated using the
make referencecommand and then verified with themake checkcommand, which compares the generated samples against the reference files within a specified tolerance. A good practice for developers is therefore to generate the reference files and re-run the checks whenever the code is modified.make checkfails on the first divergence; usemake -k checkto run the whole suite and collect every failure. It re-runs a test when a file the test loaded changed (its.dspand the librariesfaust -flistlists), or its reference, the harness or a build setting: there is no need to deletetests/outputafter editing a library, and tests that do not use that library are not run again. A missing reference fails:make checknever generates one, since the code under test would then be compared with itself. A failure means that the change altered the output: either a bug in the change or a deliberate fix. In the second case, say so explicitly and regenerate only the affected references: the references do not depend on the sources, on purpose, so delete the affected.reffiles, then runmake reference. - every new function therefore ships with both its
#### Testsection and the correspondingfunctionName_testentry in the tests folder, and its reference is generated withmake referencein the same change. - finally,
make check-docmust pass: it rejects any new undocumented symbol, any documentation block without a#### Usagesection, any block reduced to a#### Testsection, a staledoc/docs/standardFunctions.md, and any non-canonical license string, while the historical debt recorded intests/doc-baseline.jsonstays accepted. It also compiles the#### Usagesections of the libraries changed since the last commit (whenfaustis installed): a Usage whose buses do not match the arity of the call, or whose parameters differ from itsWhere:section, fails unless it is recorded intests/usage-baseline.json; a fix that makes an entry pass removes it in the same commit. Never regenerate a baseline to silence a failure you caused.make check-usagechecks every library. - a reference must check something.
make checkcompares within 1e-5, an absolute tolerance below 1: a channel that stays that close to zero passes against a silent output, and frames that stay that close to a constant pass against that constant.make check-weakreads every reference and flags a test whose channels all stay within the tolerance of zero (silent), a channel whose values all do (below-tolerance), a program with state whose output never changes (constant), an output that stops changing before the middle of the render (settles), and a test that has inputs (dead-input): the harnesses feed them with zeros, so drive the function from inside the test (no.noise : fn, notfn). Its first run, in October 2026, found 138 such tests among 2347, recorded with their reason intests/weak-baseline.json: a marimba whose strike cutoff of 1 Hz filters the excitation out, waveguide blocks fed with constants, a counter whose trigger is pressed once, mass-interaction links at constant positions.make check-docruns it when a library or a test changed. Check a new reference before committing it: a new test passesmake check-weakwithout an entry in the baseline. - new code must also be checked in single and double precision, from 44.1 to 192 kHz, as described below:
make checkcovers neither,make check-precisiondoes. - a function whose parameters are meant to vary at run time is tested with constant, slider and modulated parameters, as described below: the three run different code.
- bargraphs are part of the reference:
arch/print_arch.cppprints each of them after the outputs, on every line, and a program that has some runs in blocks of 64 frames, since a bargraph holds its value at the end of a block. A function that only measures (db.probe_*, a meter) is therefore checked like any other, bymake checkonly: the other harnesses read the audio outputs. - buttons and checkboxes are driven by the harnesses (
arch/print_arch.cppformake check,arch/precision_arch.cppformake check-precision): every button and checkbox is ON (1) for the first half of the rendered frames and OFF (0) for the second half. A gate is pressed then released, so a release, a note-off or a retrigger is exercised; a checkbox, a bypass for example, is rendered in both states, with the transition between them. Sliders and number entries keep their default value for the whole run. (Until October 2026 the buttons and checkboxes stayed ON for the whole run, so bypassed effects and releases were never tested, #281.)
Constant, slider, modulated and jump tests
The Faust compiler generates different code for a parameter depending on what it is:
| parameter | example | the coefficients that depend on it are computed |
|---|---|---|
| a constant | fi.resonlp(1000, 2, 1) |
once: folded at compile time, or at init when they depend on ma.SR |
| a control (slider) | fi.resonlp(hslider("fc", ...), ...) |
once per block, at the start of compute |
| a signal | fi.resonlp(1000*(1 + 0.5*lfo), ...) |
at every sample, inside the loop |
Precision, stability and CPU cost can differ between the three. A function that is correct with constants can lose precision when its coefficients are computed at run time in float. It can also blow up when they change at every sample, since a recursive structure that is stable for each frozen setting is not necessarily stable when that setting moves. And its cost per sample can double. The harnesses (make check, make check-precision, make check-cpu) render the tests as written, with the controls at their default values: they cannot turn a constant into a control or a signal. The test has to do it.
A function whose parameters are meant to vary at run time therefore has three tests, a recursive filter four, and a filter whose cutoff is modulated in synthesis five, written first in its #### Test section like any other (see New Functions). Typical parameters are a cutoff or center frequency, a resonance, a gain, an oscillator frequency, a delay length or a time constant.
functionName_test, constant parameters. This is the usual test.functionName_slider_test, parameters from sliders (hslider,vslider,nentry), without smoothing, with realistic default values. It checks that the function accepts run-time controls: a parameter that must be a constant makes it fail to compile. It checks the coefficients computed at run time in the program's precision: forfi.resonlp, the float/double level gap is 6.4e-5 with sliders against 1.8e-5 with constants. And it checks that they stay at control rate: its cost should match the constant test's. When it is clearly slower, the normalizer has moved part of the coefficient computation into the per-sample loop, which is what themin(x, ma.MAX)workarounds in the libraries prevent.functionName_modulated_test, a parameter modulated at every sample, over the part of its range where the function is under stress (low cutoffs, high resonance...). It checks the stability and the precision of the time-varying structure, and the cost of computing the coefficients at every sample: 6.32 ns/frame forfi.resonlpagainst 3.48 with constants. A slider followed bysi.smoois a signal too, so a_uiwrapper that smooths its controls belongs to this case, not the previous one.
Drive the modulation with an integer counter, not with os.osc or os.lf_*. Those accumulate their phase in the program's precision and drift in float: the precision check then measures the modulator, not the function. With a sine modulator, the level gap of the test below is 9 times larger (4.8e-4) and its sample gap 43 times larger (2.2e-2). ba.period counts in integers and gives a triangle that is the same in both precisions. Give it a period tied to the sample rate, P = int(ma.SR/10), so that the triangle runs at 10 Hz at every rate the precision check uses (with a fixed ba.period(4800) it would run at 40 Hz at 192 kHz). P and 1/P are computed once at init: the period adds no per-sample division.
resonlp_test = no.noise : fi.resonlp(1000, 2, 1);
resonlp_slider_test = no.noise : fi.resonlp(hslider("fc", 1000, 50, 5000, 1), hslider("Q", 2, 0.5, 20, 0.01), 1);
resonlp_modulated_test = no.noise : fi.resonlp(fc, 2, 1)
with {
P = int(ma.SR/10); // a tenth of a second, in samples, at every rate
tri = 1 - abs(2*ba.period(P)/P - 1); // 0 to 1 and back at 10 Hz, exact
fc = 50*pow(100, tri); // exponential sweep from 50 Hz to 5 kHz
};
functionName_jump_test, a parameter jumping between the two ends of its range, for recursive filters. It is what a user produces by moving a slider: the harnesses never move one, so the_slider_testnever jumps. A jump is where realizations differ most. A state-variable section leaks on an attenuated input after an abrupt cutoff change (#264); a direct form can leave its states far from the level the new coefficients expect, and its float and double outputs then diverge. The jump test is the_modulated_testwith its triangle replaced by a square wave at 5 Hz,sq = ba.period(2*P) < P, so that the parameter holds each end of the sweep for 0.1 s:
resonlp_jump_test = no.noise : fi.resonlp(50*pow(100, sq), 2, 1)
with {
P = int(ma.SR/10);
sq = ba.period(2*P) < P; // 0 or 1, switching every 0.1 s, exact
};
Delay lines with an integer length need none: a jump of length is the same discontinuity whatever the realization.
When it was introduced, every filter of filters.lib that has a _modulated_test got one, except ten that failed make check-precision, with level gaps of 1.1e-3 to 0.53. Eight of them, built on the direct-form fi.tf2s (resonlp, resonhp, resonbp, peak_eq, peak_eq_cq, highpass3e, highpass6e, highpass_plus_lowpass), got their jump tests when tf2s became two trapezoidal integrators (#273). peak_eq_rm, a direct-form fi.tf2 allpass, got its jump test when it became a trapezoidal state-variable filter. One still fails: wgr, which is already at the threshold with a constant 100 Hz. Every state-variable or TPT filter passes. wgr will get its jump test with a realization that passes it.
functionName_audio_modulated_test, the cutoff modulated at audio rate, for the filters whose cutoff is modulated in synthesis: a VCF whose cutoff follows an oscillator (filter FM) or a fast envelope. The 10 Hz_modulated_testcannot see what goes wrong there. A recursive structure that is stable for every frozen cutoff, and under slow sweeps, can grow without bound when its coefficients change by a large fraction within a period of its resonance: a direct-form section with Q = 10 does, in double precision too. One convention serves every such filter, so that their results compare:
resonlp_audio_modulated_test = 0.1*no.noise : fi.resonlp(max(20, 1000*(1 + 0.9*os.tosc(500))), 10, 1);
- The input is
0.1*no.noise, so that a resonance at Q = 10 stays well below full scale. - The cutoff is swept by ±90 % around 1 kHz, from 100 Hz to 1.9 kHz, by a 500 Hz sine.
os.toscis exact in both precisions;max(20, ...)keeps the cutoff positive if the depth is changed. - Q = 10 where the filter has a Q. A resonance on another scale keeps the value of the function's
_modulated_test(ve.moog_vcf(0.9, ...),ve.lowpassLadder4(3.9, ...)). Where Q = 10 is the self-oscillation threshold, the test stays below it:ve.korg35LPFandkorg35HPFuse 9.5, since at Q = 10 (K = 2) even the static filter at 1 kHz rings 7 to 18 times above its input level, and the test would measure an oscillator rather than the modulation. - The
vefilters with a normalized frequency (moogLadder,moogHalfLadder,diodeLadder,korg35LPF,korg35HPF,oberheim,sallenKey2ndOrder) mapnormFreqin [0, 1] to 20 Hz-20 kHz as2*10^(3*normFreq + 1). They get the same cutoff throughlog10(fc/20)/3;fc/20000would sweep them between 21 and 38 Hz.
moogLadder_audio_modulated_test = 0.1*no.noise : ve.moogLadder(log10(max(20, 1000*(1 + 0.9*os.tosc(500)))/20)/3, 10);
Besides passing make check-precision, compare the output peak with that of the same filter at a constant 1 kHz: a structure whose states follow the cutoff stays close to it. The tests in place, all within 0.9 to 1.41 times the static peak at 48 and 192 kHz, are those of fi.tf2s (a Q = 10 peaking section, so that every numerator tap is used), resonlp, resonhp, resonbp, the third-order Butterworth lowpass and highpass, and svf (its lp, bp and hp outputs); ve.moog_vcf, moog_vcf_2b, moog_vcf_2bn, moogLadder, lowpassLadder4, moogHalfLadder, diodeLadder, korg35LPF, korg35HPF, oberheim (its four outputs) and sallenKey2ndOrder (its three outputs). The wrappers are covered by the function they call (oberheimLPF, sallenKey2ndOrderLPF, svf_morph...).
The others do not get one:
fi.tf2s_dfand the*_tpt_dffunctions with a direct-form section are for fixed cutoffs only: under this modulation a Q = 10tf2s_dfsection diverges at every rate, in double precision too, and in direct form the third-order Butterworthlowpasspeaks 4.4 to 5 times higher than in TPT. The audio-rate tests oftf2s,resonlp,lowpass... are what keeps them in TPT form.ve.wah4,crybabyandautowahsmooth their control withsi.smooth(0.999), which attenuates a 500 Hz modulation by 37 dB at 44.1 kHz and 24 dB at 192 kHz: their test would render a nearly static filter.moog_vcfcovers the filter ofwah4.- Vicanek's matched filters,
ve.lowpass2Matched,highpass2Matchedandbandpass2Matched, run a direct-form recurrence (_matchedRun) and diverge under this modulation from Q = 6 on (peaks of 1e5 to 1e7 from the 0.1 input at Q = 6, beyond 1e38 within 0.42 s at Q = 10, in double precision too). At Q = 5 they pass, already 4 to 7 times above their static peak. They will get their tests with a realization that passes them. - Filters whose cutoff is not modulated in synthesis (equalizers, crossovers, elliptic anti-aliasing filters) need none.
Two more precautions:
- An integer parameter driven by the triangle, such as a delay length, must come out the same in both precisions.
int(16 + 112*tri)does not: float and doubletrican differ in the last bit, and near an integer boundaryint()then picks a different delay, so the two outputs diverge by whole samples and the sample gap checks nothing. Compute the integer exactly, with an integer remainder, since Faust's/is always a float division:
fb_comb_modulated_test = no.noise : fi.fb_comb(2048, d, 0.7, 0.6)
with {
P = int(ma.SR/10);
m = 112*(P - abs(2*ba.period(P) - P)); // 112*tri*P, an integer
d = 16 + int((m - m % P)/P + 0.5); // 16 + floor(112*tri), the same integer in float and double
};
- The interval analysis of the compiler does not see that
ba.period(P)/Pstays below 1 whenPis not a constant: a parameter that needs bounds, such as a delay that is read directly with@or a window length, gets them explicitly (: max(16) : min(128),tri : max(0) : min(1)).
Parameters that must be known at compile time (in capital letters by convention: an order, a number of voices or bands, a maximum delay) need neither variant. scripts/lib_tests.py inventory xx.lib lists which of the four tests each documented function has, in the doc blocks and in tests/*.dsp. scripts/lib_tests.py add xx.lib new_tests.dsp inserts tests written in an ordinary Faust file into both places; scripts/README.md describes it. The three costs can be compared in one run:
make check-cpu CPU_ARGS="-k '^resonlp(_slider|_modulated)?_test'"
Precision and sample rate
The regression tests run in double precision at 48 kHz only (-double, SAMPLE_RATE=48000). Most hosts compile Faust code in single precision (float) and run it at 44.1, 48, 88.2, 96, 176.4 or 192 kHz. Before a pull request, new code must therefore be rendered in both precisions and at all these rates.
make check-precision does this for every *_test, with no stored reference: it compiles each test in -single and -double with arch/precision_arch.cpp (the excitation and control schedule of arch/print_arch.cpp, with a binary output), renders one second at each of the six rates, and compares the two builds. A test fails when:
- an output is not finite, in either precision, at any rate;
- its level gap exceeds 1e-3: for some output and rate, the RMS of the single-precision render differs from that of the double-precision render by more than 1e-3 in relative terms.
The level gap is the criterion, not the sample-by-sample gap, because os.osc drifts in phase in single precision (see below): the sample gap of a test it drives exceeds 1e-3 whether the code under test is accurate or not. The sample gap is still measured and written to the --json report. For a new test, prefer no.noise as input, or os.tosc when a sine is needed: both measurements are then meaningful. os.tosc is the sine of an integer phase (os.tphase): its phase is exact at every sample, the same in both precisions and at every rate, and it plays its frequency to 0.1 Hz; the tests use it in place of os.osc, except those of the oscillators themselves.
The debt accepted when the check was introduced is pinned in tests/precision-baseline.json, the way tests/doc-baseline.json pins the documentation debt: nonfinite lists the rates at which a test may be non-finite in single precision, level the worst level gap it may reach (within a factor margin of 2, since the last bits of a single-precision result depend on the compiler and its math library), and expected the few tests whose outputs differ between precisions by definition (ma.EPSILON, ma.MIN). A new test is never in the baseline, so it must pass outright. When a fix removes the need for an entry, the check says so: remove the entry in the same commit. For a level entry, it says so only once the gap is below the threshold divided by the margin (5e-4): a gap just under 1e-3 on your machine may still be above it on another platform, so do not remove an entry the check does not report. Never add or loosen an entry to silence a failure you caused; the baseline is regenerated as a whole (scripts/check_precision.py --write-baseline) only when the rates, the threshold or the harness change.
The whole run compiles every test twice and takes about ten minutes on ten cores. To check one library, pass its test file, or select tests by name:
make check-precision PRECISION_ARGS="tests/vaeffects_tests.dsp"
make check-precision PRECISION_ARGS="-k klonCentaur_test"
The builds use faust -single|-double and c++ -O2. A precision fix can depend on how the code is compiled: the Faust normalizer and a C++ -ffast-math both reassociate floating-point expressions, and can undo a rewrite that avoided a cancellation. When a change relies on a precise evaluation order, check it with other compilations too. make check-precision-matrix runs the check with C++ -O2 and -O3 -ffast-math, then with Faust -vec and -lang ocpp, against the same baseline; single options are also available:
make check-precision-matrix PRECISION_ARGS="tests/vaeffects_tests.dsp"
make check-precision PRECISION_ARGS='-k Matched --cxx-options="-O3 -ffast-math"'
make check-precision PRECISION_ARGS="-k Matched --faust-options=-vec"
make check-precision renders each test as written, at its default control values. The points below go further; check them for new code, with the controls at their extremes and with the input levels the function is meant for:
- Stability. At every rate and in both precisions the output must stay finite and bounded, with the controls at their extremes and with the input levels the function is meant for.
make check-extremeschecks the controls part: it renders every test that has sliders or number entries, in single precision at 44.1 and 192 kHz, with all of them at their minimum, then at their maximum, then each one alone at each end, and fails on a non-finite output or a peak beyond 100 times the larger of 1 and the default render's peak. A gain at its maximum may exceed that by design, and a test's own slider range may reach a stability limit (a feedback gain of 1): such cases are listed intests/extremes-baseline.jsonwith their reason, and an entry that no longer fails is reported, to be removed. Its first run foundfd.hammerunstable at the top of its test'somega0Sqrrange. The input levels remain to be checked by hand. - Controls that move. A host moves a slider while the program runs, and a realization stable at every fixed setting can blow up when the setting jumps: the state left by the old coefficients is a wrong starting point for the new ones.
make check-jumpsrenders every test that has sliders or number entries with them jumping between their bounds during the run (default, max, min, max, min, max, min, default, one eighth of a second each, at 44.1 and 192 kHz), all together and one by one, and fails on a non-finite output or a peak beyond 100 times the largest of 1, the default render's peak and the peaks held at the same bounds. Its first run, in October 2026, found 16 tests among 470: the direct-form biquads ofwebaudio.libandve.moog_vcf_2bn(peaks of 115 to 2e4 after a jump of the frequency), the DPW oscillators (os.saw3,os.saw4,os.sawN,os.pulsetrainN: up to 6e5 after a frequency jump), the Jiles-Atherton models ofja_processor(up to 5e4) andfd.hammer(not finite). They are recorded intests/jumps-baseline.jsonwith their reason; a test named_jump_teststill pins the jumps that matter for one function. - A second
init(). A host initializes an instance again to reset it or when the sample rate changes.make check-reinitrenders every test after a secondinit()(48 kHz after 48 kHz, 192 kHz after 44.1 kHz, 44.1 kHz after 192 kHz) and requires the output of a fresh instance, sample for sample: a stateinstanceClear()does not reset, or a table or constant computed from the first rate, fails it. Its first run, in October 2026, found none among the 2349 tests. - Float against double. At each rate, compare the single and double precision renders of the same program. A well-conditioned structure stays within about 1e-5 to 1e-4 of the peak. A larger gap, or one that grows with the sample rate, points to a structure that loses precision in float. Recursive filters whose poles come close to z = 1 are the usual cause, that is, frequencies low relative to the sample rate. For example, a direct-form biquad (
fi.tf2) with the coefficients of a 50 Hz second-order Butterworth lowpass differs by 0.2 % of its peak at 44.1 kHz and by 2.5 % at 192 kHz. Prefer a structure that stays accurate there, or document the limitation. A state-variable filter is one such structure: in the same conditions,fi.svf.lp(50, 0.707)stays within 2e-6. - Compare on an input that is the same in both precisions, such as
no.noise, which is an integer generator, oros.tosc, a sine of an integer phase.os.oscaccumulates its phase in the program's precision, so a sine input already differs between float and double by 0.1 % at 44.1 kHz and 1 % at 192 kHz, and hides the behavior of the code under test. - Behavior across rates. What should not depend on the sample rate must not: cutoff and resonance frequencies, formants, time constants, levels. Compute coefficients from
ma.SR, and watch for anything set in samples (delay lengths, waveguide sections, block sizes) and for pre-warping or oversampling filters close to Nyquist at the lowest rates. When a model is only valid at some rates, say so in its documentation and, if possible, give a way to adapt it (seept.ticksPerSample).ma.SRis clamped to 192 kHz (seepl.SR), so behavior above that rate is not guaranteed.make check-srrenders every test at 44.1, 96 and 192 kHz, with the noises made rate-independent, and fails when the shape of the spectrum, the level, the onset or the decay moves beyondtests/sr-baseline.json(SR_ARGS="tests/xx_tests.dsp"to restrict it); the claims checks below measure the cutoffs, pitches and aliasing of the filters, instruments and oscillators at each rate. - Modulation. When a parameter can change while the function runs, check two cases: a parameter that jumps between two distant values (for example a cutoff switching between 100 Hz and 5 kHz on an integer sample count, so that both precisions switch at the same sample), and a parameter modulated at audio rate. Compare the output peak with the static filter's. A structure whose states do not scale with the parameter can peak many times above it, or diverge: a direct-form resonant lowpass peaked about 2000 times above its static level in the first case and diverged in the second, in double precision too. The section Digital Filter Sections Specified as Analog Filter Sections of the filters library describes a structure that does not.
- The domain of a new realization. When a change replaces one realization by another (a direct form by
fi.tf2_tpt, a filter by its state-variable form), check that what the new one receives stays within the domain its documentation states, over the full parameter ranges of every caller, the sliders of the demos included, and not only at the values of the tests. In October 2026, a pull request realized the allpass sections ofpf.vibrato2_monowithtf2_tpt, whose documentation asks a design that reaches Nyquist to bound its frequency. The phaser places its notchiatfratio^itimes the first one, sodm.phaser2_demo's ranges put the fourth one at 640 kHz, aliasing across Nyquist many times per second: it peaked at 37.6 where the direct form peaked at 5.0 (noise in, feedback 0.9, width 10 Hz, at 44.1 kHz), and every test passed. Bound what the domain requires, asfi.notchwdoes andpf.vibrato2_mononow does at 0.95*PI, and pin the bound with a test at the edge of the domain (vibrato2_mono_nyquist_test).make check-extremesdoes not replace this check: it moves the controls of a test one at a time or all together, on the test's own input, and fails only on a hundredfold growth. - Long runs. A recursive state decaying towards zero must not linger in the subnormal range, which float reaches much earlier than double: flush it or check that the structure does not produce it. Integer counters such as
ba.timewrap after 2^31 samples, that is 12.4 hours at 48 kHz: do not use them to detect the first sample, use1'or1 - 1'.make check-longrenders every test for two minutes at 192 kHz in-singleand-double, and fails on a non-finite output, a growing level, subnormal samples or a single/double drift beyondtests/long-baseline.json(LONG_ARGS="tests/xx_tests.dsp"to restrict it).
For such hand checks, the arch/print_arch.cpp architecture used by make check takes the number of frames and the sample rate as arguments. For a program probe.dsp built around the new function, for instance process = no.noise : fi.lowpass(4, 50);, the following commands render one second at each rate in both precisions and print, for each rate, whether the output is finite, its peak, and the largest float/double difference relative to that peak:
b=tests/build
for p in single double; do
faust -$p -a arch/print_arch.cpp $b/probe.dsp -o $b/probe-$p.cpp
c++ -O2 -std=c++17 $b/probe-$p.cpp -o $b/probe-$p
done
for sr in 44100 48000 88200 96000 176400 192000; do
$b/probe-single $sr $sr > $b/probe-single.txt
$b/probe-double $sr $sr > $b/probe-double.txt
python3 -c "import numpy as n; s=n.loadtxt('$b/probe-single.txt')[:,1:]; d=n.loadtxt('$b/probe-double.txt')[:,1:]; print('$sr', 'finite' if n.isfinite(s).all() and n.isfinite(d).all() else 'NOT FINITE', 'peak %.3g' % abs(d).max(), 'single/double gap %.1e' % (abs(s-d).max()/abs(d).max()))"
done
Report in the pull request what was checked and what was found, including any limitation left in the documentation.
Memory errors
An out-of-bounds read of a table or a delay line produces plausible numbers and passes every other check. make check-sanitize builds every test with the address and undefined-behavior sanitizers (-fsanitize=address,undefined), in single and double precision, renders one second at 44.1 and 192 kHz (indices depend on the rate), and fails on the first report. Faust's table guards are turned off (-ct 0): by default the compiler clamps every rdtable/rwtable index, which hides a library function whose index leaves the table, so the check reports those reads too. UBSan's array-bounds check is the one that matters here: the tables and delay lines are fixed-size arrays inside the DSP object, where an index past one array lands in the next and ASan, which only guards the whole object, sees nothing.
The whole suite takes about 30 minutes; restrict it to the test files you touched with make -k check-sanitize DSP_FILES="tests/xx_tests.dsp". Like make check, it re-runs only the tests that a change reaches, and keeps a stamp per test in tests/output-sanitize/. Its first full run found ba.tabulateNd(...).cub reading outside its dimensions at the edges of the grid (fixed in basics.lib 1.23.6).
Backends and foreign functions
The regression tests compile and run C++ only, but the libraries are used through every Faust backend: WebAssembly first (the Faust IDE, faustwasm), then Cmajor, Julia, Codebox, C#, Java and the interpreter. Those backends refuse a foreign function outside a short whitelist, at compile time:
ERROR : calling foreign function 'cbrtf' is not allowed in this compilation mode
| Foreign functions | Backends that accept them |
|---|---|
acosh, asinh, atanh, cosh, sinh, tanh, isnan, isinf, copysign |
all |
every other ffunction of maths.lib (cbrt, hypot, ldexp, scalb, logb, ilogb, erf, erfc, gamma, lgamma, J0, J1, Jn, Y0, Y1, Yn, nextafter), no.randomseed (arc4random) |
C, C++, Rust and LLVM only |
The whitelisted functions are not free on the web either: the WebAssembly module imports them from its JavaScript host, so extending the list takes a compiler change and the matching import in every runtime in use.
So library code uses Faust primitives and the whitelisted functions only, however deep the call: aa.sineFold1 stopped compiling for the web when it called the C log1p two levels down. The precise forms that Precision and sample rate asks for have portable tools: ma.expm1 and ma.log1p are built on sinh and atanh (exact identities, 1.6e-7 in single precision), not on the C functions.
make check-doc compiles every test for WebAssembly when a library or a test file differs from HEAD (about 15 s), and make check-backends does it for the six backends (a minute of compilation, about two with Cmajor's rendering; BACKENDS_ARGS="--lang wasm" to restrict it). Both also validate the WebAssembly modules with Node, as a browser does before running one, and run them: one second at 48 kHz, the inputs at 0, the controls at their default values and the buttons pressed for the first half, as make check runs the C++. A module can compile and still be rejected there, or stop when it runs (a trap: in October 2026, int() of a NaN did), or write a non-finite sample: a bug of faust to report, not a debt of the libraries, unless the C++ build in single precision gives the same value (ma.MIN * 1e307 is infinite in single precision). The modules of the soundfile tests import their memory, which faustwasm's JavaScript glue provides with the sound files: they are validated, not run. make check-backends also has Cmajor compile and render every patch (cmaj render, one second at 48 kHz; it cannot press a button), and with BACKENDS_ARGS=--run-julia loads and runs the Julia code, buttons included: faust -lang cmajor or -lang julia succeeding does not mean that the target accepts the code, as Cmajor's isinf returning a bool and Julia's sqrt throwing on a negative number showed in October 2026. A Cmajor host starts an input at its default snapped to the slider's step, round(init / step) * step computed in float, which moves even a default on the grid by one float (0.2 with a step of 0.0001 starts at 0.19999999, a delay of SR * 0.2 samples one sample short): faust leaves the step annotation out when that computation does not give the default back exactly (faust 2.90.20, 29 October 2026). Both compare the failures with tests/backend-baseline.json, the accepted debt: the tests of the non-portable functions themselves, ma.BS and si.bsmooth (the foreign variable count) on Cmajor and Codebox, and the soundfile tests on Cmajor, Codebox and Julia (the primitive is not supported) and Java (a compiler assertion). A test that fails and is not listed is a regression; a listed test that compiles again is removed from the list in the same commit. The error names the foreign function, and the test names the library function that calls it.
A finite output is not a correct one. make check-backend-outputs (check_backends.py --compare) writes the outputs of WebAssembly and Cmajor (and Julia with BACKEND_OUTPUTS_ARGS="--lang wasm,cmajor,julia --run-julia") and compares them with the C++ build in single precision, rendered with the same schedule, in blocks of 512 frames (buttons never pressed for Cmajor), compiled with -ffp-contract=off: clang contracts multiply-adds into fused ones on arm64 by default, which neither backend does, and that alone moves the level of greyhole_test by 4.5e-3. A test fails when its shape differs, when the RMS of a channel differs by more than 1e-3 (relative), or a sample by more than 1e-2 of the C++ peak, beyond tests/backend-output-baseline.json. Its first run, in October 2026, found two bugs of Cmajor's standard library behind finite outputs: acos(x) returns acos(x) - pi for negative x (the aa.arccos tests), and sinh and atanh give 0 near 0 in float32 (expm1_slider_test, log1p_slider_test, cmajor-lang/cmajor#141). Cmajor fixed both in November 2026, with its asinh, and the eleven Cmajor entries of the baseline were removed. WebAssembly matched the C++ build on every test but two, where isolated samples differ. A difference that Cmajor's or the browser's math library causes is reported to it, not hidden in the test or the baseline.
faust looks for libraries in the current directory before the -I ones. To scan another checkout (a worktree, the head of a pull request), run the script of that checkout: it compiles from its own root, while a faust run by hand from this repository would test this repository's libraries.
CPU cost
A change that alters the structure of a computation, such as a rewrite against cancellation, a filter realized in another form, or a workaround of the normalizer, also changes what it costs. That cost is a trade-off to state in the pull request, with numbers a reviewer can reproduce. make check-cpu measures it on the tests. The --base REV argument compares the libraries of the working tree, or of --new REV, with those of REV:
make check-cpu CPU_ARGS="--base origin/master tests/filters_analog_sections_tests.dsp"
make check-cpu-matrix CPU_ARGS="--base origin/master -k 'resonlp|vocoder_demo'"
scripts/check_cpu.py --base origin/master --new origin/some-branch -k tf2s
Measure on an idle machine, on AC power, with nothing else running: no build, no make check or check-precision, no other heavy job. A few seconds of another load can triple the rounds of the test being timed, and no tool can correct a timing made on a loaded machine. check-cpu warns when the load average exceeds the performance cores at the start, but it cannot see a short burst. What it does see is the spread of the rounds: a ratio whose spread is still above 20% after the re-race is marked ?, left out of the summary, and listed at the end, to be measured again. Quote no ratio marked ?. For the figures of a pull request, two runs that agree are better than one. On an idle machine, two full runs of the suite differed by 0.2% to 0.5% per ratio (median).
For each test, the table gives the best time per frame in the two versions, their ratio new / base, the share of one core at 48 kHz, and the spread of the rounds, which is the noise the ratio should be read against. Comparisons of identical code put that noise at about 3%: a ratio within 3%, or within its spread, is no difference. The measurement and the protocol come from Yann Orlarey's faustcompilerbenchtool, and are described in scripts/README.md. A time is flagged NaN when the output was not finite: that time measures NaN arithmetic, not the code.
- Measure the tests you touched, and the callers that matter. A function used inside a bank of filters, such as the 32 bands of
dm.vocoder_demo, costs its ratio times the number of instances. Select these tests by file or with-k, or run the whole suite with--changed-only, which times only the tests whose generated code the change alters, wherever they are. - Measure with more than one compilation. The default one is what faust2xx scripts use (
c++ -O3 -ffast-math). A ratio depends on the compilation, and not only the times do.-ffast-mathturns divisions into multiplications and reassociates sums: a direct-form filter profits from that more than a state-variable one. Faust-veccan change a ratio even more.make check-cpu-matrixrunsfast-math,strict(-O3) andvecin turn. Report at leastfast-mathandstrict. - Measure the three regimes. A test with constant parameters computes its coefficients once. The
_slider_testand_modulated_testvariants (see Constant, slider, modulated and jump tests above) measure the cost per block and per sample. A rewrite can be cheap in the first regime and twice as slow in the last one: a state-variable realization offi.tf3slfmeasured 1.22 times the direct form's cost with constants, and 1.97 times with its cutoff modulated at every sample. - Look at the
opscolumn, not only at the ratio. It counts the divisions, square roots and transcendental calls (pow,tan...) that each sample executes, and marks with!a change that adds any. A desktop core hides much of their cost; an embedded core such as a Cortex-M7 does not, since a division costs it 14 cycles and apowtens to hundreds. A new per-samplepowortandeserves a mention in the pull request even when the measured ratio looks harmless. - Quote ratios from one run. Times vary between machines, compilers and runs. The identity lines printed first name the machine, the compilers (with their paths) and the revisions, so include them with the table.
Report the ratios, the compilations, and the absolute cost (% of a core) in the pull request. A slower function is acceptable when what it buys (precision, stability, a correct behavior) is worth it: say so explicitly.
Measured claims
The references of make check are made by the code they test: they say that an output did not move, not that it is right. Three checks measure what the documentation promises, with faustprobe (from faust-rs), each against its own baseline:
make check-filter-claims: the filters offilters.libandvaeffects.lib, their -3 dB points, peaks and independence from the sample rate (tests/filter-claims-baseline.json;FILTER_CLAIMS_ARGS="--only fi.lowpass");make check-tuning: the pitch of thephysmodels.libmodels and MIDI instruments from 44.1 to 192 kHz, about a minute (tests/tuning-baseline.json;TUNING_ARGS="--only pm.ks");make check-osc-claims: the oscillators ofoscillators.liband the antialiased functions ofaanl.lib, their pitch, independence from the sample rate, aliasing and float noise, about a minute (tests/osc-claims-baseline.json;OSC_CLAIMS_ARGS="--only os.sawN").
Run the one that covers a function you change. make verify-matched proves the rewrites of the matched filters of vaeffects.lib and checks their coefficients at 60 digits.
What the tests detect
make check-mutation writes small faults into a copy of the libraries, one at a time (a constant moved, an operator swapped, x' turned into x), and reports which ones the tests detect. It runs on a sample drawn with a fixed seed, in about an hour, and never touches the working tree; MUTATION_ARGS="--lib filters.lib -n 50 --list-survivors" restricts it to one library and lists the faults no test saw. A surviving fault in code you wrote is a test to add. make check-vec runs the whole regression suite with Faust's vectorized code generator (-vec).
Figures
The figures in doc/docs/img/ are measured from the libraries, and nothing regenerates them on its own: in October 2026, 13 of them still showed behavior fixed weeks before, and six property assertions of scripts/plot_families.py had been failing since. A change that alters a function's output runs make check-plots (about two minutes) before committing: it regenerates every figure aside, fails on a failed assertion, and lists the figures whose rendering changed. Run the whole check, not --only the function you changed: the seven tu_* figures depend on a table-interpolation helper that nothing in their names reveals. Regenerate the stale figures in the same commit with make plots, which rewrites only those, then rebuilds the pages that embed them; it must end with "all property assertions hold". An assertion that fails after a deliberate fix is updated to the fixed behavior in the same commit, and checked to fail on the code before the fix. scripts/README.md, section Figures, describes the generators.
Formal certification (experimental, work in progress)
Status: experimental. This tool is under active development: the set of properties it can certify is deliberately small, its verdicts and file formats may change, and it is not required for a pull-request to be accepted. Regular testing (
make reference/make check/make check-doc) remains the contract.
Alongside the numerical test harness, the repository carries a formal
certification pipeline based on Lean 4: the compiled
signal graph of a DSP example is imported into Lean, analysed, and each verdict
is pinned as a machine-checked theorem. The hand-written specifications live in
formalisation/, the certified examples in tests/lean/, and the generator in
scripts/sig2lean.py.
Two properties are currently certified, on concrete instantiations:
- feedback stability: linear recursions of order ≤ 2 with constant
coefficients are checked against the Jury criterion in exact rational
arithmetic (e.g.
fi.tf2instances); - index bounds: every table read and delay tap is checked to stay in range as written — as opposed to being made safe by a compiler-inserted clamp.
Everything the analysers do not recognise exactly is refused, not guessed:
a refusal (not certified, not proven) is a statement about the analyser's
current coverage, not a defect report about the function.
Contributor workflow
No Lean knowledge is needed. Prerequisites: lean (4.31, bundled Std only) and
faust-rs on the PATH — or override with make certify FAUST_RS=... LEAN=....
- Add a small DSP program to
tests/lean/instantiating the new function with concrete parameters, e.g.tests/lean/machin.dsp:
xx = library("malib.lib");
process = xx.machin(3, 1000);
The file's base name becomes the name of the generated definitions and
theorems. A nominal case plus a boundary case is a good default; a
deliberate counter-example whose refusal is itself pinned (like
tf2_unstable.dsp or table_bad_clamp.dsp) is also valuable.
-
Run
make certify. It regenerates the theorems intotests/build/, kernel-checks them, and diffs against the committedtests/lean/certified.lean— so a new.dspmakes it fail, displaying exactly the block that would be added. Read the verdicts in that diff: -
STABLE/IN RANGE: the property is certified by a kernel-checked theorem; NOT STABLE/CLAMP REQUIRED: the graph really is unstable, or the index only stays in the table thanks to the backend's clamp — for a library function, a hint to clamp or document on the Faust side;not a recognised linear recursion/not proven: outside the certified fragment (coefficients depending onma.SR, nonlinear recursion, order > 2…). The refusal is pinned as a= falsetheorem, so if a later extension of the analysers unlocks the case,make certifywill show the verdict flip.
The run also cross-checks every table verdict against the compiler's own
clamp insertion (the -ct pass, read from
faust-rs --dump-sig-dag-prepared): a CLAMP REQUIRED table the
compiler left unclamped fails certification outright, and a clamp on a
table Lean proves in range is recorded as a missed optimisation in the
"Compiler clamp oracle" section of certified.lean.
- Once the verdicts look right, run
make certify-referenceto regeneratetests/lean/certified.leanin place, and commit both the.dspand the regeneratedcertified.lean.
From then on, every make certify re-proves the theorems and turns any
verdict drift — from a compiler or specification change — into a loud failure,
exactly as make check does for numerical outputs.
make check-doc does the same when a library, tests/lean/, formalisation/
or the generator changed, if lean 4.31 and faust-rs are installed
(scripts/check_certify.py --changed, about 10 s; make check-certify always
runs it). It fails on a verdict that moved, and only notes a term that changed
with its verdict intact, which make certify still refuses until
make certify-reference. It does not see a new compiler, which changes no
file: run make certify after updating faust-rs. A change that loses a
verdict either teaches the prelude the new form, with its correctness argument
in a comment, or accepts the refusal; in both cases make certify-reference
runs in the same commit. Never reword a rule to get a verdict back.
Two standing limits are worth knowing: certification applies to the exported
signal graph (not to the generated C++/Rust code), and to the exact rationals
denoted by the coefficients (not to floating-point execution). Both are
recorded as named obligations in formalisation/signal-import-formal-spec.lean.
A third, optional layer exists for maintainers: make certify-deep builds a
small mathlib-based project
(formalisation/mathlib/) that discharges the central recorded obligation —
the executable Jury test is proved equivalent, at order 2, to "every pole lies
strictly inside the unit disc" — plus the positivity hypothesis of the tf2s
theorem. It pins its own toolchain and downloads the mathlib build cache
(several GB) on first run; it is never needed for make certify, for
contributions, or for pull-requests.
LLMs
The site exposes an llms.txt file generated from doc/docs/llms.txt and published at https://faustlibraries.grame.fr/llms.txt.
Faust Library JSON Exports
scripts/build_faust_doc_index.py parses the doc blocks of the .lib sources
into a machine-readable index that LLM tools (the MCP servers,
scripts/faust_doc_api.py) search without loading the libraries: for each
documented symbol, its summary, usage, parameters, notes, test code,
references, license and source, and its io (numbers of inputs and outputs),
computed by the Faust compiler from the call of the Usage valued by the
#### Test section. make doc-index-split writes it to tests/faust-doc/ and
tests/faust-doc-index.json, in one compact index plus one file per module,
the layout suited to retrieval; make doc-index-commercial keeps only the
symbols whose license passes a conservative commercial-compatible filter.
scripts/README.md, section JSON export, describes the options, the license
policy and the output paths.
Keep these exports working. After a change to the documentation format
(header shapes, section names, block structure), regenerate them
(make doc-index-split) and check that the symbols you touched still come out
with their summary, usage, parameters and license
(scripts/faust_doc_api.py get_faust_symbol xx.name). make check-doc only
guards the count of exported symbols, which may only grow: it cannot see a
field that silently comes out empty. A new function whose io comes out with
"source": "usage" instead of "faust" has a Usage that does not evaluate.
Local Documentation Query API
scripts/faust_doc_api.py queries that index with the operations of the
Faust-library MCP tools used in faustforge: search by words, signal counts or
license, a symbol's entry, a module's symbols, examples, and a symbol's doc
block and definition read from its .lib file. Every command prints JSON, or
a compact text rendering for LLM context with --format text:
make doc-index-split
scripts/faust_doc_api.py --format text search_faust_lib lowpass butterworth
scripts/faust_doc_api.py --pretty get_faust_symbol fi.lowpass
scripts/README.md, section JSON export, lists its commands and the
ranking of the search.
Licensing issue
Some DSP functions carry per-symbol licenses that are more restrictive than the default Faust libraries distribution terms. This matters in LLM-assisted code generation and code reuse workflows.
In particular, functions released under licenses that are non-commercial, copyleft-incompatible, or otherwise unsuitable for the intended downstream use must not be suggested blindly in generated code.
When exposing Faust library data to LLM tools or retrieval systems:
- preserve per-function license metadata when it exists
- make that metadata queryable alongside the usual documentation fields
- check license compatibility before recommending or assembling generated DSP code from library functions
The local JSON export and query tooling can expose this information, so license checks can be integrated into higher-level assistants and generation pipelines.
Git history
The history is linear and must stay that way: no merge commits since December 2020. Bisecting a library where a regression means "an audible output changed" depends on it.
- Never
git mergea branch that has diverged: rebase it onto its target, then fast-forward (git rebase master my-branch,git checkout master,git merge --ff-only my-branch). - Update from the remote with
git pull --rebase.git config pull.rebase trueandgit config merge.ff onlymake a stray pull refuse to create a merge. - One commit per coherent change: a library edit, its tests, its regenerated
documentation and its version bumps belong together, not spread over
commits that each leave
make check-docormake checkfailing. Squash the work-in-progress commits of a branch before integrating it. - Rewrite history (
rebase,--amend, squash) only before the commits are pushed. Once they are onorigin, fix forward with a new commit. - Do not commit build artifacts: the built site (
site/), the test references (tests/reference/), the test outputs and builds (tests/output/,tests/build*/,tests/output-sanitize/) and the JSON exports (tests/faust-doc-index.json,tests/faust-doc/)..gitignorecovers them, andmake cleanremoves all but the references (make distcleanremoves those too). Never force one in withgit add -f, and never stage withgit add -Aorgit commit -a: name the files you mean.
Library test and deployment
For GRAME maintainers:
- global tests can be done using the
make referenceandmake checkat root level - run
make check-plotsbefore everyversion.libbump (see Figures) - regenerate the PDF documentation using
make pdftarget at root level - update the library submodule in faust, recompile and deploy WebAssembly libfaust in fausteditor, faustplayground and faustide
- update the library submodule in faustlive
- update the library list in this fausteditor page as well as the snippets (using the
faust2atomsnippets -s *.libcommand at root level). - update the library list in this faustide page and LIBRARIES folder.
- update the library list in the faustgen~ code
- update the Faust Syntax Highlighting Files
- make an update PR for vscode-faust project