m4l-builder
Build Max for Live devices in Python. Write scripts, emit .amxd files straight to your Ableton User Library. No Max GUI required. Everything is version-controllable, scriptable, and reproducible. Zero runtime dependencies -- pure stdlib.
Workspace boundaries
m4l-builder is a standalone library with zero runtime dependencies -- it
builds .amxd files on its own and has no requirement on any other repo.
This repo intentionally does not ship in-repo plugin/device scripts; it's a
framework, not a product collection.
The maintainer's own plugin products live in a private repo not published
here. If you're building your own devices with this library, there's no
required layout -- write your build.py scripts wherever you like and
import m4l_builder.
Install
pip install m4l-builder
Quick start
from m4l_builder import AudioEffect, WARM, device_output_path
device = AudioEffect("My Gain", width=150, height=110, theme=WARM)
device.add_panel("bg", [0, 0, 150, 110])
device.add_dial("gain", "Gain", [10, 6, 50, 90],
min_val=-70.0, max_val=6.0, initial=0.0,
unitstyle=4, annotation_name="Gain")
# Inlet/outlet counts and outlet types are inferred from the object text.
# Objects whose shape can't be known from text (gen~, poly~, p, js, ...) raise
# and need numinlets=/numoutlets= passed explicitly; explicit values always win.
device.add_newobj("mul_l", "*~ 1.")
device.add_newobj("mul_r", "*~ 1.")
device.add_newobj("db2a", "dbtoa")
device.add_newobj("pk", "pack f 20")
device.add_newobj("ln", "line~")
device.add_line("obj-plugin", 0, "mul_l", 0) # stereo in
device.add_line("obj-plugin", 1, "mul_r", 0)
device.add_line("mul_l", 0, "obj-plugout", 0) # stereo out
device.add_line("mul_r", 0, "obj-plugout", 1)
device.add_line("gain", 0, "db2a", 0) # dial -> dbtoa -> smooth -> gain
device.add_line("db2a", 0, "pk", 0)
device.add_line("pk", 0, "ln", 0)
device.add_line("ln", 0, "mul_l", 1)
device.add_line("ln", 0, "mul_r", 1)
device.build(device_output_path("My Gain"))
Restart Ableton (or refresh the browser) and your device shows up in the User Library.
Examples
Runnable scripts that build real devices live in examples/; new
users should start with the step-by-step getting started
guide.
uv run python examples/02_generative_midi.py # builds a generative MIDI device
01_gain_audio_effect.py— audio effect, low-level API02_generative_midi.py— MIDI effect using the generative recipe03_stereo_width.py— audio effect using the mid/side width recipe04_midi_transformation.py— Live 12 MIDI Tool (MidiTransformation) built on thelive.miditool.in/outchain05_euclidean_midi.py— MIDI effect using the Euclidean rhythm generator06_simple_synth.py—Instrumentdevice: oscillator through an ADSR amplitude envelope
Key concepts
Device types
The three classic types plus Live 12 MIDI Tools:
from m4l_builder import AudioEffect, Instrument, MidiEffect
from m4l_builder import MidiTransformation, MidiGenerator # Live 12 MIDI Tools
fx = AudioEffect("FX", 300, 170) # auto-adds plugin~/plugout~
synth = Instrument("Synth", 400, 200) # no auto I/O
midi = MidiEffect("MIDI FX", 200, 100) # MIDI only
transform = MidiTransformation("Swing", 200, 120) # rewrites clip notes
generator = MidiGenerator("Euclid", 200, 120) # adds notes to a clip
AudioEffect auto-wires stereo plugin~ / plugout~ objects (IDs obj-plugin, obj-plugout). Instruments and MIDI effects leave I/O to you.
MIDI Tools (Live 12) are built around a live.miditool.in → processing →
live.miditool.out chain; use the midi_tool_io helper for the scaffolding.
A MidiTransformation rewrites the selected notes of a clip; a MidiGenerator
adds new notes. See the MIDI Tools guide and
examples/04_midi_transformation.py.
DSP blocks
All DSP functions return (boxes, lines) tuples. Compose them with add_dsp:
from m4l_builder import gain_stage, highpass_filter
boxes, lines = gain_stage("gain")
device.add_dsp(boxes, lines)
Filters: highpass, lowpass, bandpass, notch, onepole, shelves, tilt EQ, 3-band crossover, peaking EQ, allpass
Dynamics: compressor, limiter, envelope follower, gate/expander, sidechain detect, multiband compressor
Delay/Reverb: delay line, feedback delay, reverb network, FDN reverb, convolver
Modulation: LFO (4 waveforms), tremolo, transport LFO, morphing LFO
MIDI: notein/out, ctlin/out, velocity curve, transpose, arpeggiator, chord, pitch quantize, midi learn
Generative: probability gate, random note, Euclidean rhythm
MIDI Tools: midi_tool_io (the live.miditool.in/out scaffold for Live 12 Generators/Transformations)
Synthesis: wavetable osc, noise, oscillator bank, ADSR, poly voices, grain cloud
Spectral: spectral gate, crossover, vocoder, phase vocoder
Routing: selector, send/receive (signal + message), matrix mixer, sidechain routing
Utility: param smooth, tempo sync, sample and hold, bitcrusher, coll/dict/pattr storage
100+ blocks total. Browse the catalog or docs/api.md for the full list with signatures.
gen~ DSP primitives & verification
The DSP blocks above emit Max object graphs. For sample-accurate DSP that needs a
gen~ codebox, m4l-builder provides a registry of composable GenExpr
fragments plus a codegen and a two-layer test harness — so the flagship plugins
compose audited primitives instead of hand-copying the same math.
gen_snippets — parameterized GenExpr fragments (each takes caller-chosen
variable names and returns a gen code string):
from m4l_builder import peak_follower, soft_knee_gain_computer, dynamics_band
# detector -> soft-knee gain computer -> makeup, one reusable compressor band
GEN_CODE += dynamics_band("peak", "env", "atk", "rel",
"threshold", "ratio", "knee", "makeup", "gain")
Registry (17): ms_encode / ms_decode / ms_width (Mid/Side matrix),
drive_blend (level-matched tanh soft-clip), peak_follower (attack/release
detector), isp_catmull_4x (4× inter-sample-peak / true-peak), kweight_coeffs_bs1770
(ITU-R BS.1770-4 K-weight), exp_pole (one-pole ballistics coefficient),
soft_knee_gain_computer + dynamics_band (compressor gain path), biquad_df1
(Direct-Form-I biquad apply), rbj_peaking / rbj_shelf (runtime peaking-EQ /
low-high-shelf coefficients), one_pole_coeff / one_pole_lp / one_pole_hp
(cutoff-frequency 1st-order filter split), exciter_harmonics (harmonic-exciter
generator: odd tanh + even squarer, the added content).
build_gendsp(code, numins, numouts) — wraps GenExpr into a .gendsp
support file, and lints at build time (gen_lint): a dead/unassigned signal
out, an out-of-range in N/out N index, or the multi-line-ternary trap raise a
ValueError instead of silently shipping a broken device.
gen_sim — an offline simulator that runs a gen~ kernel sample-by-sample in
pure Python, so tests assert the audio behaviour, not just the structure:
from m4l_builder import simulate
out = simulate("History env(0.);\n" + peak_follower("in1", "env", "0.1", "0.9", "c")
+ "\nout1 = env;", {"in1": [1.0] * 5 + [0.0] * 5})
# assert attack is faster than release, no NaN, ratio=1 is transparent, ...
It supports History/Param/arithmetic/ternary/if-else and a pure-function table, and refuses (rather than mis-evaluates) Delay/buffer/FFT kernels that need a live render. This is how the suite proves a compressor is transparent at ratio 1 or a limiter never boosts — the "advertised-but-unwired" bug class — fully offline.
Validating against Ableton's standards
Device.check_guidelines() checks a built device against the statically
decidable subset of Ableton's published Max for Live device conventions
(parameter naming, presentation geometry, forbidden objects, JavaScript style)
— before it is ever loaded in Live:
for issue in device.check_guidelines():
print(issue.severity, issue.code, issue.message)
…or over a folder of build scripts from the shell:
python -m m4l_builder.guidelines path/to/*/build.py
It flags unknown / misspelled object names — a typo like cycl~ that would
otherwise ship as a Max newobj: no such object load error, reported with a
"did you mean cycle~?" suggestion — plus duplicate parameter Long / Scripting
Names, auto-indexed default names (Gain[1]), fractional pixel rects, and
forbidden print/dac~/adc~. It's advisory (reports, doesn't gate the
build) and it's the pre-Live static complement to a live console audit.
Engines (jsui visualizations)
JavaScript generators for Max's jsui object. Each returns an ES5 string for mgraphics/Cairo rendering:
from m4l_builder.engines import filter_curve_js
device.add_jsui("display", [10, 30, 200, 80],
js_code=filter_curve_js(), numinlets=3)
Dozens of generators are available: filter curves, EQ, envelopes, spectrum, waveforms, XY pad, piano roll, step grids, grain clouds, vocoder bands, and more. See the auto-generated catalog for the complete, current list of engines.
Themes
16 built-in color themes — AMBER, COBALT, COOL, FOREST, GRAPHITE, INDUSTRIAL, LIGHT, LOFI, MAGMA, MIDNIGHT, NEBULA, NEON, SOLAR, SYNTHWAVE, VIOLET, WARM (see the catalog for the current list). Pass to the device constructor and all UI elements inherit colors automatically:
from m4l_builder import AudioEffect, MIDNIGHT, WARM, COOL, LIGHT, FOREST, VIOLET, SOLAR
device = AudioEffect("FX", 300, 170, theme=MIDNIGHT)
Build a theme from just an accent color:
from m4l_builder import Theme
my_theme = Theme.from_accent([0.8, 0.3, 0.1, 1.0])
Recipes
Pre-wired DSP combos for common patterns. They add objects to a device and return IDs for further wiring:
from m4l_builder import gain_controlled_stage, dry_wet_stage
ids = gain_controlled_stage(device, "out", [10, 10, 50, 70])
# ids["gain"] is the *~ you wire into your signal chain
Available recipes include gain_controlled_stage, dry_wet_stage,
stereo_width_stage, generative_midi_stage, euclidean_sequencer_stage,
tempo_synced_delay, and midi_note_gate — see the full list in the
catalog.
Layout helpers
Automatic positioning with Row, Column, and Grid context managers:
with device.row(10, 10, spacing=8, height=70) as r:
r.add_dial("d1", "Param1", width=50)
r.add_dial("d2", "Param2", width=50)
r.add_dial("d3", "Param3", width=50)
UI guidance
Beyond the widget API above, deeper UI/visual-design guidance lives in docs/m4l_advanced_ui_techniques.md, docs/ui_goodies_and_graphics_pipeline.md, and docs/ui_premium_playbook.md.
Subpatchers
Nested patchers for organizing signal chains:
from m4l_builder import Subpatcher
sub = Subpatcher("processor")
sub.add_newobj("in", "inlet~", numinlets=1, numoutlets=1)
sub.add_newobj("out", "outlet~", numinlets=1, numoutlets=1)
sub.add_line("in", 0, "out", 0)
device.add_subpatcher(sub, "proc_box", [30, 100, 80, 20])
Round-trip editing with from_amxd
Read an existing .amxd back into a Device, modify it, write it out:
device = AudioEffect.from_amxd("path/to/effect.amxd")
device.add_dial("new_knob", "NewParam", [10, 10, 50, 70])
device.build("path/to/modified.amxd")
LiveMCP bridge (optional)
Entirely optional: enable_livemcp_bridge embeds a self-contained JSON-lines
TCP bridge (pure stdlib -- no LiveMCP install required by the library itself)
inside a device's own .amxd, so a compatible external tool -- LiveMCP is
one -- can inspect and edit that device's patcher live in Ableton.
from m4l_builder import AudioEffect, enable_livemcp_bridge, device_output_path
device = AudioEffect("Bridge Ready", width=420, height=180)
enable_livemcp_bridge(device, include_ui=True)
device.build(device_output_path("Bridge Ready"))
That device will write the .amxd plus the bridge sidecars next to it during
build(). The bridge is local-only and device-local: it gives LiveMCP access to
that device's patcher, not to arbitrary third-party Max devices in the set. See
docs/livemcp_max_bridge.md for the full contract.
Plugin workspaces
This framework repo does not keep buildable plugin scripts in-tree -- the
maintainer's own concrete devices live in a private repo, not published.
There's no dependency on that repo (or any other) to use m4l-builder:
write your own build.py anywhere and import m4l_builder.
Architecture / internals
Notes on how the library itself is organized, for anyone extending it rather than just building devices with it.
Engines layer
src/m4l_builder/engines/ (68 modules) holds the jsui/v8ui JS generators
described above, plus two shared-scaffold modules that are not generators
themselves:
engines/design_system.py— shared MGraphics drawing helpers and cursor handling that the hero displays embed, so a visual change lands once instead of being hand-copied. Sidecar.jsfilenames are content-addressed byjs_sidecar_name()(stem + BLAKE2b hash of the JS source): Max caches jsui/v8ui sidecars by filename for the whole Live session, so editing the JS without renaming the file would otherwise keep serving the stale cached version.engines/interaction_core.py— the shared JS interaction scaffold (pointer-coordinate resolvers,clamp,onresize, plot-geometry accessors) that used to be hand-copied verbatim into every interactive display engine.
patcher_walk.py
patcher_walk.py is the one shared
implementation of the box/line traversal dance (iter_boxes, boxes_by_id,
iter_patchlines, unwrap_box) that used to be hand-rolled independently
throughout the library. It accepts a live Device/GraphContainer, a raw
patcher dict, or an already-extracted list of wrapper entries, so the same
functions serve live authoring code and code that reads existing patchers.
idioms.py and bridge_probe.py
Root-level helper modules: idioms.py wraps Max
wiring patterns that are easy to get subtly wrong — expr_cond for branchless
expr conditionals (Max expr has no ternary), plus debounce,
dedupe_value, control_smooth, init_prime, corr_readout, and
assign_parameter_banks — each one encodes a trap that previously shipped as
a real bug. bridge_probe.py is shared
scaffolding for devices that embed a LiveMCP bridge probe
(register_bridge_probe_assets, add_bridge_probe_runtime), factored out
after two EQ devices each hand-copied the same ~76 lines.
Facade + introspection pattern
m4l_builder/__init__.py and m4l_builder/builder/__init__.py don't
hand-maintain their own export lists — both build their public surface from
shared metadata in _exports.py and resolve
names lazily via module-level __getattr__/__dir__, so importing
m4l_builder only loads the modules a caller touches.
recipes.py is a thin facade that re-exports from its split implementation
modules (recipes_stages.py, recipes_layout.py, recipes_widgets.py,
recipes_io.py), so existing from m4l_builder.recipes import Y code keeps
working unchanged.
Development
git clone https://github.com/alaarab/m4l-builder.git
cd m4l-builder
uv pip install -e .
# Tests
uv run pytest tests/ -v
# With coverage
uv run pytest tests/ --cov=m4l_builder --cov-report=term-missing
API reference
Browse the catalog for every DSP block, UI widget, recipe, theme, and engine at a glance, or the full API docs.
License
MIT. Files vendored from Ableton's
maxdevtools (src/m4l_builder/vendor/maxdiff/,
tools/maxdiff/) are MIT, (c) 2024 Ableton AG; their license text sits next to them.
Metadata
Release files for m4l-builder 0.8.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| m4l_builder-0.8.0.tar.gz | 891.1 kB | With provenance | Details for m4l_builder-0.8.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| m4l_builder-0.8.0-py3-none-any.whl | Python 3 | none | any | Details for m4l_builder-0.8.0-py3-none-any.whl |
Total release size: 1.7 MB
Release files / m4l_builder-0.8.0.tar.gz
| Download URL | m4l_builder-0.8.0.tar.gz |
|---|---|
| Size | 891.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
58530d3fbe656bb063db303716433489443d8485c55261b6eda79962c2d38231
|
|
BLAKE2b-256 checksum How to use checksums |
1840243090ac1371d023d83e1c1400226924d63db1c13dc2cfc3525e2c436d26
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logRelease files / m4l_builder-0.8.0-py3-none-any.whl
| Download URL | m4l_builder-0.8.0-py3-none-any.whl |
|---|---|
| Size | 768.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
27cd22a47ac920df11b279354ce1915dc29e7606eed673c084d4ea0542eba291
|
|
BLAKE2b-256 checksum How to use checksums |
1470c370e438638a6b8feb96129cbbe0427ee3d4226078b49867dd3e7aa59214
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logSecurity for m4l-builder 0.8.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for m4l_builder-0.8.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.