Utilities
Messages and Debug
There are three messages used to print info in the PureData console, pd.print, pd.logpost and pd.error.
pd.print
-
Example
The ordinary function
print()will not work inpy4pd(unless you open PureData from the terminal). So if you want to debug or print some info from the PureData console you need to usepd.print.import pd def printInfo(): pd.print("ok") # It prints "[Python] ok" pd.print("ok", show_prefix=False) # It prints "ok". -
Arguments
Parameters Type Description arg1Python ObjectThing to print
Kwargs Type Description show_prefixPython ObjectWhen Falsedon't print prefixInfo
For Object written in Python, the prefix will be the Object Name.
pd.logpost
-
Example
This function uses
logpostin C PureData API to log messages using levels. For example, if you uselogpost(4, "PureData message in level 4"), the message will appear in the console just if the user had selected to show the messages of level 4 in PureData Console.import pd def printInfoLevel(): pd.logpost(1, "Level 1") pd.logpost(2, "Level 2") pd.logpost(3, "Level 3") pd.logpost(4, "Level 4") -
Arguments
Parameters Type Description arg1intLevel to print (1-4) arg2stringMessage to print
pd.error
-
Example
If you want to inform errors in PureData console use
pd.errormethod. The message is printed in red.import pd def main(arg1): try: # some wrong arg here ???? except: pd.error("This is a not " + "valid operation!") -
Arguments
Parameters Type Description arg1stringMessage of the error.
GUI
pd.pd_has_gui
-
Example
When using some functions as
pd.show_imagecan be useful to know if a GUI is running. This function returnsFalsewhen running PureData from the terminal using-nogui.import pd def thereisGUI(): return pd.pd_has_gui() -
Arguments
There are no Arguments.
pd.get_patch_zoom
-
Example
To set different default images for
pd.VISobjects, you can use this function. It returns 1 when the patch is used without zoom and 2 when is used with zoom.import pd def getZoom(): return pd.get_patch_zoom() -
Arguments
There are no Arguments.
Objects
These functions are used to retrieve information about the current object where the function is being executed.
get_outlet_count
-
Example
Get the number of outlets of the object.
import pd def get_out_count(): pd.get_outlet_count() -
Arguments
There is no args for this function.
get_obj_args
-
Example
Returns a list of all arguments used to create the object.
import pd def get_out_count(): pd.get_obj_args() -
Arguments
There is no args for this function.