Coupling Operators
🥄 Mixer
Section titled “🥄 Mixer”sim_add_mixer_operator(ctx, lhs, rhs, out, opts)
Combine two inputs in-place or into a destination. Shared options:
lhs_gain,rhs_gain,bias(defaults 0),mix(0..1 for crossfade).accumulate(bool): add instead of overwrite.scale_by_dt(bool): scale writes by substep dt when accumulating.
Modes:
linear:out = lhs * lhs_gain + rhs * rhs_gain + bias.multiply: element-wise product of scaled inputs.crossfade: blend between scaled inputs usingmix(0 = lhs, 1 = rhs).sum: simple sum of scaled inputs.power:out = lhs ^ rhs(complex usescpow).am: amplitude modulation(1 + rhs*rhs_gain) * (lhs*lhs_gain) + bias.fm: frequency modulationlhs * exp(i * rhs * rhs_gain).pm: phase modulation preserving magnitude.ring_mod: ring modulation removing DC bias.max/min: element-wise extrema after scaling.average: mean of scaled inputs.difference/abs_diff: signed or absolute difference.feedback: leaky integrator usingfeedback_decay,feedback_strength,feedback_bias.
Example mix patterns:
-- FM synthesissim.sim_add_mixer_operator(ctx, carrier, mod, out, { mode = "fm", lhs_gain = 1.0, rhs_gain = 0.2})
-- Crossfadesim.sim_add_mixer_operator(ctx, a, b, out, { mode = "crossfade", lhs_gain = 1.0, rhs_gain = 1.0, mix = 0.35})
-- Feedback blendsim.sim_add_mixer_operator(ctx, a, b, out, { mode = "feedback", feedback_decay = 0.1, feedback_strength = 0.9, bias = 0.0})Examples:
sim.sim_add_mixer_operator(ctx, a, b, out, { mode = "fm", rhs_gain = 0.2, lhs_gain = 1.0})
sim.sim_add_mixer_operator(ctx, a, b, out, { mode = "feedback", feedback_decay = 0.1, feedback_strength = 0.9, bias = 0.0})