maxref¶
Dynamic Max object information parsed from .maxref.xml files (or the bundled
fallback). Provides object help, inlet/outlet counts and types, connection
validation, and the MaxRefCache / MaxRefDB access layers.
from py2max.maxref import get_object_help, get_available_objects
objects = get_available_objects() # 1175+ objects
print(get_object_help('umenu'))
Max object reference system for py2max.
This subpackage provides access to Max object documentation and metadata:
- MaxRefCache: Cache for parsed .maxref.xml files
- MaxRefDB: SQLite database for Max object reference data
- MAXCLASS_DEFAULTS: Dictionary of default object properties
- Various helper functions for object introspection
Example
from py2max.maxref import get_object_info, MAXCLASS_DEFAULTS info = get_object_info('cycle~') defaults = MAXCLASS_DEFAULTS.get('cycle~')
MaxClassDefaults ¶
Object-defaults lookup with two layers.
- Curated overrides (
legacy.MAXCLASS_DEFAULTS) -- authoritative, hand-tuned defaults for common/UI objects, including the correctpatching_rectgeometry the XML cannot provide. - Dynamic maxref discovery (
get_legacy_defaultsover.maxref.xml) -- the fallback for the long tail of objects not in layer 1.
Curated overrides win on purpose: maxref-derived defaults use a generic 60x22 box and cannot infer UI sizes, so an object present in both layers must use its curated entry.
MaxRefCache ¶
get_all_jit_objects ¶
Get list of all Jitter objects (jit-ref category)
get_all_m4l_objects ¶
Get list of all Max for Live objects (m4l-ref category)
get_all_max_objects ¶
Get list of all Max objects (max-ref category)
get_all_msp_objects ¶
Get list of all MSP objects (msp-ref category)
get_available_objects ¶
Get list of all available Max objects with .maxref.xml files
get_inlet_count ¶
Get the number of inlets for a Max object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
maxclass
|
str
|
The Max object class name |
required |
Returns:
| Type | Description |
|---|---|
Optional[int]
|
Number of inlets or None if unknown |
get_inlet_types ¶
Get the inlet types for a Max object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
maxclass
|
str
|
The Max object class name |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
List of inlet type strings |
get_legacy_defaults ¶
Get legacy-compatible defaults for a Max object
This function extracts basic information needed for backwards compatibility with the old MAXCLASS_DEFAULTS structure.
get_object_help ¶
Get formatted help text for a Max object
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Max object name |
required |
Returns:
| Type | Description |
|---|---|
str
|
Formatted help text string |
get_object_info ¶
Get information about a Max object from its .maxref.xml file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Max object name (e.g., 'umenu', 'cycle~', 'gain~') |
required |
Returns:
| Type | Description |
|---|---|
Optional[Dict[str, Any]]
|
Dictionary with complete object information or None if not found |
get_objects_by_category ¶
Get list of objects in a specific category (jit, max, msp, m4l)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
category
|
str
|
Category name ('jit', 'max', 'msp', or 'm4l') |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
Sorted list of object names in that category |
get_outlet_count ¶
Get the number of outlets for a Max object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
maxclass
|
str
|
The Max object class name |
required |
Returns:
| Type | Description |
|---|---|
Optional[int]
|
Number of outlets or None if unknown |
get_outlet_types ¶
Get the outlet types for a Max object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
maxclass
|
str
|
The Max object class name |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
List of outlet type strings |
replace_tags ¶
Replace XML tags with substitution string
validate_connection ¶
validate_connection(
src_maxclass: str,
src_outlet: int,
dst_maxclass: str,
dst_inlet: int,
src_text: Optional[str] = None,
dst_text: Optional[str] = None,
) -> tuple[bool, str]
Validate a connection between two Max objects using the port-type model.
Checks (a) that the outlet/inlet indices are in range (arg-aware, so
limi~ 2 is understood to have two ports) and (b) that the outlet's
message kind is compatible with the inlet -- catching a control outlet wired
into a signal-only inlet (e.g. metro -> cycle~), which Max rejects.
The message-type check is deliberately conservative: only clearly-wrong connections fail; anything ambiguous (or involving a maxref-unknown object) is allowed, so validation never rejects a valid patch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src_maxclass
|
str
|
Source object's maxclass. |
required |
src_outlet
|
int
|
Source outlet index (0-based). |
required |
dst_maxclass
|
str
|
Destination object's maxclass. |
required |
dst_inlet
|
int
|
Destination inlet index (0-based). |
required |
src_text
|
Optional[str]
|
Source box text (enables arg-aware outlet counts). |
None
|
dst_text
|
Optional[str]
|
Destination box text (enables arg-aware inlet counts). |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
Tuple of (is_valid: bool, error_message: str). |
str
|
only for a definite error. |