CL-1B optical compressor model (S6 + TFiLM, bounded gain)
A neural model of the Tube-Tech CL 1B optical compressor. It maps mono Dry audio and the front-panel settings (Threshold, Ratio, Attack, Release) to the compressed Wet signal, sample by sample, at 48 kHz. Exported to ONNX as a streaming model with explicit recurrent state.
Model
- Backbone: two S6 blocks (Mamba-1–style selective state-space model, width 8, state 16) around a conditioning stage. Threshold and Ratio feed a static FiLM; Attack and Release feed a GRU temporal FiLM. The input is a 64-sample Dry history plus its 128-point magnitude spectrum.
- Output: a per-sample gain bounded to 0–2 (
2·sigmoid); Wet = Dry × gain. The bound prevents gain spikes after near-silence. - Size: 5,985 parameters (36 KB checkpoint). The ONNX file is 30 MB because the graph unrolls the 512-step selective scan.
Files
| File | Content |
|---|---|
s6_tfilm_bounded_chunk512.onnx | Streaming ONNX model, opset 18, 512-sample chunks |
example_stream.py | Process a WAV with ONNX Runtime |
s6_tfilm_bounded_epoch22.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 | Meaning |
|---|---|---|
dry | [B, 512] | Dry audio, float32, full scale (±1), 48 kHz |
controls | [B, 4] | (-threshold_db/40, (ratio-2)/8, attack/4, release/4); Threshold −40…0 dB, Ratio 2…10, Attack and Release positions 0…4 |
history, conv1, ssm1, condition, conv2, ssm2 | [B,63], [B,16,3], [B,16,16], [1,B,16], [B,16,3], [B,16,16] | Recurrent state; start every recording at zero |
wet | [B, 512] | Predicted Wet |
next_* | as above | State to feed into the next chunk |
Feed chunks in time order and pass each next_* output back as the matching input. Pad the last chunk with zeros and discard the padded output. The scores below skip the first 49,152 samples (about 1 s) after a zero start, while the state settles.
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), each one setting of a 5×5×5×5 Attack × Release × Ratio × Threshold grid. Makeup gain is 0 dB in every recording.
- Split: by audio content, shared across all settings. Training uses about 29.5 h of intervals, validation 4.9 h, and test 2.97 h (the last ~20 s of every recording).
- Training: full intervals streamed chronologically with state carried across 1,024-sample chunks (batched truncated BPTT), 50 epochs, batch 128, lr 3e-4. Epoch 22 was selected by the per-file mean ESR on validation; this rule was fixed before training, and the test set played no part in any choice.
Results on the full test split (620 files, 2.97 h, lower is better):
| Model | Mean ESR per file | Median ESR | Pooled ESR | Files with ESR > 1 |
|---|---|---|---|---|
| This model | 0.055 | 0.026 | 0.025 | 0 |
| RiccardoVib published model (reference) | 0.137 | 0.083 | 0.046 | 0 |
| S4 + TFiLM, same training pipeline | 0.148 | 0.070 | 0.069 | 2 |
ESR = error energy ÷ target energy.
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 ≤ 8×10⁻⁸ and the largest sample difference is 1.4×10⁻⁴.
Limitations
- One device, one training run. The model covers one CL 1B unit and was trained with a single seed (7).
- Coverage. Settings between the recorded grid points, and makeup gain other than 0 dB, were never seen in training.
- Generalization to unseen settings is not established. In a separate experiment, an S6 model trained without the Threshold −40 dB settings did markedly worse on them, and the result varied strongly with the seed.
- 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.