skillZs
★ LIVE SKILL TAGS ★
>>> LIVE SKILLS INDEX <<<
* OPEN SOURCE *
NO LOGIN, NO TRACKING
※ REAL INSTALL DATA ※
← back to all skills
shortwavlabs/agent-skills51 installs

faust-dsp

Write DSP algorithms in the Faust programming language for real-time audio processing and synthesis. Faust (Functional Audio Stream) is a functional, block-diagram language that compiles to optimized C/C++, WebAssembly, LLVM IR, and more — targeting VST/AU plugins, standalone JACK apps, PureData/Max externals, WebAudio, embedded platforms (Teensy, ESP32, Bela), and more. Use this skill whenever the user asks about Faust, faust code, .dsp files, Faust libraries, faust2xx scripts, or any real-time audio DSP that could be expressed as a signal processing block diagram. Also use when the user mentions functional audio programming, compiling DSP to plugins, or cross-platform audio signal processing from a single source.

How do I install this agent skill?

npx skills add https://github.com/shortwavlabs/agent-skills --skill faust-dsp
view source ↗

Is this agent skill safe to install?

  • Gen Agent Trust Hubpass

    The skill provides a comprehensive environment for developing audio DSP algorithms using the Faust programming language. It includes language syntax, standard library documentation, and compilation instructions. No security risks were identified.

  • Socketpass

    No alerts

  • Snykpass

    Risk: LOW · No issues

What does this agent skill do?

Faust DSP Development

Faust is a functional programming language designed for real-time audio signal processing. A Faust program describes a block diagram of signal processors using five composition operators, and the compiler generates highly optimized C++ (or C, Rust, WebAssembly, etc.) that runs at sample level.

Core Workflow

  1. Analyze the requirement — identify inputs, outputs, parameters (with ranges), and the signal flow
  2. Sketch the block diagram — think in terms of the five composition operators
  3. Write the .dsp file — import libraries, declare metadata, define process
  4. Add UI elements — sliders, buttons, groups for parameters
  5. Compile and test — use faust CLI, Faust Online IDE, or faust2xx scripts

Language Essentials

Every Faust program must define process — the main signal processor (like main in C). Programs are lists of statements: metadata, imports, definitions, and comments.

File Template

import("stdfaust.lib");

declare name "MyEffect";
declare author "Author Name";
declare version "1.0";

// Parameters with UI
freq = hslider("Frequency", 440, 20, 20000, 1);
gain = hslider("Gain", 0.5, 0, 1, 0.01);

process = no.noise : fi.resonlp(freq, 1, gain);

Five Composition Operators

These are the backbone of Faust. Everything is a block diagram.

OperatorSyntaxDescription
ParallelA,BPlace A and B side by side (no connections)
SequentialA:BConnect A's outputs to B's inputs
SplitA<:BDistribute A's outputs to B's inputs (outputs must divide inputs evenly)
MergeA:>BSum A's outputs into B's inputs (outputs must be multiple of inputs)
RecursiveA~BCreate feedback loop: A's outputs feed back through B with 1-sample delay

Priority (higher = tighter binding): ~ (4) > , (3) > : (2) > <:,:> (1). Use parentheses to clarify.

Iterations

Faust provides compile-time loop constructs for algorithmic diagram construction:

IterationSyntaxResult
par(i,N,x)ParallelN copies of x in parallel
seq(i,N,x)SequentialN copies of x in series
sum(i,N,x)SumN copies summed together
prod(i,N,x)ProductN copies multiplied together

i is the iteration variable (0-indexed), N is a compile-time constant.

Key Primitives

