argbind configurationΒΆ

faustax.fx supplies one snake_case factory for each effect: gain_fx, distortion_fx, parametric_eq_fx, compressor_fx, freeverb_fx. Each factory has an introspected signature with one keyword for each Faust slider. Thus argbind can configure each parameter as a <factory>.<param> YAML key, with the usual scope prefixes. This design matches the common trainer pattern in which the trainer instantiates transforms by name from a scoped, bound module:

compressor_fx.sample_rate: 44100
compressor_fx.threshold_db: [uniform, -40.0, -6.0]   # per-item draw
compressor_fx.ratio: [choice, [2.0, 4.0, 8.0]]
compressor_fx.attack_ms: 5.0                          # scalar = const
train/compressor_fx.prob: 0.5                         # scoped override

train/augment_batch.transforms: [compressor_fx]
import argbind
from faustax import fx as fx_lib

fx_lib = argbind.bind_module(fx_lib, "train", "val", "test", "gen")

@argbind.bind("train", "val", "test", "gen")
def augment_batch(rng, batch, transforms: list[str] = None):
    for name in transforms or []:
        transform = getattr(fx_lib, name)()   # args come from the config
        rng, subkey = jax.random.split(rng)
        batch = transform.random_map(batch, subkey)
    return batch

Each factory returns a configured faustax.audiotree.FaustFx. Thus you can put the factories in an augment_batch loop together with the audiotree transforms. When you call a factory directly, without argbind, the same keywords apply:

from faustax.fx import gain_fx

transform = gain_fx(sample_rate=44100, gain_db=["uniform", -12.0, 12.0])
print(type(transform).__name__)
FaustFx

The value syntax has two forms. A scalar means a fixed value (("const", v)). A list must start with a distribution kind: const, uniform (low, high), or choice (one list of values). A list without a kind causes an error at construction.

Note

argbind requires that the bound names are unique in each process. Thus bind only the NumPy flavor or the JAX flavor of a transforms library. Bind it one time, in one module. Usually, put the binding adjacent to the augment_batch function that uses it.