This directory contains working examples used throughout the py2max documentation. All examples are tested to ensure they work correctly.
- quickstart/: Examples from the quickstart guide
basic_patch.py- Simple oscillator patchlayout_examples.py- Grid and flow layout demonstrations
- tutorial/: Complete tutorial examples
simple_synthesis.py- Basic synthesizer with C major chordsignal_processing_chain.py- Complex audio processing chaininteractive_controller.py- MIDI controller interfacegenerative_music.py- Generative music system with patterns
- layout/: Layout manager examples
grid_layout_examples.py- Grid layout with clusteringflow_layout_examples.py- Flow layout with signal analysis
- advanced/: Advanced usage patterns
subpatchers.py- Subpatcher creation and nestingdata_containers.py- Tables, collections, and dictionariesconnection_patterns.py- Fan-out, feedback, and matrix routingerror_handling.py- Robust patch creation and validationperformance_optimization.py- Large patch optimizationcustom_extensions.py- Custom patcher classes and methods
- api/: API reference examples
patcher_api_examples.py- Patcher class methods and featuresbox_api_examples.py- Box class introspection and help system
All examples can be run independently:
# Run a specific example
python tests/examples/quickstart/basic_patch.py
python tests/examples/tutorial/simple_synthesis.py
python tests/examples/advanced/subpatchers.py
# Run all examples (via test suite)
uv run pytest tests/test_examples.pyBasic examples for getting started with py2max, including simple patches and layout demonstrations.
Four comprehensive tutorials building from simple synthesis to complex generative music systems:
- Simple Synthesis - Multi-oscillator chord synthesizer
- Signal Processing Chain - Complete audio effects chain
- Interactive Controller - MIDI controller with preset management
- Generative Music - Multi-pattern algorithmic composition
Demonstrations of py2max's powerful layout managers:
- Grid Layout - Automatic grid positioning with clustering
- Flow Layout - Signal flow-based hierarchical arrangement
Complex usage patterns including:
- Subpatchers - Hierarchical patch organization
- Data Containers - Tables, collections, and state management
- Connection Patterns - Advanced routing and feedback systems
- Error Handling - Robust patch creation with validation
- Performance - Optimization techniques for large patches
- Extensions - Custom patcher classes and methods
Complete demonstrations of the py2max API:
- Patcher API - All patcher creation and management methods
- Box API - Object introspection, help system, and validation
Examples are automatically tested as part of the test suite to ensure they remain functional as the library evolves.
# Test all examples
uv run pytest tests/test_examples.py -v
# Test specific example category
uv run pytest tests/test_examples.py::test_quickstart_examples -v
uv run pytest tests/test_examples.py::test_tutorial_examples -v
uv run pytest tests/test_examples.py::test_layout_examples -v
uv run pytest tests/test_examples.py::test_advanced_examples -v
uv run pytest tests/test_examples.py::test_api_examples -vThese examples are designed to be included in the Sphinx documentation to ensure that all code examples in the docs are tested and functional. The documentation references these files directly instead of containing hardcoded examples.