PrimitiveDescription
_Identity (wire): passes signal through
!Cut: terminates a signal
+(x)Add (partial application: adds x to input)
*(x)Multiply (partial application: scales input by x)
@(n)Integer delay of n samples (n can be dynamic but bounded)
'One-sample delay (equivalent to @(1))
memOne-sample delay (equivalent to ')
select2(s)Two-way selector: s=0 picks first, s=1 picks second
select3(s)Three-way selector
rdtable(n,s,r)Read-only table: size n, content s, read index r
rwtable(n,s,w,_,r)Read/write table for loopers etc.
route(A,B,...)Custom signal routing: A inputs, B outputs, pairs of connections
waveform{...}Fixed waveform as a list of samples
soundfile("label[url:path]",n)Load and access external sound files
attach(x,y)Force y to be compiled (for side effects like bargraphs)

Infix Operators

Standard math/comparison operators work as infix: +, -, *, /, %, ^, <, <=, ==, !=, >=, >, &, |, xor, <<, >>. All compare/compute sample-by-sample on two signals.

Built-in math functions: sin, cos, tan, acos, asin, atan, atan2, exp, log, log10, pow, sqrt, abs, min, max, fmod, floor, ceil, round, rint.

Pattern Matching

Define functions with multiple cases using pattern matching:

// Simple pattern matching with parallel composition
count((x,xs)) = 1+count(xs);
count(x) = 1;

// Case expression
swap = case {
  (x:y) => y:x;  // invert sequential
  (x) => x;      // pass through
};

Lexical Environments

// with: local definitions
myFilter(x) = x : + ~ *(0.99)
    with { cutoff = 0.99; };

// environment: named group of definitions
consts = environment {
    pi = 3.14159;
    e = 2.718;
};

// letrec: mutually recursive difference equations
ar(a,r,g) = v letrec {
    'v = max(0, v + (n<a)/a - (n>=a)/r) * c;
    where c = g<=g';
};

Foreign Functions

Call external C functions directly:

asinh = ffunction(float asinhf|asinh|asinhl|asinfx(float), <math.h>, "");
SR = min(192000.0, max(1.0, fconstant(int fSamplingFreq, <math.h>)));

Standard Libraries

Import all libraries with import("stdfaust.lib"); and access via environment prefixes:

PrefixLibraryKey Contents
sfall.libAll functions from all libraries
babasics.libCounters, timers, bypass, MIDI freq conversion
mamaths.libConstants (SR, PI, etc.), math functions
ososcillators.libosc, sawtooth, square, triangle, bandlimited oscillators
fifilters.libresonlp, resonhp, resonbp, peak_eq, butterfly, svf
dedelays.libDelay lines, fractional delay, comb filters
rereverbs.libzita_light, freeverb, faustplate
enenvelopes.libAR, ADSR, smooth envelope generators
cocompressors.libCompressor, limiter, gate
nonoises.libWhite/pink noise generators
sisignals.libsmoo, bus, polySmooth, block
efmisceffects.libAutowah, crossover, talkbox
pmphysmodels.libPhysical models (strings, brass, wind, etc.)
sysynths.libReady-made synth components
dmdemos.libDemo functions with built-in UI
ananalyzers.libLevel meters, FFT, zero crossing
spspats.libSpatial audio, panning
roroutes.libSignal routing, crossfading
vevaeffects.libVariable delay effects (chorus, flanger, phaser)
pfphaflangers.libPhase shifter, flanger
itinterpolators.libInterpolation methods
ququantizers.libBit crushing, downsampling
dxdx7.libDX7 FM synthesis
wdwdmodels.libWave digital filter models
hohoa.libHigher Order Ambisonics
mimi.libMutable Instruments models

Read references/libraries.md for detailed library function signatures and usage patterns.

User Interface Primitives

UI elements are signal generators that produce control-rate signals:

// Continuous controls
freq = hslider("freq", 440, 20, 20000, 0.1);    // horizontal slider
gain = vslider("gain", 0.5, 0, 1, 0.01);         // vertical slider
mode = nentry("mode", 0, 0, 3, 1);               // numerical entry

// Discrete controls
gate = button("gate");                            // button (0 or 1)
on   = checkbox("on");                            // toggle (0 or 1)

// Groups for organization
hgroup("Oscillator", osc_code);                   // horizontal group
vgroup("Filter", filter_code);                    // vertical group
tgroup("Effects", effect_code);                   // tab group

// Meters (pass-through, display value)
level = _ : vbargraph("Level", 0, 1) : _;        // vertical meter
level = _ : hbargraph("Level", 0, 1) : _;        // horizontal meter

UI metadata can customize appearance: [style:knob], [unit:Hz], [scale:log], etc.

MIDI and Polyphony

Enable MIDI with metadata:

declare options "[midi:on][nvoices:12]";

Standard polyphony parameters (use these exact names):

freq  = hslider("freq", 440, 50, 2000, 0.01);   // pitch from MIDI note
gain  = hslider("gain", 0.5, 0, 1, 0.01);        // velocity
gate  = button("gate");                            // key on/off

MIDI CC mapping: hslider("param[midi:ctrl 7]", ...) Pitch wheel: hslider("bend[midi:pitchwheel]", 0, -2, 2, 0.01)

Use effect = ... for a shared post-processing effect across all polyphonic voices:

process = os.sawtooth(freq) * gain * gate;
effect = dm.zita_light;

Compilation

Command-Line Compiler

# Compile to C++ (default)
faust mydsp.dsp -o mydsp.cpp

# Compile with architecture file
faust -a alsa-gtk.cpp mydsp.dsp -o mydsp.cpp

# Vector code generation (for SIMD optimization)
faust -vec --vec-size 32 mydsp.dsp -o mydsp.cpp

# Parallel code (OpenMP)
faust -omp mydsp.dsp -o mydsp.cpp

# Parallel code (work-stealing scheduler)
faust -sch mydsp.dsp -o mydsp.cpp

# Double precision
faust -double mydsp.dsp -o mydsp.cpp

# Other backends
faust -lang c mydsp.dsp          # C output
faust -lang rust mydsp.dsp       # Rust output
faust -lang wasm mydsp.dsp       # WebAssembly
faust -lang llvm mydsp.dsp       # LLVM IR

faust2xx Scripts

These one-step scripts compile .dsp to ready-to-run binaries:

ScriptTarget
faust2jaqtJACK app with Qt GUI
faust2faustvstVST2 plugin
faust2auAudio Unit plugin
faust2lv2LV2 plugin
faust2puredataPureData external
faust2max6Max/MSP external
faust2supercolliderSuperCollider external
faust2csoundCsound opcode
faust2androidAndroid app
faust2iosiOS app
faust2belaBela board
faust2apiC/C++ API
faust2svgSVG block diagram
faust2pdfPDF block diagram

Common Patterns

One-Pole Lowpass Filter

onePole(x) = x : + ~ *(a)
    with { a = hslider("cutoff", 0.99, 0, 1, 0.001); };

Simple Delay with Feedback

delay(x) = x <: @(d), feedback
    with {
        d = hslider("delay", 44100, 1, 44100, 1);
        fb = hslider("feedback", 0.5, 0, 0.99, 0.01);
        feedback = (+ ~ @(d)) * fb;
    };

Stereo from Mono

stereo(fx) = _ <: fx, fx;

Mono from Stereo

mono(fx) = _,_ :> fx;

Parameter Smoothing

freq = si.smoo(hslider("freq", 440, 20, 20000, 1));

Additive Synthesis

process = sum(i, 8, os.osc(baseFreq * (i+1)) * hslider("Gain%i", 0.5, 0, 1, 0.01))
    with { baseFreq = hslider("BaseFreq", 220, 20, 2000, 1); };

FM Synthesis

process = os.osc(carrierFreq + os.osc(modFreq) * index)
    with {
        carrierFreq = hslider("Carrier", 220, 20, 2000, 1);
        modFreq = hslider("Modulator", 220, 20, 2000, 1);
        index = hslider("Index", 100, 0, 1000, 1);
    };

Karplus-Strong String

process = burst : (+ ~ (@(del) : *(damp)))
    with {
        del = ma.SR / hslider("freq", 220, 20, 2000, 1);
        damp = hslider("damping", 0.99, 0.9, 1, 0.001);
        burst = no.noise * (1 - ba.impulse(0.999));
    };

DSP Patterns Reference

For detailed DSP algorithm implementations (filters, oscillators, effects, analysis), read references/dsp-patterns.md.

For detailed library function signatures, read references/libraries.md.

For compilation targets and architecture files, read references/compilation.md.

Tips for Writing Good Faust Code

  • Think in block diagrams first. Sketch the signal flow before writing code. The five composition operators map directly to visual connections.
  • Use with for local definitions. Keep helper variables scoped to the function that uses them.
  • Smooth UI parameters. Wrap sliders with si.smoo() to prevent clicks from sudden value changes.
  • The compiler optimizes aggressively. no.noise : filter <: _,_ and no.noise <: filter, filter produce identical code. Write what reads best.
  • Delays must be bounded. Use UI elements (hslider, nentry) for dynamic delays — their ranges tell the compiler how much memory to allocate.
  • Use library() over import() to avoid name conflicts. fl = library("filters.lib"); ... fl.lowpass(...) is safer than import("filters.lib").
  • Pattern matching order matters. More specific patterns must precede general ones.
  • The ' (prime) operator is your friend for filters. x' means "x delayed by one sample" — essential for IIR filter structures.

Source Documentation

Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.

<a href="https://skillzs.dev/skills/shortwavlabs/agent-skills/faust-dsp">View faust-dsp on skillZs</a>