Skip to content

About

Ultra-low latency, real-time standalone PipeWire host application for Neural Amp Modeler (NAM) simulation on Linux

Resources

Stars

7 stars

Watchers

1 watching

Forks

Latest commit

Β 

History

110 Commits

Folders and files

Repository files navigation

NAM-Audio-Pipe

License Rust PipeWire Arch Latency RT-Safe SIMD Parity Recording

NAM-Audio-Pipe is an ultra-low latency, real-time standalone PipeWire host application for Neural Amp Modeler (NAM) simulation on Linux.

Turn your Linux machine into a world-class, instantaneous guitar amplifier or studio rig. Powered directly by the cutting-edge NeuralAmpModeler-rs engine (v4.1.0), NAM-Audio-Pipe connects directly to your native PipeWire audio graph without requiring heavyweight digital audio workstations (DAWs), complex JACK bridging, or Wine emulation layers.

Whether practicing at home, tracking live in the studio, or performing on stage, NAM-Audio-Pipe delivers studio-grade tone with analog-like responsiveness, sub-millisecond buffer sizes, zero dropouts, and one-touch lock-free WAV recording.


⚑ Why NAM-Audio-Pipe?

NAM-Audio-Pipe inherits the relentless engineering, mathematical precision, and raw performance of the NeuralAmpModeler-rs core engine, wrapping it in a standalone Linux application designed specifically for musicians and audio professionals:

🎯 1. 100% Bit-Exact Numerical Parity with C++ NAMCore

You get the exact, authentic tone of your favorite amp models. The underlying engine is verified under a continuous dual-oracle regression suite against both the reference C++ NAMCore ($f32$) and a double-precision $f64$ mathematical oracle tracking 52 model baselines in NeuralAmpModeler-rs:

  • WaveNet A1/A2 Models: Maintains Error-to-Signal Ratio (ESR) $< 2.31 \times 10^{-14}$ against NAMCore and $9.05 \times 10^{-15}$ against the $f64$ oracle ($136.4\text{ dB}$ SNR).
  • ConvNet Models: Achieves ESR $< 9.33 \times 10^{-16}$ ($150.3\text{ dB}$ SNR).
  • Perceptual Metric Validation: All models verify multi-resolution STFT distance (MR-STFT $< 6.5 \times 10^{-6}$), spectral convergence, and LUFS loudness constancy.
  • Full Model Coverage: Loads standard .nam (JSON) and lightning-fast pre-transposed .namb v2 (binary, Gate-Major LSTM / Interleaved-4 WaveNet with CRC32, $< 1\text{ ms}$ load time) models across all major architectures: WaveNet A1/A2, LSTM (1 & 2 layers, multi-I/O), ConvNet, Linear FIR/FFT, and Sequential compositions.

πŸš€ 2. Unmatched CPU Efficiency & Headroom

Hand-written vector SIMD compute kernels (x86-64-v3 AVX2/FMA baseline) monomorphized at compile-time with zero virtual dispatch:

  • Massive Real-Time Headroom: On modern hardware (e.g., AMD Ryzen 7 5700U), a WaveNet Standard model processes a 64-sample buffer in just $41.26\text{ Β΅s}$β€”consuming only $3.1%$ of the available $1.33\text{ ms}$ real-time budget. Modern WaveNet A2 models execute in $13.76\text{–}18.68\text{ Β΅s}$ ($1.0\text{–}1.4%$), and lighter LSTM profiles execute in as little as $6.44\text{ Β΅s}$ ($0.5%$ CPU).
  • Const-Generic Optimization & Dynamic Topologies: Features 24 distinct model variants (16 static const-generic profiles + zero-allocation dynamic fallbacks). Canonical channel counts ($CH=16, 12, 8, 4, 3$), kernel sizes, and receptive fields are monomorphized at compile time, enabling aggressive LLVM loop unrolling and register allocation.
  • Zero-Vtable Dispatch: The static dispatch_simd! engine eliminates all indirect function pointers and vtable lookups on the audio path. Compute kernels utilize tap-major memory layouts and instruction-level parallelism (sum0..sum3) unrolling.
  • Adaptive Compute FSM: Dynamic CPU load-monitoring state machine with hysteresis (--slim auto) that automatically throttles model complexity under system spikes (Full β†’ Reduced β†’ Minimal) using 32 ms click-free linear crossfades to prevent buffer dropouts.
  • Microarchitecture Layout Optimization: Compiled with Profile-Guided Optimization (PGO) and LLVM BOLT instruction reordering, validated and promoted through the automated A/B optimization ceremony (utils/ab-opt-ceremony.sh) to maximize CPU Instruction Cache (I-Cache) and TLB hit rates.

πŸ›‘οΈ 3. Strict Hard Real-Time Determinism (The Three Laws of Audio DSP)

