Components#
tanh-lib is seven independently buildable library targets. Each is an
add_library of its own, exported as tanh::<Component> both in-tree and
from the installed package, and enabled by a TANH_BUILD_<COMPONENT> option.
Everything lives in namespace thl, inside the inline ABI namespace
thl::v<major>_<minor> (TANH_ABI_NAMESPACE), so that two copies of
tanh-lib in one process stay apart; code spells thl:: (see
Symbol visibility). The core is defined by tanh_add_core_library()
(cmake/core-library.cmake), which an embedder also uses for a private copy.
Core#
tanh::Core (include/tanh/core/, src/core/) is the foundation the
other components build on:
thl::Dispatcher— event messaging between subsystemsthl::Logger— leveled logging with pluggable sinks and a real-time path,thl::Logger::rt, that never allocates or blocksthl::RCU— lock-free read-copy-update for data the audio thread reads while another thread replaces it. A writer publishes in one call (update(),replace()) or in two steps:stage_update()/stage_replace()do everything that can fail,commit()cannot fail and allocates nothing, so a change that spans several RCUs is staged in full and then committed in fullthl::core::LockFreeQueue— a bounded lock-free MPMC queuethl::core::Buffer,thl::core::BufferView,thl::core::RingBuffer,thl::core::MemoryBlock— header-only containers with no dependency on the logger, so a permissively licensed consumer can embed them unchangedread_wav(WavReader.h) — a header-only WAV decoderthl::core::Thread— an OS thread with a requested scheduling class
Core links no platform system library by default; the Linux journald sink is
opt-in through TANH_WITH_JOURNALD. Allocation failure in the containers
throws std::bad_alloc; contract violations assert.
State#
tanh::State (include/tanh/state/) stores parameters in a hierarchy
addressed by dot-separated paths such as "oscillator.frequency". Reads are
RCU-protected, so the audio thread can look a value up without taking a lock;
numeric parameter types (double, float, int, bool) are fully
real-time safe. Serialization to and from JSON goes through nlohmann_json.
Depends on Core.
DSP#
tanh::DSP (include/tanh/dsp/) holds the processors: synth voices,
effects, filters, analysis helpers and the Rings resonator model, which is also
available as the separate tanh::Resonator target for consumers that only
need it. Processors inherit thl::dsp::BaseProcessor and follow the
prepare() / process() contract; process_modulated() splits a block
at change points for sample-accurate automation.
Sample playback is split into components usable on their own:
thl::dsp::sampler—thl::dsp::sampler::SamplePlayer, a varispeed player / looper with click-free loop crossfades, zero-crossing snap and reverse playback, plus its building blocks (see Sampler: play head and looper)thl::dsp::slicing—thl::dsp::slicing::SliceMapand the offlinethl::dsp::slicing::TransientSlicer(see Slicing)thl::dsp::pitch—thl::dsp::pitch::PitchBank, pitch-shifted copies of a sample (see Pitch banks)thl::dsp::granular—thl::dsp::granular::GrainEngine, a standalone granulator, andGrainProcessorImpl, a voice that composes the engine and the player behind a parameter enum
Depends on Core; Signalsmith Stretch is fetched and linked privately for the pitch banks.
Modulation#
tanh::Modulation (include/tanh/modulation/) routes modulation sources
(LFOs, UI-driven input queues and any other
thl::modulation::ModulationSource) to DSP parameters through the
thl::modulation::ModulationMatrix. The matrix records change
points per block and drives the processors’ sub-blocking. See Modulation: input events
for the input-event design. Depends on Core, State and DSP.
AudioIO#
tanh::AudioIO (include/tanh/audio-io/) is the cross-platform audio
device layer over miniaudio: device enumeration, playback, capture and duplex
streams through thl::AudioDeviceManager, with
platform-specific code for iOS and Android. See AudioIO: Android notes for the Android
Bluetooth notes. Depends on Core.
Net#
tanh::Net (include/tanh/net/) delivers versioned file sets over HTTPS,
for model or sample packs too large to bundle: thl::net::HttpClient
(GET to a file or string, Range resume, progress with cancellation) over the
platform HTTP stack, thl::net::Sha256 for verification and
thl::net::AssetStore for the verified, atomic install into
<root>/<id>/<version>/. Off by default (TANH_BUILD_NET) so nothing that
embeds tanh::Core inherits a network stack. Depends on Core.
Graph#
tanh::Graph (include/tanh/graph/) runs BaseProcessor nodes as one
processor: thl::graph::Graph is edited on the control thread and
handed to the audio thread at commit() with a short fade, nests, mixes each
node’s sources and blends its wet signal, and compensates latency: the faster
inputs of every node and a node’s dry path are delayed to match each node’s
latency_samples(), and the graph reports its own. A bypassed node coming
back is reset(). Off by default (TANH_BUILD_GRAPH). Depends on Core and
DSP.
Platforms#
macOS 12+, iOS 14+, Android, Linux, Windows and WebAssembly (Emscripten).
cmake/tanh/platform.cmake resolves the target into TANH_OPERATING_SYSTEM
and TANH_BINARY_FORMAT and defines exactly one THL_PLATFORM_* macro,
which tanh::Core carries as a public compile definition.
Licenses#
Core is Apache-2.0; every other component is AGPL-3.0. See License.