Git branches: main is the default, stable branch. Contributions go on a
feature branch cut from main and land via pull request. Don't push directly
to main.
The native GUI (Play tab, default patch), shown here hosted as hds.clap; synth_engine --gui draws the same interface.
A software synthesizer with a shared DSP core, distributed as three builds:
synth_engine— standalone binary. Owns real audio I/O (PipeWire by default, or ALSA) and MIDI, controlled over OSC by anything that speaks the wire protocol below. Can also open its own native GUI window (--gui), the primary control surface for this build.hds.clap— the synth as a CLAP instrument plugin for any CLAP host (Bitwig, REAPER, ...). No audio/MIDI I/O of its own — the host owns that. Ships a native, embedded GUI.hds_fx.clap— an 8-port, 32-slot multi-effects CLAP plugin (no synth engine) for running the same FX chains on other tracks. Also has a native embedded GUI.
All three share one DSP/state core (src/core/backend.c), so a patch, an FX
chain, or a bug fix behaves identically everywhere.
Everything builds inside nix-shell (shell.nix pins every dependency —
Cairo, X11, ALSA, PipeWire, liblo, the NAM/Eigen headers). Enter it once
per session, then:
nix-shell
make # -> ./synth_engine
make clap # -> ./hds.clap
make hds-fx # -> ./hds_fx.clap
make arm64 # -> synth_engine-arm64 (aarch64 Linux, e.g. Raspberry Pi 5)
Windows CLAP builds are cross-compiled from Linux (mingw-w64) and have been runtime-verified under Wine:
tools/build_windows_deps.sh # once per checkout
make clap-windows # -> hds-windows.clap
make hds-fx-windows # -> hds_fx-windows.clap
Background on the less obvious build choices (NAM symbol visibility, the mingw-w64 pthread
workarounds, static vs. dynamic linking on Windows, arm64 library bundling, PipeWire detection)
is in docs/building.md.
flake.nix packages the standalone for x86_64 and aarch64 Linux, built from whichever revision you
point it at, against the same pinned nixpkgs as shell.nix:
nix run github:GitHuhl/HDS -- --guiEverything after -- goes to synth_engine (see Command-line flags); drop
--gui to run it headless, controlled over OSC. nix run . does the same from a checkout, and
nix build leaves the binary at result/bin/hds. The flake needs Nix's flakes and nix-command
features enabled, and a private repository needs your Nix to be able to fetch it from GitHub.
make test # build everything, run the tests, compare against tests/golden.txt
make test-golden # same, but rewrite tests/golden.txt
Run inside nix-shell: it pins every library the results depend on and provides Xvfb for the
GUI test. make test runs nine programs from tests/:
test_backend— linksbackend.odirectly: the JSON reader (valid documents, escapes, nesting, and rejection of malformed input), the Scala.scltuning loader (cents, ratios, comments, CRLF; malformed files rejected without touching the loaded scale), and the OSC address table (every address unique and resolvable; the whole address space is fingerprinted, so any protocol change shows up).test_fx_chain— every FX type (except NAM) with four parameter/mix/routing/sidechain variants, plus a 32-slot, 8-source bus: checks the output is finite and fingerprints it.test_sample_engine— the DFD sample engine on its own, with its real disk and loader threads: a new note never plays a previous note's leftover ring audio or inherits its end-of-file, reverse zones play from their end, loop splices are crossfaded, a reloaded file is never read through a handle cached from before, and zone and SFZ loads never open a file on the audio thread (checked with a FIFO that blocks any open). Pass/fail checks only.test_recording— records WAV and WavPack through the recording engine and reads both back, checking every sample.test_clap_render— plays notes throughhds.clap(checks it sounds and then releases to silence) and checkshds_fx.clapwith every slot Off passes all 8 ports through bit-exactly.test_clap_osc— driveshds.clapover its real OSC protocol from an in-process host: ping/pong, a full/hds/request_statedump (one message per address, fingerprinted), parameter writes that show up in the next dump and change the sound, loading a generated.sfz(silent before the load, sounding after), and importing a generated 3-track MIDI file (lanes, tempo map, marker). Uses UDP port 9010, so close any running HDS plugin instance first.test_clap_patches— renders 19 sounds throughhds.clap(fresh instance each, settings over OSC, the same chord-then-legato note sequence): every oscillator shape, two oscillators, hard sync, FM, low-pass filter, filter key tracking, amp envelope, LFO to pitch and to filter cutoff, mono glide, and the arpeggiator. Each must be audible, and all must sound different from each other (with control patches, so FM and key tracking are proven to change the sound themselves); each is fingerprinted. This is what guards the voice engine inbackend.c.test_standalone— runs the realsynth_engineheadless (--no-midi, ALSA'snulldevices, OSC port 9100) and covers what only the standalone does: its audio loop is running, the state dump and an OSC parameter write, and end to end, importing a generated MIDI file, recording to a WAV while the Sequencer plays it, and checking the WAV is finalized and contains the notes; then SIGINT must exit cleanly. Pass/fail only (the standalone's timing isn't deterministic, so nothing is fingerprinted).test_clap_gui— opens both plugin GUIs on Xvfb, clicks through every tab ofhds.clap, and checks each view rendered and differs from the others. Text is pinned to the vendored DejaVu Sans so the captures match on every machine; they're saved tobuild/tests/out/.
The fingerprints in tests/golden.txt are bit-exact, so any change to the sound or the GUI fails
make test. If the change was intended, run make test-golden and commit the updated file along
with it, so the diff shows which outputs changed.
Every #include is relative to src/ (e.g. #include "core/backend.h"); the Makefile passes
-Isrc and the CLAP SDK's include directory to every compile.
| Directory | What's in it |
|---|---|
src/core/ |
The synth engine shared by synth_engine and hds.clap. backend.h (its interface) and backend_types.h (the data model); render.c (the per-sample renderer: render_audio_block, FM, oscillator/filter/envelope/LFO building blocks -- one file so they stay inlined), voices.c (note on/off, voice allocation, sustain, glide, microtuned pitch), midi_dispatch.c, arpeggiator.c, metronome.c, defaults.c (every control's default), fx_upload.c (NAM file upload over OSC), program_files.c, and backend.c itself (the engine globals); engine_internal.h holds the few cross-file pieces among those; and: osc_protocol.c (the OSC_PARAMS[] address table, dispatch, state dump, discovery, status pushes), sample_engine.c/.h (Sample Bank zones, stream pool and disk thread, the sample loader thread, the sample oscillator), sfz_parser.c/.h, smf_import.c, tuning.c, json.c; plus recording_engine.c (WAV/WavPack recording) and sequencer.c (standalone-only transport, lanes and MIDI clock). hds_config.h holds build-wide constants, hds_compat.h the Windows POSIX shims. |
src/fx/ |
The FX bus shared by all three builds: fx_chain.c/.h (slot lifecycle, routing, process_fx_chain), fx_types.h (the slot data model), one file per effect family (Airwindows modulation and tone ports, NAM, EQ/filters, compressors, gate/limiters, pitch, reverb/delay) behind the internal fx_effects.h, and the C++ NAM bridge (nam_bridge.cpp/.h). |
src/gui/ |
The native Cairo-drawn GUI, platform-free: the FX pool view (hds_fx_gui_draw.c/.h, hds_fx_gui_host.h), the file browser (hds_fx_gui_browser.c/.h), and the synth's tabs (hds_clap_*_draw.c behind hds_clap_gui.h, plus hds_engine_instance.h, the per-instance context they draw). Routing, Devices, Recording and the tab dispatcher are built once per host because they contain standalone-only code. |
src/platform/x11/, src/platform/win32/ |
Window creation and event pumping per OS and host (hds_clap_gui_*, hds_fx_gui_*, hds_standalone_gui_x11.c). Each is #included by the one target that uses it. |
src/targets/ |
One directory per product: standalone/hds_standalone.c (synth_engine's main(): ALSA/PipeWire audio, ALSA MIDI, recording, terminal controls, the optional GUI), clap/clap_plugin.c (hds.clap), fx_clap/hds_fx_plugin.c (hds_fx.clap), and android/ (experimental, currently disabled and out of date). |
tests/ |
make test — see Testing above. |
synth_engine listens for OSC (UDP, via liblo) on --osc-listen-port
(default 9000) and sends status feedback to --osc-reply-host:--osc-reply-port
(default 127.0.0.1:9001). Every parameter has its own address (e.g.
/hds/vco1/shape, /hds/filter/2/cutoff) written directly into the shared
control struct — there's no positional binary blob to keep in sync by hand.
A few notable addresses:
/hds/request_state— pull this instance's full current state (a DAW-restored CLAP patch, or a controller that just connected, use this instead of assuming GUI defaults)./hds/ping→/hds/pong— instance discovery, for scanning multiple running instances/ports./hds/subscribe— register for periodic/hds/status/*pushes./hds/zone/*— the Sample Bank (SFZ/WAVE_SAMPLE zone upsert/remove/load). Loaded WAVs are correctly speed/pitch-compensated for their own actual sample rate against this engine's fixed 48kHz internal rate (a 44.1kHz file, or any other rate, plays at its real recorded speed/pitch, not whatever a naive frame-for-frame read at 48kHz would produce). Switching an oscillator's own Shape away from Multisample fully unloads whatever zones it still owned (freeing their RAM pre-roll cache, not just leaving them dormant) and — the same root cause fixed from the other direction — a note's release no longer fires a staletrigger=releasezone left over from a Multisample that oscillator switched away from before the note was released. First-class SFZ opcode support: round-robin (seq_length/seq_position, independent ofgroup=), real choke groups (group=/off_by=), keyswitching (sw_lokey/sw_hikey/sw_last/sw_default),trigger=(attack/release/release_key/first/legato), velocity/key crossfade layering (xfin_*/xfout_*),lorand/hirand,amp_velcurve_<N>,delay,rt_decay,loop_crossfade,#definemacros, and a per-zone amp envelope (ampeg_*) that's either fully used as-is or fully overridden by the oscillator's own Amp EG via its "Use Amp EG" checkbox (Multisample oscillators only) — never blended./hds/zone/drum_bus(ii: zone id, bus 0-24) — assigns a Sample Bank zone to one of 24 Drum Buses (0 = off). A zone routed to a Drum Bus contributes NOTHING to its owning oscillator's Volume/Mute/Pan/vel-to-amp or that Program's Filter chain — only the zone's own gain/pan and its own amp EG level reach the bus — so individual multisample keys (e.g. drum kit elements) can be sent straight to their own FX chain and output routing, fully bypassing the owning Program. Drum Buses reuse the same FX-slot (/hds/fx/<slot>/source) and output-routing (/hds/routing/<source>/out/<pair>) machinery as every other source — Drum Bus 1..24 sit at source idsCOMBI_PROGRAM_COUNT + 1 + EXT_IN_PAIR_COUNTupward. Also settable per-zone via the non-standard SFZ opcodehds_drum_bus=<1-24>. The native GUI's Routing tab has a "Drum Bus Key Routing" grid (below the Source rows, scroll to reach it) for this directly: a stepper picks which of the 24 buses you're editing, and a full 12 (chromatic note, naturals + sharps) x 11 (octave -1 through 9, the entire real MIDI 0-127 range) checkbox grid assigns/clears every Single-Program-scope zone covering that note, live, no reload needed. Each Drum Bus row also gets its own Gain knob (/hds/drum_bus/<n>/gain, 0-200%, defaults to 100% unlike ext-in's own gain, which defaults to silent) — useful since a bus sums however many zones got assigned to it. The FX and Routing tabs' Source rows/combos already show/label Drum Bus sources correctly too.
A CLAP plugin instance runs its own embedded OSC server too (default
9010/9011, incrementing per instance), so any OSC controller can drive
a CLAP instance exactly like the standalone, just pointed at a different
port.
./synth_engine:
| Flag | Default | Meaning |
|---|---|---|
--osc-listen-port <port> |
9000 |
Incoming control port. |
--osc-reply-host <host> / --osc-reply-port <port> |
127.0.0.1 / 9001 |
Where status feedback is sent. |
--output-device <name> / --input-device <name> |
default |
A PipeWire node name (wpctl status), or an ALSA device string under --backend alsa. An unopenable output device is fatal at startup (with an interactive recovery prompt if stdin is a terminal); an unopenable input device just leaves external input silent. |
--backend pipewire|alsa |
pipewire |
Audio platform shim. PipeWire is the default in every build where libpipewire-0.3 was found (nix-shell, the flake); ALSA is still built in and opt-in with --backend alsa, and is the default only in builds without PipeWire (e.g. make arm64). |
--pipewire-force-quantum |
off | Forces the whole PipeWire graph's buffer size down to match this engine's Latency control — affects every other PipeWire client on the system while running. |
--sfz-vco1..4 <path> |
none | Loads an SFZ instrument onto that oscillator at startup. |
--program <path.hdsprog> |
none | Loads a full Program at startup. |
--master-volume <0.0-1.0> |
none | Sets master volume once at startup. |
--gui |
off | Opens the native Cairo GUI as this process's own top-level window. |
--no-midi |
off | Runs without the ALSA MIDI sequencer (control is OSC-only). Without it, a sequencer that can't be opened only prints a warning, and the engine runs OSC-only. With --output-device null --input-device null this runs with no audio or MIDI hardware at all, which is how make test drives it. |
Arrow keys work as live controls whenever stdin is a real terminal:
Up/Down nudge master volume, Left/Right cycle through saved Programs in
~/HDS_Programs/.
Up to 32 shared slots, each independently routable, each settable to any of:
- Dynamics: Gate (Schmitt-trigger hysteresis + a Hold timer, both in
addition to the usual Threshold/Attack/Release/Range, so a signal
hovering right at Threshold doesn't chatter open/closed the way a
single fixed threshold does), Limiter (brick-wall), FetComp (1176-style
FET compressor), FairKid67 (Fairchild 670-style tube leveling amp),
PeakMax (lookahead limiter/maximizer), OptoComp (LA-2A-style optical
compressor), DBX160 (dbx 160-family-style minimalist VCA bus compressor:
Threshold/Ratio/Makeup only, no Attack/Release knobs — matching that
hardware family's own famous simplicity — plus a sidechain highpass and
a saturation stage run through a genuine 4x-oversampled signal path; an
original design, not reverse-engineered from any real 160-family
schematic, see
FX_TYPE_DBX160's own comment insrc/fx/fx_types.h) — all report live gain-reduction metering back to the GUI. - Tone: EQ3 (3-band), MultiFilter (wide-range steep filter), Density3
(highpass into a density/waveshaping saturator), PointyGuitar (amp-style
distortion), GuitarConditioner, Cabs2 (speaker-cabinet tone shaping),
DeEsser (split-band), HardTune (real-time pitch correction, with an
optional LFO-routable vibrato), SSL4K (large-format-console-style 4-band
- HPF channel EQ, E/G switch, gain-proportional bandwidth on the two bell
bands, always-on saturation stage — an original design built on this
engine's own RBJ-cookbook biquad math, not a port of any specific plugin;
see
FX_TYPE_SSL4K's own comment insrc/fx/fx_types.h).
- HPF channel EQ, E/G switch, gain-proportional bandwidth on the two bell
bands, always-on saturation stage — an original design built on this
engine's own RBJ-cookbook biquad math, not a port of any specific plugin;
see
- Time-based: Ensemble (fixed-delay chorus), CreamCoat (FDN reverb),
FDNVerb (algorithmic reverb), StereoChorus, StereoDoubler (micro-pitch
detune), TapeDelay2 (tape echo, with optional stereo ping-pong),
BroadcastDelay (an on-air "profanity delay"/dump buffer: a plain
continuously-running delay line, 0-60s, with three fixed Dump buttons
(7s/15s/30s) that instantly skip that much buffered audio before it
reaches the output — the classic broadcast-engineering safety-delay
workflow. Auto-restocks after a dump with no manual step: the buffer
regrows back to the nominal Delay setting on its own by playing back a
hair slower than real time for a while — a Restock Speed knob controls
how aggressively (and how audibly) that catch-up happens. A color-coded
readout (green = fully buffered/safe to dump again, red = still
restocking) shows exactly how much dump time is currently available. The
three Dump buttons gray out (and stop responding to clicks) whenever
Delay is set to 0 — with nothing buffered, a dump would be a pure no-op,
which also makes it easy to spot the effect is being used purely for the
On-Air Override below rather than as an actual delay. Also has an orange
"1000 Hz" On-Air Override button next to a Volume knob (0-100%, default
50%): held rather than clicked, for as long as it's down the OUTPUT is
replaced live with a 1kHz tone at the Volume knob's own amplitude —
deliberately not delayed like everything else this effect does, so it
works as an instant on-the-spot self-censor rather than something that
only reaches air several seconds later. Volume only ever scales that
tone's loudness (0% is a legitimate "silent but still engaged" setting,
e.g. for testing a trigger source without actually being heard) — it
never disables the button; that's a separate, explicit choice. Right-
clicking the button opens a small menu with two independent checkable
toggles (not a mutually-exclusive mode picker): Trigger via MIDI Key
(purely additive — engages for as long as ANY MIDI note anywhere is
currently held, alongside the mouse-hold, never replacing or blocking
it, so a MIDI foot switch/pad and the mouse both just work at the same
time) and Disable (the only one of the two that actually grays the
button out and forces it off, regardless of the mouse or MIDI). Exists
so two Broadcast Delay slots can run at once, each with its own On-Air
Override wired to whichever trigger source(s) that instance actually
needs; see
FX_TYPE_BROADCAST_DELAY's own comment insrc/fx/fx_types.h). - Low end: DBX120X, a subharmonic ("sub-bass") synthesizer. Unlike most
digital subharmonic generators (which run a general pitch tracker across
whatever's playing and fall apart on anything polyphonic), this one never
tries to resolve a single pitch out of a complex mix at all: it heavily
low-passes the signal first (Track Freq, 30-300Hz) so only the dominant
sub-bass fundamental survives, then measures its period by simple
zero-crossing counting — a technique that's structurally immune to the
octave-detection ambiguity a spectral/autocorrelation tracker suffers
from. Generates a clean sine tone (not a buzzy divided square wave) one
or two octaves down, gated in/out by Threshold/Release so it only
appears when there's real low-frequency energy present, with its own
Synthesis Level separate from the slot's generic Mix. See
FX_TYPE_DBX120X's own comment insrc/fx/fx_types.h. - NAM: Neural Amp Modeler — loads a trained
.namamp model plus an optional cabinet impulse response.
Several of the tone/time-based effects are ports of MIT-licensed
Airwindows plugins — see each FX_TYPE_*'s
own comment in src/fx/fx_types.h for which one and any changes made porting it.
hds.clap and hds_fx.clap each embed a real, host-native window (X11 on
Linux, Win32 on Windows) drawn with Cairo — no toolkit dependency, no
second process. synth_engine can open the same GUI as its own top-level
window via --gui (off by default, so a headless deployment is unaffected).
Tempo: a CLAP instance defaults to following the host's own transport tempo (toggle to "Internal" in the Global sidebar's Tempo section to use the Tempo knob/tempo-map instead — this choice is saved with the host project like any other parameter).
Knobs: click-drag for a normal-sensitivity adjustment, double-click to reset to 0, right-click-drag for a 10x finer adjustment. A knob that also modulates something else (oscillator Pitch/Phase/Pulse-Width/Fine Tune/Curve-Drive/Volume/Pan, Filter Cutoff/Resonance, LFO Rate/Depth/Phase) opens a "Modulate From" menu on a right-click that doesn't drag, letting any LFO or assignable EG target it directly — the same field its own Destination dropdown already sets, just a second way to reach it. Fine Tune and Curve/Drive are real modulation destinations in their own right (targets 4/5/8/9 and 10-13 in the shared destination numbering) — Osc 3/4 Fine and all four oscillators' Curve/Drive didn't have one before and reclaim numbers from the destination scheme's retired-placeholder range (8-13; 84-89 are still retired) to add them without disturbing any other target's meaning.
FX tab Output pill (standalone only): hds_fx.clap's own 8-port model
always had a per-chain Output picker right in its FX tab, since a port IS
its own physical CLAP output pair. synth_engine's FX tab now has the
same convenience for its Source-combo model (Program/Combi Mix/Ext In/Drum
Bus, not a flat port) — the pill on a chain's own tail slot shows and sets
which single real output pair that source's FX result goes to, reading
and writing the exact same data the Routing tab's own source-to-output
grid does (no separate model, no risk of the two disagreeing). It can only
pick ONE pair at a time; a source already routed to several pairs at once
keeps that setup (visible as e.g. "Out 1+") until this pill is actually
clicked, and true many-to-many routing is still the Routing tab's job.
hds.clap has no equivalent — a DAW host owns its own output routing via
that plugin's per-Combi-Program CLAP ports instead, so there's nothing for
this pill to control there, and it stays blank.
Recording tab: format choices are WAV (Multichannel, formerly labeled
"Multichannel WAV") or WavPack. Selecting WavPack exposes its own controls
below the format pills — Lossless/Hybrid, a Correction File toggle (only
live in Hybrid mode: pairs a .wvc file with the .wv so the two together
losslessly reconstruct the original, while the .wv alone stays a smaller
lossy file), a 4-step Compression Level (Fast/Normal/High/Very High), and
an 8-preset Hybrid Bitrate (bits/sample, 2-24) used only in Hybrid mode.
Global sidebar: a hardcoded 160px pixel width (HDS_CLAP_GLOBAL_SIDEBAR_W
in src/gui/hds_clap_global_draw.c), not a percentage — every control inside
it sizes itself as a fraction of that constant.
- Raspberry Pi / aarch64 Linux:
make arm64cross-compilessynth_engine(headless; no GUI target for this build) from an x86_64 nix-shell. - Windows:
hds-windows.clap/hds_fx-windows.clapare cross-compiled with mingw-w64 and needlibmcfgthread-N.dllalongside them (copied automatically by the build) — everything else statically links. - PipeWire: auto-detected at build time via pkg-config;
makeprints whether it found it. When found, it is the standalone's default audio backend (--backend alsastill selects ALSA); without it, the build is ALSA-only and ALSA is the default. - Android (experimental, unofficial — currently disabled: its SDK entries in
shell.nixand themake androidtarget are commented out, sonix-shellneeds no license acceptance. Uncomment the lines markedANDROID DISABLEDto re-enable.):src/targets/android/hds_android.c+android/builds a real touchscreen native GUI (the same Cairo-drawn tab bar ashds.clap, including the Recording tab) with AAudio I/O, raw MIDI in viaandroid.media.midi, no OSC. Both AAudio streams (output, and a best-effort input onceRECORD_AUDIOis granted) are opened against the real device/channel count a connected class-compliant USB audio interface reports — seehds_android.c's own "Real external audio input" section — so a multichannel USB interface's inputs reach ext-in/the Recording tab's raw channels, and its outputs get HDS's own multichannel routing, not a stereo downmix. There's no on-screen device picker (Android routes to whatever's plugged in/selected at the OS level; the Devices tab is Polyphony + Block Size only here). File picking (NAM Model/IR, the Play tab's .sfz, the Global sidebar's .scl) goes through the real Android system picker (Storage Access Framework) rather than this GUI's own in-house browser, which can't reach arbitrary user storage under scoped storage — a picked file's real bytes are copied into an app-private cache path first, so this fully supports any self-contained single file (NAM model/IR, .scl), but a multi-sample .sfz with sample= paths relative to its own directory won't resolve its sibling samples this way (seehds_fx_gui_draw.c's ownhds_fx_gui_browser_open()comment — real folder-tree support is a separate, not-yet-done follow-up). The Recording tab's output folder is always this app's own real, writable, permission-free app-private directory; its Browse button is a no-op on this platform (SAF's folder-picking equivalent returns acontent://tree, not a POSIX path the recorder's ownfopen/fseek-based WAV writer could use).tools/build_android_manual.shproduces a real signed APK. Seeandroid/README.mdfor how the SDK/NDK get fetched, what's verified, and the real D8 compatibility bug it works around.
Vendored under third_party/: the CLAP SDK, Eigen, and Neural Amp Modeler
Core (NAM). The circuit-modeled dynamics processors (FetComp, FairKid67,
OptoComp) and the Airwindows ports above are otherwise self-contained C
ports with no external dependency — see src/fx/fx_types.h for sources.