Engineered from the ground up for zero-dropout live playing:

  • Zero Heap Allocations: Scratch memory, model weights, and resamplers are pre-allocated. No malloc or free ever occurs on the audio thread (audited via CountingAllocator).
  • Zero Mutex Locks & 3-Tier GC Cascade: State changes, model swaps, and telemetries communicate across bounded lock-free Single-Producer Single-Consumer (SPSC) rings backed by a 3-tier garbage collection cascade (SPSC queue β†’ 16-slot parking lot β†’ overwrite ring), ensuring safe off-RT resource deallocation without audio thread stalls.
  • Zero Blocking I/O: Filesystem access, socket IPC, and logging macros are strictly excluded from the audio callback.
  • Denormal & Subnormal Armor: Injects symmetric $-220\text{ dBFS}$ deterministic dither ($1.0 \times 10^{-11}$) combined with hardware MXCSR FTZ/DAZ reassertion on every processing block, preventing 10–100Γ— CPU microcode penalties during digital silence with zero net DC drift.

πŸ”Š 4. Studio-Grade Native DSP Suite

No external audio libraries or third-party wrappers needed:

  • Zero-Latency Cabinet Simulation & SPA Delay Accounting: Single exclusive cabinet slot (--cab) supporting Uniformly Partitioned Overlap-Save (UPOLS) FFT convolution for .wav impulse responses ($1.24\text{ Β΅s}$ for 2048-sample IRs, configurable --cabsim-partition 32–256 samples) or 1-in/1-out .nam/.namb neural cabinet models at strict unity gain (isolated from amp calibration and --ir-level-policy), plus independent --cab-bypass with 64-sample cosine crossfade. Algorithmic priming latency is strictly declared to the PipeWire graph scheduler via SPA latency properties (SPA_PARAM_Latency), preserving constant delay compensation even while cabinet bypass is engaged (see docs/latency-spa-adr.md).
  • Minimum-Phase Polyphase Sinc Resampling: Native 256 phases Γ— 64 taps Kaiser sinc resampler (Kaiser $\beta=12$, $>105\text{ dB}$ stopband attenuation, $< 0.05\text{ dB}$ passband ripple, zero pre-ringing, $0.65\text{–}1.30\text{ Β΅s}$ execution) seamlessly adapts 48 kHz models to any host sample rate (44.1 kHz, 96 kHz, 192 kHz).
  • Half-Band Anti-Aliasing Oversampling: Multi-stage half-band polyphase FIR filters (Off, 2x, 4x, $>100\text{ dB}$ stopband attenuation) attenuate non-linear high-frequency foldover distortion on screaming high-gain leads. Experimental until SRI: fixed-rate models shift timbre when oversampled.
  • Selectable Activation Precision: Choose between standard (exact Taylor minimax, +89.5 dB SNR) and fast (PadΓ© polynomial minimax approximation) to tailor math precision against CPU cycles.
  • Selectable Noise Gate Topologies (--gate-mode): Choose between musical (default log-domain continuous expander triggering pre-calibration and attenuating post-model / pre-CabSim IR to preserve natural cabinet tails) and silence (dual-threshold Schmitt gate with CPU-skipping shutoff), plus the C++-parity legacy expander.
  • Deliberate DSP Architectural Boundaries:
    • Omission of Integrated Tone Stack (EQ): Omitted by deliberate design to keep the standalone pipeline lean, deterministic, and modular. Equalization and tone shaping are best placed within the PipeWire graph via dedicated audio filter nodes or external visual patchbays (e.g. qpwgraph + Calf/LSP/Carla plugins).
    • Omission of Post-Cabinet DC Filter: Omitted by deliberate design. While symmetrical dither and floating-point denormal armoring prevent hardware microcode slowdowns, there is no claim of absolute immunity to DC offset (which may arise from asymmetric non-linear models). Users requiring steep sub-bass DC filtering can route the stream through a high-pass filter in the audio graph. This decision remains open and may be reevaluated in future revisions based on user requirements.

πŸ’Ύ 5. High-Performance Asynchronous WAV Recording (--record)

Capture your tone directly to pristine 32-bit float stereo WAV files without touching DAW software:

  • Zero-Impact io_uring Engine: Audio samples travel through a pre-allocated 64 KiB slot pool transport with safe, non-nullable memory references (~57% lower memory traffic than traditional rings) and write to disk via Linux tokio-uring.
  • Crash-Resilient Header Checkpointing: Automatically updates WAV header chunk lengths and invokes fsync every 3 seconds. An unexpected power outage or signal kill loses at most 3 seconds instead of destroying the entire recording.
  • Automatic 4 GiB RIFF File Splitting: Seamlessly splits extended jam sessions into continuous, gapless _partN.wav segments.
  • Continuous Capture Across Gate Pauses: In --gate-mode silence, a gate-closed quantum is committed as a zero-copy intentional-silence marker β€” the RT thread only sends the frame count and the disk worker writes the matching zero frames. The take keeps its real duration (including rehearsal pauses) without copying zeros on the audio thread. Genuine transport loss (pool starvation, full ring) is never padded: it is counted as overrun and reported as a lossy capture. --gate-mode musical records continuously with expanded tails.

🐧 6. Deep Linux Real-Time Hardening

Optimizes the operating system kernel for audio automatically on launch:

  • Locks application memory into physical RAM (mlockall) to prevent disk paging.
  • Pins Power Management DMA latency to 0 Β΅s (/dev/cpu_dma_latency), eliminating CPU C-state wake-up lag.
  • Profiles /proc/interrupts in real-time to bind the audio thread to the least-contended CPU core away from hardware device IRQs.
  • Disables Transparent Huge Pages (THP) to prevent background kernel memory compaction jitter.

🎸 Quick Start for Beginners (Plug & Play in 60 Seconds)

