pd.add_object
You can create your objects with Python. For the simplest, you define the Python Function and add it as an object using pd.add_object().
It is crucial to emphasize that when an object uses pd.add_object() it is added as an anything object. It implies that if your object functions with individual floats rather than lists, py4pd does not provide additional 'protection' for types. In such cases, you are responsible for managing these different types on your own. For more complex objects it is recommended to utilize pd.new_object().
-
Example
It just returns a unique string with the pathname.
import pd from src.thing import myFunction def Py4pdLoadObjects(): pd.add_object(myFunction, "mypyobj", obj_type=pd.VIS, fig_size=(400, 200), py_out=True, no_outlet=False)
-
Arguments
Parameters Type Description arg1Python FunctionFunction that will be executed by the object. arg2StringString to create the object. Kwargs Type Description objtypepdThe type of the object: pd.VIS,pd.AUDIO,pd.AUDIOIN, orpd.AUDIOOUT. Hiding this option will create a normal object.fig_sizeTupleSets the pixel size of the object. Example: figsize=(400, 200)creates an object with a width of 400 and height of 200.py_outBooleanDetermines whether the output will be in PureData data types or Python data types. If set to Python, you can not use the data before the convertion to PureData with py2pdobject.no_outletBooleanCreates an object with no outlets if set to True.num_aux_outletsintSet the number of auxiliar outlets. If you use 4, it means that the object will have 5 inlets, 4 auxiliar and the main outlet (0). added2pd_infoBooleanPrints the message "[py4pd]: Object {objectName} added."when set toTrue.help_patchStringPersonalized help patch, it always must be inside the helpfolder.ignore_none_returnBooleanWhen Trueit ignores all things that return None.obj_imageStringSet the standard image for pd.VISobjects. When you create the object it will load this image.