Objects and generators that are added to the Pymax system in your Python code can be called by pyobj, pygen, and pynote Max objects in your Max patch.
The following Python code…
from pymaxmusic import pymax
def single_event_generator():
yield [1000, "hello world"]
pymax.open_pymax()
pymax.add_generator("say_hello", single_event_generator)
pymax.run_pymax()
…will produce, after one second (1000 ms), the following Max output:
Basic usage is this:
Note that any messages you send from Max will only be received by the Python side if run_pymax() has been called. So if you trigger messages in a max patch using loadbang or loadmess, these will not be received by Python unless run_pymax() has been called (that is, your module has started running) before these messages have been triggered (that is, before the Max patch has been opened).