Getting started with guitar on Linux has never been easier. You do not need to configure JACK, compile kernel patches, or launch complex software suites.

       Guitar / Bass
             β”‚ (1/4" Instrument Cable)
             β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ USB Audio Interface     β”‚
β”‚ (Focusrite, Behringer,  β”‚
β”‚  PreSonus, MOTU, etc.)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
             β”‚ (USB)
             β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Linux Machine (PipeWire Audio Graph)                        β”‚
β”‚                                                             β”‚
β”‚   [Capture: Guitar DI] ──► [NAM-Audio-Pipe] ──► [Speakers]  β”‚
β”‚                                  β”‚                          β”‚
β”‚                                  └──► (WAV Recording)       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Step 1: Compiling System Dependencies

On Ubuntu, Debian, Pop!_OS, or Linux Mint:

sudo apt update && sudo apt install -y build-essential pkg-config clang libclang-dev libpipewire-0.3-dev libspa-0.2-dev

Step 2: Grab a Guitar Model (.nam) & Cabinet IR (.wav)

Download free community-created amp models and impulse responses from:

Step 3: Run and Play

Plug in your guitar, select your instrument input in your system sound settings, and launch:

# Basic amp playback:
nam-audio-pipe --model ~/models/MyFavoriteAmp.nam

# Complete rig with amp model and speaker cabinet:
nam-audio-pipe --model ~/models/Plexi50W.nam --cab ~/irs/Greenback4x12.wav

You will hear your guitar processed with full neural simulation in real time!

πŸ’‘ Pro-Tip: Visual Patching & Innovative Routing with qpwgraph

On startup, NAM-Audio-Pipe Processed Output (NAM-Audio-Pipe-playback) auto-connects to your default speakers/headphones, while NAM-Audio-Pipe Input (NAM-Audio-Pipe-input, virtual Audio/Sink) starts unconnected so you choose which hardware interface or desktop application feeds the rig. PipeWire's dynamic multimedia graph lets you route any audio source through the neural amp rig with zero extra quantum latency.

Using a visual patchbay tool such as qpwgraph (or Helvum), follow these routing rules:

  • Guitar DI / Live Playing: Connect your audio interface capture port (e.g., capture_FL / capture_FR) to NAM-Audio-Pipe Input (playback_FL / playback_FR). Note that the capture sink is created with StreamFlags::EXCLUSIVE, so only one input source should be patched into it at a time (use an external mixer node if you want to blend multiple sources).
  • Creative Re-Amping & Tone Coloration (VLC / Browsers / Synths): Patch your application (Firefox, Chromium, VLC, MPV, software synthesizers, or drum samplers) straight into NAM-Audio-Pipe Input β€” and disconnect the application's direct link to your speakers/headphones (otherwise you will hear the dry unprocessed signal mixed over the processed output).
  • Never Patch NAM-Audio-Pipe Input:monitor_FL/FR to Speakers: PipeWire's Audio/Sink monitor ports tap the incoming audio before DSP processing. Processed audio always exits exclusively from NAM-Audio-Pipe Processed Output.
  • Jam Along with Backing Tracks: Route your browser or music player directly to your speakers/headphones while keeping only your guitar routed through NAM-Audio-Pipe Input.
  • Live Dynamic Re-Routing: Connections can be made, broken, or rerouted on the fly while playingβ€”no audio dropouts, no driver reloading, and no engine restarts needed.

Install qpwgraph easily via your package manager:

sudo apt install qpwgraph   # Debian / Ubuntu / Pop!_OS
# or via Flatpak: flatpak install flathub org.rncbc.qpwgraph

πŸ₯Š Feature Showcase & Technical Matrix

Capability Technical Implementation Practical Musician / Engineering Impact
Neural Amp Simulation Full NeuralAmpModeler-rs engine (WaveNet A1/A2, LSTM, ConvNet, Linear, Sequential) Authentic tube amp tone with exact dynamic feel and pick-attack nuance
Native PipeWire Routing Direct Client API (libpipewire-0.3-dev $\ge 0.3.41$) via pipewire crate Seamless integration with qpwgraph, Helvum, and system audio patchbays
Latency Benchmark Native quantums down to 64 samples ($1.33\text{ ms}$ at 48 kHz) Imperceptible latency matching real analog hardware amplifiers
SPA Latency Publication Real-time SPA_PARAM_Latency synchronization based on active DSP stages and graph rate Exact host delay compensation preventing phase alignment errors in complex graphs
Real-Time Safety Strict zero heap allocations, zero mutex locks, zero blocking I/O Absolute reliability on stage and in the studioβ€”no audio glitches or xruns
Numerical Accuracy Dual-oracle verified against C++ NAMCore $f32$ & $f64$ oracles (52 model baselines) Laboratory-grade fidelity ($>136.4\text{ dB}$ SNR on WaveNet, $>150.3\text{ dB}$ on ConvNet)
Const-Generic Profiles 24 model variants (16 static compile-time profiles $CH=16, 12, 8, 4, 3$ + dynamic fallbacks) Compile-time loop unrolling and optimal register allocation for canonical architectures
Low-Latency Cabinet Slot Exclusive slot for .wav IR (UPOLS FFT) or 1x1 .nam/.namb cabs + --cab-bypass Natural cabinet tone ($1.24\text{ Β΅s}$ UPOLS for 2048-tap IRs) with constant-latency bypass
Multi-Rate Resampling 256-phase Γ— 64-tap Kaiser sinc resampler (>105 dB stopband, <0.05 dB ripple) Pristine 44.1/48/96/192 kHz rate conversion in 0.65–1.30 Β΅s with zero pre-ringing
Anti-Aliasing Oversampling Multi-stage half-band polyphase FIR filtering (2x exp., 4x exp., $&gt;100\text{ dB}$ stopband) Attenuates high-frequency aliasing; timbre shifts until SRI oversampling
Activation Math Modes standard (exact Taylor minimax) vs fast (PadΓ© polynomial approximation) Balance maximum floating-point precision (+89.5 dB SNR) against minimal CPU cycles
Calibration & Output Safety Per-sample ParamSmoother trims/calibration, resilient metadata (strict opt-in), 5 Hz DC blocker, and soft-clip/true-peak/clamp playback limiter Click-free gain staging, transparent DC removal, and protected monitoring with raw recording
Dual Noise Gate Topologies silence (10 dB Schmitt hysteresis, CPU-skip) or musical (pre-IR quadratic expander) Eliminates pickup noise cleanly or lets natural cabinet tails ring out smoothly
Binary .namb v2 Format Pre-transposed memory layout (Gate-Major LSTM, Interleaved-4 WaveNet) with CRC32 Lightning-fast model loading and live hot-swapping in $&lt; 1\text{ ms}$ (vs ~50 ms JSON)
Denormal Armor Symmetric βˆ’220 dBFS dither injection + hardware MXCSR FTZ/DAZ Prevents 10–100Γ— CPU microcode stalls on digital silence with zero net DC drift
Asynchronous WAV Recording Non-blocking slot pool transport with safe references + Linux tokio-uring engine Lossless 32-bit float stereo recording straight to disk with zero audio thread burden
Crash Protection Periodic 3-second header checkpointing & 5-second graceful signal shutdown Saves your take even if the host machine experiences a sudden power loss
Kernel Latency Tuning Real-time PM QoS ($0\text{ Β΅s}$), mlockall, THP disable, CPU IRQ isolation Prevents CPU sleep states and operating system scheduler interruptions
Adaptive Compute Dynamic CPU pressure monitoring (--slim auto) with 32 ms crossfading Automatically throttles model complexity under system overload to prevent dropouts
Desktop & Flatpak Deployment Standalone Flatpak bundle with AppStream metadata & .desktop launcher 1-click install and sandboxed execution across all modern Linux distributions

πŸ† Measured Audio Fidelity & CPU Headroom

NAM-Audio-Pipe delivers world-class audio fidelity backed by the strict quality contract and empirical baselines established in NeuralAmpModeler-rs.

Dual-Oracle Parity & Perceptual Validation

Accuracy is validated against two co-equal reference oracles across 52 model baselines:

  1. Canonical C++ NAMCore Reference ($f32$): Verifies bit-exact behavioral parity across WaveNet A1/A2, LSTM, ConvNet, and Linear architectures.
  2. Double-Precision Reference ($f64$): Quantifies numerical ideality and eliminates floating-point rounding divergence.
Architecture / Model Error-to-Signal Ratio (ESR) Signal-to-Noise Ratio (SNR) Multi-Resolution STFT
WaveNet Standard $&lt; 2.31 \times 10^{-14}$ $&gt; 136.4\text{ dB}$ $&lt; 6.5 \times 10^{-6}$
WaveNet A2 $&lt; 2.10 \times 10^{-14}$ $&gt; 136.8\text{ dB}$ $&lt; 5.8 \times 10^{-6}$
ConvNet ReLU $&lt; 9.33 \times 10^{-16}$ $&gt; 150.3\text{ dB}$ $&lt; 1.2 \times 10^{-6}$
LSTM 1-Layer $&lt; 1.45 \times 10^{-14}$ $&gt; 138.2\text{ dB}$ $&lt; 4.1 \times 10^{-6}$

All models satisfy spectral convergence and LUFS loudness constancy invariants.

1. Bare DSP Engine Core Microbenchmarks (NeuralAmpModeler-rs)

Execution times for isolated DSP kernels measured per 64-sample block at 48 kHz ($1.33\text{ ms}$ real-time deadline budget) on an AMD Ryzen 7 5700U (x86-64-v3 AVX2 baseline, verified against NeuralAmpModeler-rs v4.1.0 baselines on rustc 1.100.0; crate MSRV remains 1.99.0):

Component / Profile Execution Time RT Deadline Budget Used Max Theoretical Instances
WaveNet Standard (CH=16) 41.26 Β΅s 3.1% ~32 instances
WaveNet Lite (CH=12) 51.86 Β΅s 3.9% ~25 instances
WaveNet Feather (CH=8) 14.63 Β΅s 1.1% ~91 instances
WaveNet Nano (CH=4) 11.97 Β΅s 0.9% ~111 instances
WaveNet A2 Full (CH=8) 18.68 Β΅s 1.4% ~71 instances
WaveNet A2 Lite (CH=3) 13.76 Β΅s 1.0% ~96 instances
LSTM 1-Layer (Hidden=16) 6.44 Β΅s 0.5% ~207 instances
LSTM 2-Layer (Hidden=8) 6.91 Β΅s 0.5% ~192 instances
ConvNet 9.30 Β΅s 0.7% ~143 instances
Linear FIR (RF=4 Direct) 0.17 Β΅s 0.01% >1,000 instances
DSP Resampler (44.1 kHz β†’ 48 kHz) 1.30 Β΅s 0.10% >1,000 instances
Cabinet IR Simulation (UPOLS 2048 taps) 1.24 Β΅s 0.09% >1,000 instances
Full Pipeline Base (Model + CabSim, No OS) 41.81 Β΅s 3.1% ~31 instances
Full Pipeline HQ (Model + CabSim + 4Γ— OS) 170.23 Β΅s 12.8% ~7 instances

2. Standalone PipeWire Real-Time Host Execution (nam-audio-pipe)

In live operation, nam-audio-pipe runs as a native PipeWire SPA client executing the complete end-to-end audio processing chain (Capture callback $\rightarrow$ Input gain & Noise Gate $\rightarrow$ Neural Model inference $\rightarrow$ UPOLS Cabinet Convolution $\rightarrow$ SPSC lock-free transport $\rightarrow$ Playback output):

Host Metric / Invariant Measured Specification Architectural Guarantee
Native Quantum Support Down to 64 samples ($1.33\text{ ms}$ at 48 kHz) Sub-millisecond buffer scheduling with zero driver jitter
Full Rig CPU Budget Used (64 samp) $&lt; 8%$ (WaveNet Standard + CabSim) Over $&gt; 92%$ CPU headroom preserved for system and desktop UI
Real-Time Memory Allocations 0 heap allocations Enforced via CountingAllocator in RT processing loop
Lock-Free Concurrency SPSC lock-free atomic queues Zero mutexes, zero blocking system calls in audio callback
Full-Chain Parity vs $f64$ Oracle WaveNet ESR $&lt; 1.05 \times 10^{-12}$, LSTM $&lt; 2.71 \times 10^{-11}$ Bit-exact perceptual accuracy validated in pipe_offline_parity.rs
Thread Priority & Stability SCHED_FIFO (priority 80–95) with PM QoS $0\text{ Β΅s}$ Deterministic audio deadlines with zero xruns under system load

Why This Matters for Live Guitarists: A complete standalone rig (WaveNet + CabSim + Noise Gate) executing within PipeWire uses only a fraction of a 64-sample quantum ($1.33\text{ ms}$ at 48 kHz). Musician players experience imperceptible latency indistinguishable from analog tube amplifiers, backed by ironclad real-time safety and zero audio dropouts.


πŸŽ›οΈ Musician's Playbook: Common CLI Recipes

1. The Clean Studio Rig (Crystal Clear Tone)

Ideal for clean jazz, funk, or acoustic simulation:

nam-audio-pipe \
  --model models/TwinReverb-Clean.nam \
  --cab irs/OpenBack2x12.wav \
  --gate -75

Tip: --gate -75 sets a gentle threshold, preserving delicate fingerpicking tails.

2. High-Gain Metal Lead with 4Γ— Oversampling

Eliminates aliasing foldover on heavy distortion leads:

nam-audio-pipe \
  --model models/HighGainDrive.nam \
  --cab irs/Vintage4x12.wav \
  --oversample 4x \
  --gate -50

Tip: --gate -50 silences single-coil hum and high-gain hiss between riffs.

3. Ultra-Low Latency Live Performance (64-Sample Quantum)

For maximum responsiveness during stage monitoring:

nam-audio-pipe \
  --model models/PlexiLead.nam \
  --cab irs/4x12-Greenback.wav \
  --buffer-size 64 \
  --activation fast

Tip: --activation fast selects PadΓ© polynomial activations for maximum CPU speed.

4. Practice & Record Jam Session to Disk

Records your complete processed guitar take directly to a timestamped WAV file:

nam-audio-pipe \
  --model models/OverdriveAmp.nam \
  --cab irs/Cab1x12.wav \
  --record \
  --record-dir ~/Music/GuitarJams

Files save as capture_YYYYMMDD_HHMMSS.wav. When --gate on is active, long silent pauses are trimmed automatically.

5. Running in Dry Bypass (Audio Interface / Latency Testing)

Stream dry audio through PipeWire without loading a model:

nam-audio-pipe --gate off

πŸ–₯️ Supported Platforms & Architectures

Architecture Platform Tier Continuous Integration Real-Time Hardware Certification Notes
Linux x86_64 Tier 1 (Reference) Blocking (lints, quick, msrv, long) Fully verified & certified Requires x86-64-v3 baseline (AVX2, FMA, BMI2). Supports full PGO + LLVM BOLT optimization pipeline.
Linux on ARM (aarch64) Tier 2 (Compatible) Blocking compile/lint (linux-arm64-lints) and quick test suite (linux-arm64-quick) Not formally tested on bare-metal hardware Compiles cleanly on native ARM64 runners (ubuntu-26.04-arm). Architecture flags are scoped in .cargo/config.toml, and pure-Rust SPA logging supports AAPCS64.

Note

Linux on ARM Status: While NAM-Audio-Pipe continuously compiles, passes static analysis, and is architecturally compatible on Linux on ARM (aarch64), formal validation on physical ARM audio workstations (such as real-time audio deadline certification, bare-metal ALSA/PipeWire driver testing, and hardware latency profiling) has not yet been formally conducted.


πŸ“¦ Installation & Packaging Options

NAM-Audio-Pipe can be run directly via Cargo, compiled into a standalone hyper-optimized binary, or installed as a sandboxed Flatpak application.

Option A: Standalone Flatpak Application (Recommended for Users)

NAM-Audio-Pipe is packaged as an autonomous desktop Flatpak (io.github.fabiohl.NAMAudioPipe), targeting the org.freedesktop.Platform//26.08 runtime. It provides an isolated, reliable environment with direct low-latency PipeWire IPC access.

Install Local Bundle

flatpak install --user --reinstall target/dist/nam-audio-pipe-v1.3.0-linux-x86_64-v3.flatpak

Run via Flatpak

# 1. Inspect environment diagnostics:
flatpak run io.github.fabiohl.NAMAudioPipe --diagnose

# 2. Run amp simulation reading models from your home directory:
flatpak run io.github.fabiohl.NAMAudioPipe \
  --model ~/models/Amp.nam \
  --cab ~/irs/Cabinet.wav \
  --buffer-size 64

The Flatpak bundle exports native desktop launchers and high-resolution icons to your application menu, including desktop actions for Run in bypass and Diagnostics.


Option B: Simple Direct Cargo Build (Development & Testing)

For developers working on source code or rapid testing on x86_64 or Linux on ARM:

# Direct development execution:
cargo run --release --bin nam-audio-pipe -- --model /path/to/amp_model.nam

# Build standard release binary:
cargo build --release --bin nam-audio-pipe

The compiled binary will be located at target/release/nam-audio-pipe.

Building on Linux on ARM (ARM64): Standard Cargo compilation works out-of-the-box (cargo build --release --bin nam-audio-pipe). Microarchitecture flags (x86-64-v3) in .cargo/config.toml are automatically scoped to x86_64 targets, generating clean, native AArch64 code on ARM systems.


Option C: Hyper-Optimized Native Binary (./utils/build-release.sh)

For maximum performance in mission-critical live setups and stage environments, compile using the automated multi-stage optimization pipeline combining Profile-Guided Optimization (PGO) and LLVM BOLT:

# 1. Build hyper-optimized PGO + LLVM BOLT binary into target/dist/:
./utils/build-release.sh --strict

# 2. Run the long audit against the canonical artifact:
./utils/tests-long.sh --strict --artifact

# 3. Certify and install locally to ~/.local/bin/nam-audio-pipe:
./utils/build-release.sh --strict --certify --install
Canonical Option Purpose
--strict Enforces fail-closed mode: PGO is mandatory, BOLT requires ceremony proof (target/logs/ab-opt-ceremony-receipt.json), and unproven gaps abort
--package Generates distribution tarball (.tar.zst) and Flatpak bundle (.flatpak) in target/dist/
--certify Does not recompile: validates artifact SHA-256 and reconciles build receipt with long audit evidence
--install Valid with --certify: installs the certified binary to ~/.local/bin/nam-audio-pipe (and Flatpak if packaged)
-h, --help Displays command-line help screen and exits

This automated builder executes:

  1. Profile-Guided Optimization (PGO): Instruments DSP kernels across quantum matrices (32 to 1024 frames) and model families, generating profile traces to guide branch prediction and loop vectorization.
  2. LLVM BOLT: Rearranges basic blocks in machine code using Linux perf sample traces to minimize CPU Instruction Cache (I-Cache) and TLB misses.
  3. Automated A/B Optimization Ceremony: Evaluates median P99 cycles across all canonical topologies (wavenet_a1, wavenet_a2, lstm) with an explicit 1.0% promotion margin (utils/ab-opt-ceremony.sh, using llvm-bolt -instrument + merge-fdata when hardware LBR is absent), cleanly falling back to proven PGO-only or proven plain release when higher-tier margins are not met.
  4. Static Hotspot Gates: Enforces zero zmm registers (AVX-512 opt-in policy), zero libm calls in RT paths, and zero heap allocations.
  5. Verified Local Installation (--certify --install): Reconciles the build and audit receipts, then installs the verified artifact directly to ~/.local/bin/nam-audio-pipe.

Option D: Official Release & Certification Chain (Production)

For distributors and release publishing, the official release pipeline enforces strict separation between compilation, stress testing, and cryptographic verification:

# 1. Build canonical optimized release artifact and packages into target/dist/
./utils/build-release.sh --strict --package

# 2. Audit the canonical artifact under heavy soak, RT deadline, and zero-alloc stress
./utils/tests-long.sh --strict --artifact

# 3. Certify release compliance using the generated receipts and install without recompilation
./utils/build-release.sh --strict --certify --install

πŸŽ›οΈ Command-Line Interface (CLI) Reference

nam-audio-pipe [OPTIONS]
Flag / Option Parameter Domain / Values Default Operational Description
-m, --model <FILE> Filepath (.nam, .namb) None (Bypass) Path to neural amplifier model file. Invalid path fails fast before PipeWire initialization.
-c, --cab <FILE> Filepath (.wav, .nam, .namb) None (Bypass) Path to cabinet asset (.wav IR or 1-in/1-out neural cabinet). Invalid asset fails with code 4 unless --cab-optional.
--cab-optional Flag false Missing or unreadable --cab warns and continues without cabinet simulation.
--cab-bypass Flag false Starts with cabinet slot bypassed at constant SPA latency (crossfade & dry-delay aligned).
-i, --input-gain <DB> Float (-96.0 to +30.0 dB) 0.0 Input gain adjustment prior to neural inference.
-o, --output-gain <DB> Float (-96.0 to +30.0 dB) 0.0 Output gain adjustment after cabinet simulation.
-b, --buffer-size <SAMPLES> {0} βˆͺ {2^k | 16 ≀ 2^k ≀ 8192} 256 PipeWire quantum block size in samples (0 for auto-negotiation).
--cabsim-partition <N> 32, 64, 128, 256 samples 128 Cab-sim UPOLS partition size. Lower values reduce algorithmic latency at slight CPU cost.
--ir-level-policy <MODE> loudness-normalized, rms, peak-normalized, preserved, legacy-nam-plugin loudness-normalized Cabinet IR gain policy applied per channel (stereo WAV supported): continuous K-weighted LUFS normalization (default), flat RMS, peak normalization, 1:1 amplitude, or C++ scaling ($10^{-18/20} \times 48000/f_s$).
--calibrate-input <on|off> on, off, true, false, 1, 0 off Enables pre-nonlinearity input calibration using model input_level_dbu. Missing metadata warns and falls back to unity unless --strict-calibration.
--input-calibration-level <DBU> Float (-60.0 to +60.0 dBu) 12.0 Reference 0 dBFS input level in dBu for input calibration and calibrated output mode.
--output-mode <MODE> raw, normalized, calibrated normalized Output gain mode: unity (raw), -18 LUFS via loudness (normalized), or output_level (calibrated). Missing metadata warns and falls back to unity unless --strict-calibration.
--strict-calibration Flag false Fails startup with exit code 3 when requested calibration/output metadata is missing (default is warn + unity fallback).
--dc-blocker <on|off> on, off, true, false, 1, 0 on Post-IR 5 Hz DC blocker (f64 TDF-II). Removes offset before output trim and the playback limiter.
--output-limit <MODE> soft-clip, true-peak, clamp, off soft-clip Playback-only output protection: zero-latency residual-ADAA soft-clip, 4Γ— look-ahead true-peak (adds latency to SPA PDC), hard clamp, or off. --record float WAV output is never limited.
--oversample <off|2x|4x> off, 2x, 4x off Half-band polyphase anti-aliasing oversampling factor.
--activation <MODE> standard, fast standard Math precision: standard (exact Taylor minimax) vs fast (PadΓ© polynomial approximation).
--slim <auto|full|lite> auto, full, lite auto Adaptive compute: automatically swaps submodels under CPU pressure to prevent dropouts.
--gate <MODE> on, off, or [-96.0, -20.0] dBFS on (-70 dB) Gate enable/threshold configuration. Numeric thresholds derive Silence close value via 10 dB Schmitt relation.
--gate-mode <MODE> silence, musical, legacy musical Noise gate topology: musical (continuous pre-IR log-domain expander, default), silence (block-RMS CPU-skipping gate), or legacy (C++ parity).
--cpu <INDEX> Integer core ID Dynamic IRQ selection Manually binds the real-time audio thread to a specific CPU core.
--record Flag false Enables asynchronous 32-bit float stereo WAV recording via io_uring.
--record-dir <DIR> Directory path $XDG_MUSIC_DIR/NAM-Audio-Pipe (or ~/Music/NAM-Audio-Pipe, else .) Output directory for saved audio takes (auto-created if missing).
--fail-fast Flag false Disables bounded reconnect cycle: exits immediately on PipeWire daemon disconnect.
--reconnect-timeout <SECS> Seconds (integer >= 0) 11.75 (6 attempts) Caps the total reconnect retry backoff budget (0 behaves like --fail-fast).
--color <WHEN> auto, always, never auto (respects NO_COLOR) Controls ANSI color output for diagnostic banners and terminal messages.
--diagnose Flag false Emits technical diagnostic bundle and exits.
--diagnose-full Flag false Emits diagnostic bundle with unredacted raw paths and exits.
--pause Flag false Waits for Enter before exiting on interactive terminals (used by .desktop Diagnostics).
-h, --help Flag β€” Displays command-line help screen and exits.

Exit Code Taxonomy

NAM-Audio-Pipe returns typed exit codes to distinguish invocation mistakes from hardware or runtime failures:

Exit Code Classification Meaning / Trigger Condition Remediation Guidance
0 Success Normal termination or successful --help / --diagnose. None.
1 Generic / Forced Uncategorized failure or hard escalation after termination grace window timeout. Inspect application error logs.
2 Usage Error Invalid CLI arguments or non-power-of-two buffer size. Review command syntax with --help.
3 Model Load Error Model file missing/corrupt, unsupported architecture, or strict calibration metadata failure. Verify .nam/.namb integrity or metadata.
4 Cab Asset Error Cabinet asset (.wav IR or .nam/.namb cab) missing, invalid, or rejected. Check file path/format (must be 1x1) or use --cab-optional.
5 Backend Error PipeWire daemon unreachable or stream initialization failed. Check PipeWire daemon status (systemctl --user status).
6 Recording Error Recording directory unwritable, io_uring failed, or buffer overruns occurred. Check disk permissions and available space.

πŸ”€ PipeWire Graph Topology & Auto-Routing

On startup, NAM-Audio-Pipe registers dedicated capture and playback nodes in the PipeWire graph:

Internal Node Name Patchbay Label (qpwgraph) Media Class Function in Audio Graph
NAM-Audio-Pipe-input NAM-Audio-Pipe Input Audio/Sink (Input) Exclusive virtual capture sink (starts unconnected) receiving guitar DI or app audio
NAM-Audio-Pipe-playback NAM-Audio-Pipe Processed Output Stream/Output/Audio Auto-connected playback stream emitting processed audio to speakers or headphones
  • Causal Intra-Quantum Ordering: Both nodes share scheduling groups (node.group = "nam-audio-pipe-dsp" / node.link-group = "nam-audio-pipe-link-group"), and the playback stream uses PW_STREAM_FLAG_TRIGGER driven by the capture RT callback so capture and playback run in sequence within the same quantum (zero extra quantum latency).
  • SPA Latency Compensation: Stream latency properties (SPA_PARAM_Latency) publish the exact algorithmic delay (cab-sim partition latency + resampler + oversampling) in sample units to the graph scheduler, eliminating phase smearing and timing misalignment.
  • Default-Sink Auto-Connect & Dual-Stream Isolation: NAM-Audio-Pipe-playback delegates default hardware output selection to PipeWire/WirePlumber (AUTOCONNECT), while the isolated DspBridge separation between Audio/Sink capture and Stream/Output/Audio playback prevents monitor_* dry leakage and acoustic feedback loops.
  • Visual Patchbay Support: Nodes are clearly labelled and easily connected using visual patchbays such as qpwgraph, Helvum, or Carla. Seamlessly patch physical guitar inputs, desktop browsers, media players, software synthesizers, or DAW tracks into NAM-Audio-Pipe Input (NAM-Audio-Pipe-input) for instant live processing and re-amping (remembering to disconnect the source's direct speaker link and leave monitor_FL/FR unconnected).

πŸ§ͺ Quality Assurance & Verification Suite

NAM-Audio-Pipe maintains enterprise-grade reliability through an automated testing and verification suite located in utils/:

# 1. Static quality gate (formatting applied, check, clippy -D warnings, SPDX, AppStream):
./utils/lints.sh

# 2. Quick discipline (all non-ignored targets, development profile):
./utils/tests-quick.sh

# 3. Release chain (human operator only): build -> long audit -> certify.
# The long suite covers accelerated soak, zero-alloc heap audit, RT deadline/jitter,
# endurance, live PipeWire, io_uring and offline f64 parity.
./utils/build-release.sh --strict --package
./utils/tests-long.sh --strict --artifact
./utils/build-release.sh --strict --certify --install

For complete architectural details on testing, verification phases, and real-time compliance criteria, consult docs/testing.md.


πŸ“š Technical Documentation Directory

  • Gain staging contract: chain order, per-sample smoothing, calibration resolution and host range contracts.

  • Output protection: DC blocker, limiter policies, latency/PDC and the raw-recording invariant.

  • docs/architecture.md β€” Comprehensive architecture bible: dual-stream PipeWire topology, DspBridge shared memory layout, SPSC GC cascade, Linux RT hardening, and asynchronous io_uring WAV recording.

  • docs/testing.md β€” Testing architecture, unit/integration inventory, 11-phase long audit suite, script contract, and compiler optimization pipeline.

  • docs/latency-spa-adr.md β€” Architecture decision record: PipeWire SPA latency publication, sample-rate vs nanosecond evaluation invariants, UPOLS partition alignment, and graph delay compensation.

  • CHANGELOG.md β€” Project release history, version milestones, and feature additions.


πŸ™ Credits & Acknowledgments

  • Steven Atkinson β€” Creator of Neural Amp Modeler (NAM) for revolutionizing open-source deep learning guitar modeling.
  • The PipeWire Project (Wim Taymans and contributors) β€” For creating the high-performance Linux multimedia routing subsystem that makes ultra-low latency audio accessible to everyone.
  • Tone3000 / ToneHunt Community β€” For hosting and curating thousands of exceptional, free neural amp models for guitarists worldwide.

βš–οΈ License & AI Transparency

AI Transparency Note

The software architecture, real-time safety guarantees, DSP pipeline design, and microarchitectural optimizations are intellectual work (and passion) of the maintainer (FΓ‘bio Lima). Implementation and continuous refinement were accelerated through pair programming (Vibe Coding) using cutting-edge artificial intelligence models (Gemini, Claude, Grok, DeepSeek and others) within Google Antigravity IDE. AI is an amplifier of human intent, transforming ambitious vision into robust software.

License

This project is licensed under the GNU General Public License v3.0 or later (GPL-3.0-or-later). See LICENSE.txt for complete license terms. Third-party attribution for the Apache-2.0 NeuralAmpModeler-rs engine is in NOTICE, which is included in the distributed tarball and Flatpak bundle.

About

Ultra-low latency, real-time standalone PipeWire host application for Neural Amp Modeler (NAM) simulation on Linux

Resources

Stars

7 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages