CL-1B optical compressor model (S6 + TFiLM + circuit PINN)
A physics-informed neural model of the Tube-Tech CL 1B optical compressor. The S6 network predicts the states of a reduced equivalent circuit, and the circuit equations turn them into the Wet signal. Exported to ONNX as a streaming model with explicit recurrent and circuit state.
Companion model without the circuit: aaatmy/cl1b-s6-tfilm-onnx. That model is slightly more accurate on the test set (mean ESR 0.055 vs. 0.059).
Model
- Backbone: two S6 blocks (Mamba-1–style selective state-space model, width 8, state 16) around Threshold/Ratio FiLM and Attack/Release GRU temporal FiLM conditioning. The input is a 64-sample Dry history plus its magnitude spectrum.
- Circuit head: the network outputs three circuit states every sample:
- e: C3 control voltage, 0–30 V
- f: fast occupancy of the photo element, 0–1
- s: slow occupancy of the photo element, 0–1
- Circuit readout: the states set the light-dependent conductance; a front-panel resistor network and a soft-clipping amplifier then produce the Wet signal. Seven circuit parameters were learned with a prior.
- Physics loss: during training, the residuals of the circuit's three state equations were added to the loss, with a weight ramped from 0 to 1 over the first 10 epochs. This is a soft constraint: at inference the network's states are used as predicted. The residuals are returned as outputs for diagnosis.
- Size: 6,010 parameters (39 KB checkpoint). The ONNX file is 31 MB because the graph unrolls the 512-step selective scan.
Files
| File | Content |
|---|---|
s6_tfilm_pinn_chunk512.onnx | Streaming ONNX model, opset 18, 512-sample chunks |
example_stream.py | Process a WAV with ONNX Runtime, including the knob-to-circuit mapping |
s6_tfilm_pinn_ramp_epoch20.mdlus | Original PyTorch / PhysicsNeMo checkpoint |
training_config.json | Model and training settings |
verification.json | ONNX vs. PyTorch check on two recordings |
Inputs and outputs
| Name | Shape, type | Meaning |
|---|---|---|
dry | [B, 512] float32 | Dry audio, full scale (±1), 48 kHz |
controls | [B, 4] float32 | (-threshold_db/40, (ratio-2)/8, attack/4, release/4) |
pots | [B, 5] float64 | Circuit potentiometer positions (threshold wiper, (ratio-2)/8, attack/4, release/4, makeup_db); threshold wiper = log10(1 + 99·10^((−40−threshold_db)/20))/2 |
history, conv1, ssm1, condition, conv2, ssm2 | float32, as in the companion model | Network state; zero at the start |
physical | [B, 3] float64 | Circuit state (e, f, s) at the end of the previous chunk; zero at rest |
wet | [B, 512] float32 | Predicted Wet |
next_*, next_physical | as above | State for the next chunk |
residual_c3, residual_gre_fast, residual_gre_slow | [B, 512] float64 | ODE residuals of this chunk (diagnostic only) |
Settings: Threshold −40…0 dB, Ratio 2…10, Attack and Release positions 0…4, makeup 0 dB. example_stream.py computes both controls and pots.
pip install onnxruntime soundfile numpy
python example_stream.py input.wav output.wav --threshold -20 --ratio 4 --attack 2 --release 2
Training data and evaluation
- Data: the TubeTech CL-1B dataset by Riccardo Simionato (CC BY-SA 4.0). It has 620 stereo recordings (left Dry, right Wet) on a 5×5×5×5 Attack × Release × Ratio × Threshold grid.
- Split: by audio content. The test split is the last ~20 s of every recording, 2.97 h in total.
- Training: full intervals streamed chronologically with network and circuit state carried across 1,024-sample chunks, 50 epochs, batch 128, lr 3e-4, physics weight ramped 0→1 over 10 epochs. Epoch 20 was selected by the per-file mean ESR on validation; this rule was fixed before training.
Results on the full test split (620 files, lower is better):
| Model | Mean ESR per file | Median ESR | Pooled ESR | Files with ESR > 1 |
|---|---|---|---|---|
| S6 + TFiLM, bounded gain (companion) | 0.055 | 0.026 | 0.025 | 0 |
| This model (S6 + TFiLM + circuit PINN) | 0.059 | 0.030 | 0.034 | 1 |
| Original S6 + PINN (short-window training) | 0.352 | 0.114 | 0.122 | 42 |
| RiccardoVib published model (reference) | 0.137 | 0.083 | 0.046 | 0 |
Mean squared ODE residual on the test split: C3 0.043, fast 5.5×10⁻⁴, slow 2.3×10⁻⁴.
ONNX check (verification.json): 12 s of two recordings, streamed in 512-sample chunks from zero state. The ESR between ONNX Runtime and PyTorch is ≤ 1.5×10⁻⁷ and the largest sample difference is 5.9×10⁻⁵.
Limitations
- Single run. One device, one training run, one seed (7).
- Coverage. Only the recorded grid points and makeup 0 dB were seen in training.
- The physics does not guarantee extrapolation. In a holdout experiment with the Threshold −40 dB settings removed from training, physics-informed models of this kind did worse than the plain S6 on those settings. Their predicted C3 voltage did not rise with the lower threshold, and the soft constraint does not act at inference.
- The circuit parameters describe a reduced model, not the hardware. The 7 learned parameters moved well away from their nominal values (for example
gre_half0.12 → 1.64), so read them as fitting parameters. - Fixed format. Mono, 48 kHz only, fixed 512-sample chunks.
License and attribution
The model is trained on the TubeTech CL-1B dataset by Riccardo Simionato, licensed CC BY-SA 4.0. These weights are released under the same license.