Add native Max for Live (.amxd) device support#9
Merged
Conversation
Integrate .amxd binary save/load directly into the maxpylang package so
users can create M4L devices with a single explicit flag:
patch.save("synth.amxd", device_type="instrument")
- Add maxpylang/amxd.py with save_amxd/load_amxd functions
- Extend patch.save() with device_type parameter (instrument/audio_effect/midi_effect)
- Auto-detect .amxd from extension, require device_type, force extension when set
- Support loading .amxd files via MaxPatch(load_file="device.amxd")
- Export save_amxd, load_amxd, DEVICE_TYPES from package
- Add M4L instrument and audio effect examples
- Add class_transition.md and edge_cases.md planning docs
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
notein works without arguments in Max (listens on all ports/channels). The reference file incorrectly marked these as required, causing UnknownObjectWarning when placing notein without args. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add bounds check in load_amxd to catch truncated/corrupt .amxd files - Use removesuffix(b"\x00") instead of rstrip for precise null handling - Add TypeError guard in save_amxd for non-dict input - Fix truthiness check to explicit `is not None` in save() verbose path - Update load_file docstring to mention .amxd support - Fix misleading comment in extension handling Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Use rstrip(b"\x00") instead of removesuffix to handle multiple trailing nulls - Compare chunk tags as raw bytes instead of decoding to ASCII - Wrap JSONDecodeError with filename context for easier debugging - Include filename in "no ptch chunk" error message Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Member
|
Can we add something in CI that tests this? |
Member
|
like maybe we shoudl at least just run maxpy on the example folder in ci to make sure we dont break these at least from a maxpy pass. i dont know that there is any good way to have full integration tests |
Expand CI to run M4L examples (m4l_instrument, m4l_audio_effect), attributes, and random_pitch_generator alongside hello_world. Add pytest step with 81 tests covering amxd support and backward compat. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
@santolucito
|
santolucito
reviewed
Mar 30, 2026
- load_file: change else to elif .maxpat with ValueError on unknown extensions - Remove test_backward_compat.py per reviewer request (one-time verification) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This was referenced Apr 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds native Max for Live (
.amxd) device support to MaxPyLang — save and load patches as Ableton Live devices directly from Python.Supported device types
device_type"instrument"noteinplugout~"audio_effect"plugin~plugout~"midi_effect"midiin→midiparsemidiformat→midioutUsage
Instrument (MIDI → audio):
Audio effect (audio → audio):
Standalone functions for advanced use:
Other fixes
noteinargs: markport-channelandchannelas optional sonoteincan be placed without argumentsload_amxd: userstripfor multiple trailing nulls, compare chunk tags as raw bytes, include filename in error messagesCI
hello_world,m4l_instrument,m4l_audio_effect,attributes,random_pitch_generatorTest plan
patch.save("test.amxd", device_type="instrument")produces a valid.amxdfile openable in Abletonload_amxd("test.amxd")round-trips correctlypatch.place("notein")[0]works without errors.amxdwithoutdevice_typeraisesValueError.maxpatsave behavior is unchanged