com.cycling74.max
Class MaxObject

java.lang.Object
  extended by com.cycling74.max.MaxObject
Direct Known Subclasses:
MSPObject

public abstract class MaxObject
extends java.lang.Object

Base class for a Java Max object. Subclass this directly or indirectly to create your own Java objects for use in Max.


Field Summary
static java.lang.String[] EMPTY_STRING_ARRAY
          A convenience constant; use this empty String array instead of creating a new one.
static int[] NO_INLETS
          A convenience constant; use it in a call to declareInlets to declare that an object has no inlets.
static int[] NO_OUTLETS
          A convenience constant; use it in a call to declareOutlets to declare that an object has no outlets.
 
Constructor Summary
protected MaxObject()
          This allows subclasses to avoid calling super(args) in their constructors.
 
Method Summary
protected  void anything(java.lang.String message, Atom[] args)
          Called by Max: inlet has received a message.
protected static void bail(java.lang.String errormsg)
          If called during your constructor bail will cause no instance of the class to be instantiated within max and the mxj box will show up in the patcher as invalid.
protected  void bang()
          Called by Max: inlet has received a bang value.
protected  void createInfoOutlet(boolean b)
          Determine whether or not an info outlet is created.
protected  void dblclick()
          Called by Max when the user double-clicks on the object box.
protected  void declareAttribute(java.lang.String name)
          Declare an attribute with default getter and setter methods.
protected  void declareAttribute(java.lang.String name, java.lang.String getter, java.lang.String setter)
          Declare an attribute with specific getter and setter methods.
protected  void declareInlets(int[] types)
          Declare typed inlets.
protected  void declareIO(int ins, int outs)
          Declare untyped inlets and outlets.
protected  void declareOutlets(int[] types)
          Declare typed outlets.
protected  void declareReadOnlyAttribute(java.lang.String name)
          Declare an attribute with default getter method.
protected  void declareReadOnlyAttribute(java.lang.String name, java.lang.String getter)
          Declare a readonly attribute with a specific getter method.
protected  void declareTypedIO(java.lang.String ins, java.lang.String outs)
          Declare typed inlets and outlets.
protected  void embedMessage(java.lang.String msg, Atom[] args)
          Embed messages in a patcher file for initialization purposes.
static void error(java.lang.String message)
          Post an error message to the Max console.
 void gc()
          Invoke garbage collection via System.gc().
 java.lang.Object getAttr(java.lang.String name)
          Get the current value of a declared attribute as a java.lang.Object.
 Atom[] getAttrAtomArray(java.lang.String name)
          Get the current value of a declared Atom array attribute.
 boolean getAttrBool(java.lang.String name)
          Get the current value of a declared boolean attribute.
 boolean[] getAttrBoolArray(java.lang.String name)
          Get the current value of a declared boolean array attribute.
 float getAttrByte(java.lang.String name)
          Get the current value of a declared byte attribute.
 byte[] getAttrByteArray(java.lang.String name)
          Get the current value of a declared byte array attribute.
 char getAttrChar(java.lang.String name)
          Get the current value of a declared char attribute.
 char[] getAttrCharArray(java.lang.String name)
          Get the current value of a declared char array attribute.
 double getAttrDouble(java.lang.String name)
          Get the current value of a declared double attribute.
 double[] getAttrDoubleArray(java.lang.String name)
          Get the current value of a declared double array attribute.
 float getAttrFloat(java.lang.String name)
          Get the current value of a declared float attribute.
 float[] getAttrFloatArray(java.lang.String name)
          Get the current value of a declared float array attribute.
 AttributeInfo[] getAttributeInfo()
          Get the array of AttributeInfo objects.
 int getAttrInt(java.lang.String name)
          Get the current value of a declared int attribute.
 int[] getAttrIntArray(java.lang.String name)
          Get the current value of a declared int array attribute.
 long[] getAttrLongArray(java.lang.String name)
          Get the current value of a declared long array attribute.
 short getAttrShort(java.lang.String name)
          Get the current value of a declared short attribute.
 short[] getAttrShortArray(java.lang.String name)
          Get the current value of a declared short array attribute.
 java.lang.String getAttrString(java.lang.String name)
          Get the current value of a declared String attribute.
 java.lang.String[] getAttrStringArray(java.lang.String name)
          Get the current value of a declared String array attribute.
 java.lang.String getCodeSourcePath()
          This method returns the native filesystem path of the class file or jar archive from which this class was loaded.
static MaxContext getContext()
          Get the context in which we are running.
static com.cycling74.io.ErrorStream getErrorStream()
          Get the global ErrorStream.
 int getInfoIdx()
          Returns the index of the info outlet.
protected  int getInlet()
          Returns the inlet of the last received message.
 java.lang.String getInletAssist(int inletIdx)
          Describes what inlet inletIdx does.
 int getInletType(int idx)
          Returns an inlet type.
 long getLongAttr(java.lang.String name)
          Get the current value of a declared long attribute.
 MaxBox getMaxBox()
          Gets the MaxBox peer of this mxj instance.
 java.lang.String getName()
          Get the MaxContext name of this instance.
 int getNumInlets()
          Return the number of inlets.
 int getNumOutlets()
          Returns the number of outlets.
 java.lang.String getOutletAssist(int outletIdx)
          Describes what outlet outletIdx does.
 int getOutletType(int idx)
          Returns an outlet type.
 MaxPatcher getParentPatcher()
          Gets the parent MaxPatcher.
static com.cycling74.io.PostStream getPostStream()
          Get the global PostStream.
protected  void inlet(float value)
          Called by Max: inlet has received a float value.
protected  void inlet(int value)
          Called by Max: inlet has received an int value.
protected  void list(Atom[] atomArray)
          Called by Max: inlet has received a list.
protected  void list(float[] f)
          Called by Max: inlet has received a list of floats.
protected  void list(int[] i)
          Called by Max: inlet has received a list of ints.
protected  void loadbang()
          Called by Max at loadbang time (ie, when the enclosing patch has finished loading).
protected  void notifyDeleted()
          Notification that the corresponding mxj object peer was deleted.
static void ouch(java.lang.String message)
          Put up an error window.
 boolean outlet(int outletIdx, Atom value)
          Sends the contents of the Atom out.
 boolean outlet(int outletIdx, Atom[] array)
          Sends an array of Atoms.
 boolean outlet(int outletIdx, boolean value)
          Sends a 0 or a 1.
 boolean outlet(int outletIdx, boolean[] array)
          Sends an array of booleans.
 boolean outlet(int outletIdx, byte value)
          Sends a byte.
 boolean outlet(int outletIdx, byte[] value)
          Sends a list of bytes.
 boolean outlet(int outletIdx, char c)
          Sends a char as a message with no arguments.
 boolean outlet(int outletIdx, char[] value)
          Sends an array of chars.
 boolean outlet(int outletIdx, double value)
          Sends a double.
 boolean outlet(int outletIdx, double[] value)
          Sends a list of doubles.
 boolean outlet(int outletIdx, float value)
          Sends a float.
 boolean outlet(int outletIdx, float[] value)
          Sends a list of floats.
 boolean outlet(int outletIdx, int value)
          Sends an int.
 boolean outlet(int outletIdx, int[] value)
          Sends a list of ints.
 boolean outlet(int outletIdx, long value)
          Sends a long.
 boolean outlet(int outletIdx, long[] value)
          Sends a list of longs.
 boolean outlet(int outletIdx, short value)
          Sends a short.
 boolean outlet(int outletIdx, short[] value)
          Sends a list of shorts.
 boolean outlet(int outletIdx, java.lang.String message)
          Sends a message with no arguments.
 boolean outlet(int outletIdx, java.lang.String[] value)
          Sends an array of Strings.
 boolean outlet(int outletIdx, java.lang.String msg, Atom value)
          Sends a message with an Atom arg.
 boolean outlet(int outletIdx, java.lang.String message, Atom[] args)
          Sends a message.
 boolean outlet(int outletIdx, java.lang.String msg, boolean value)
          Sends a message with a boolean arg.
 boolean outlet(int outletIdx, java.lang.String msg, boolean[] array)
          Sends a message followed by an array of booleans.
 boolean outlet(int outletIdx, java.lang.String msg, byte value)
          Sends a message with a byte arg.
 boolean outlet(int outletIdx, java.lang.String msg, byte[] value)
          Sends a message followed by an array of bytes.
 boolean outlet(int outletIdx, java.lang.String msg, char c)
          Sends a message with a char arg.
 boolean outlet(int outletIdx, java.lang.String msg, char[] value)
          Sends a message followed by an array of chars.
 boolean outlet(int outletIdx, java.lang.String msg, double value)
          Sends a message with a double arg.
 boolean outlet(int outletIdx, java.lang.String msg, double[] value)
          Sends a message followed by an array of doubles.
 boolean outlet(int outletIdx, java.lang.String msg, float value)
          Sends a message with a float arg.
 boolean outlet(int outletIdx, java.lang.String msg, float[] value)
          Sends a message followed by an array of floats.
 boolean outlet(int outletIdx, java.lang.String msg, int value)
          Sends a message with an int arg.
 boolean outlet(int outletIdx, java.lang.String msg, int[] value)
          Sends a message followed by an array of ints.
 boolean outlet(int outletIdx, java.lang.String msg, long value)
          Sends a message with an long arg.
 boolean outlet(int outletIdx, java.lang.String msg, long[] value)
          Sends a message followed by an array of longs.
 boolean outlet(int outletIdx, java.lang.String msg, short value)
          Sends a message with an short arg.
 boolean outlet(int outletIdx, java.lang.String msg, short[] value)
          Sends a message followed by an array of shorts.
 boolean outlet(int outletIdx, java.lang.String msg, java.lang.String value)
          Sends a message with a String arg.
 boolean outlet(int outletIdx, java.lang.String msg, java.lang.String[] value)
          Sends a message followed by an array of Strings.
 boolean outletBang(int outletIdx)
          Sends a bang.
 boolean outletBangHigh(int outletIdx)
          Sends a bang out an outlet in the timer thread if overdrive is on.
 boolean outletHigh(int outletIdx, Atom[] value)
          Sends a list out an outlet in the timer thread.
 boolean outletHigh(int outletIdx, double value)
          Sends a double out an outlet in the timer thread.
 boolean outletHigh(int outletIdx, float value)
          Sends a float out an outlet in the timer thread.
 boolean outletHigh(int outletIdx, float[] values)
          Sends a list out an outlet in the timer thread.
 boolean outletHigh(int outletIdx, int value)
          Sends an int out an outlet in the timer thread if overdrive is on.
 boolean outletHigh(int outletIdx, int[] values)
          Sends a list out an outlet in the timer thread.
 boolean outletHigh(int outletIdx, java.lang.String message)
          Sends a message with no arguments out an outlet in the timer thread.
 boolean outletHigh(int outletIdx, java.lang.String message, Atom[] args)
          Sends a message and arguments out an outlet in the timer thread.
 boolean outletHigh(int outletIdx, java.lang.String message, float[] values)
          Sends a message and arguments out an outlet in the timer thread.
 boolean outletHigh(int outletIdx, java.lang.String message, int[] values)
          Sends a message and arguments out an outlet in the timer thread.
static void post(java.lang.String message)
          Post a message to the Max console.
 void postCodePath()
           
protected  void save()
          Called by Max when the user saves the patch.
 void setAttr(java.lang.String name, Atom[] val)
          Set the current value of a declared Atom array attribute.
 void setAttr(java.lang.String name, boolean val)
          Set the current value of a declared boolean attribute.
 void setAttr(java.lang.String name, boolean[] val)
          Set the current value of a declared boolean array attribute.
 void setAttr(java.lang.String name, byte val)
          Set the current value of a declared byte attribute.
 void setAttr(java.lang.String name, byte[] val)
          Set the current value of a declared byte array attribute.
 void setAttr(java.lang.String name, char val)
          Set the current value of a declared char attribute.
 void setAttr(java.lang.String name, char[] val)
          Set the current value of a declared char array attribute.
 void setAttr(java.lang.String name, double val)
          Set the current value of a declared double attribute.
 void setAttr(java.lang.String name, double[] val)
          Set the current value of a declared double array attribute.
 void setAttr(java.lang.String name, float val)
          Set the current value of a declared float attribute.
 void setAttr(java.lang.String name, float[] val)
          Set the current value of a declared float array attribute.
 void setAttr(java.lang.String name, int val)
          Set the current value of a declared int attribute.
 void setAttr(java.lang.String name, int[] val)
          Set the current value of a declared int array attribute.
 void setAttr(java.lang.String name, long val)
          Set the current value of a declared long attribute.
 void setAttr(java.lang.String name, long[] val)
          Set the current value of a declared long array attribute.
 void setAttr(java.lang.String name, java.lang.Object val)
          Set the current value of a declared attribute.
 void setAttr(java.lang.String name, java.lang.Object[] args)
           
 void setAttr(java.lang.String name, short val)
          Set the current value of a declared short attribute.
 void setAttr(java.lang.String name, short[] val)
          Set the current value of a declared short array attribute.
 void setAttr(java.lang.String name, java.lang.String val)
          Set the current value of a declared String attribute.
 void setAttr(java.lang.String name, java.lang.String[] val)
          Set the current value of a declared String array attribute.
protected  void setInletAssist(int index, java.lang.String message)
          Set one inlet assistance string.
protected  void setInletAssist(java.lang.String[] messages)
          Set the inlet assistance strings.
 void setName(java.lang.String name)
          Set the name of this instance used by MaxContext.
protected  void setOutletAssist(int index, java.lang.String message)
          Set one outlet assistance string.
protected  void setOutletAssist(java.lang.String[] messages)
          Set the outlet assistance strings.
static void showException(java.lang.String message, java.lang.Throwable t)
          Display an exception or other Throwable in a convenient way with an accompanying message.
static void showException(java.lang.Throwable t)
          Display an exception or other Throwable in a convenient way.
 java.lang.String toString()
          Return a human-readable version of this object.
 void viewsource()
          Brings up the source code for the java class in an editor.
 void zap()
          Force the next class to be loaded by mxj to be loaded with a new MXJClassLoader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_INLETS

public static final int[] NO_INLETS
A convenience constant; use it in a call to declareInlets to declare that an object has no inlets.

See Also:
declareInlets(int[])

NO_OUTLETS

public static final int[] NO_OUTLETS
A convenience constant; use it in a call to declareOutlets to declare that an object has no outlets.

See Also:
declareOutlets(int[])

EMPTY_STRING_ARRAY

public static final java.lang.String[] EMPTY_STRING_ARRAY
A convenience constant; use this empty String array instead of creating a new one.

Constructor Detail

MaxObject

protected MaxObject()
This allows subclasses to avoid calling super(args) in their constructors.

Method Detail

notifyDeleted

protected void notifyDeleted()
Notification that the corresponding mxj object peer was deleted. By default, this method does nothing. Subclasses are free to override this to do anything they like.


setName

public void setName(java.lang.String name)
Set the name of this instance used by MaxContext.

Parameters:
name - the new name.

getName

public java.lang.String getName()
Get the MaxContext name of this instance.

Returns:
a String that contains the instance's name.

getContext

public static MaxContext getContext()
Get the context in which we are running.

Returns:
the current MaxContext.

post

public static void post(java.lang.String message)
Post a message to the Max console.

Parameters:
message - the String to post in the Max console.

error

public static void error(java.lang.String message)
Post an error message to the Max console.

Parameters:
message - the String to post as an error to the Max console.

ouch

public static void ouch(java.lang.String message)
Put up an error window. Extremely annoying. Should probably never be used. I'm not even sure why we support it.

Parameters:
message - the text to display in the error window.

getPostStream

public static com.cycling74.io.PostStream getPostStream()
Get the global PostStream.

Returns:
the global PostStream.

showException

public static void showException(java.lang.Throwable t)
Display an exception or other Throwable in a convenient way. Prints out the exception information in the Max console.

Parameters:
t - the exception to display.

showException

public static void showException(java.lang.String message,
                                 java.lang.Throwable t)
Display an exception or other Throwable in a convenient way with an accompanying message.

Parameters:
message - the accompanying message.
t - the exception to display.

getErrorStream

public static com.cycling74.io.ErrorStream getErrorStream()
Get the global ErrorStream.

Returns:
the global ErrorStream.

getParentPatcher

public MaxPatcher getParentPatcher()
Gets the parent MaxPatcher.

Returns:
the parent MaxPatcher

getMaxBox

public MaxBox getMaxBox()
Gets the MaxBox peer of this mxj instance.

Returns:
the MaxBox for this MaxObject

declareInlets

protected void declareInlets(int[] types)
Declare typed inlets. Typed inlets are more efficient than untyped (ie, DataTypes.ALL). To have any effect, this method must be called in your class's constructor. For example, the following call ensures that an object of this class will have an int inlet and a float inlet.
 declareInlets(DataTypes.INT, DataTypes.FLOAT);
 

Parameters:
types - array of ints that represent the type of data that will be accepted in the corresponding inlet.
See Also:
com.cycling74.max

declareOutlets

protected void declareOutlets(int[] types)
Declare typed outlets. Typed inlets are more efficient than untyped (ie, DataTypes.ALL). To have any effect, this method must be called in your class's constructor. For example, the following call ensures that an object of this class will have an int outlet and a float outlet.
 declareOutlets(DataTypes.INT, DataTypes.FLOAT);
 

Parameters:
types - array of ints that represent the type of data that will be sent out the corresponding inlet.
See Also:
com.cycling74.max

declareIO

protected void declareIO(int ins,
                         int outs)
Declare untyped inlets and outlets. All inlets and outlets are declared to be of type DataTypes.ALL.

Parameters:
ins - the number of untyped inlets.
outs - the number of untyped outlets.

declareTypedIO

protected void declareTypedIO(java.lang.String ins,
                              java.lang.String outs)
Declare typed inlets and outlets. The two input Strings determine the number and type of inlets and outlets. For instance, the following call declares that an object will have two int inlets, a float inlet, then another int inlet, and one LIST outlet.
 declareTypedIO("iifi","L");
 

F or f -> DataTypes.FLOAT
I or i -> DataTypes.INT
M or m -> DataTypes.MESSAGE
L or l -> DataTypes.LIST
other -> DataTypes.ALL

Parameters:
ins - a String whose length and content determines the number and type of the inlets.
outs - a String whose length and content determines the number and type of the outlets.

setInletAssist

protected void setInletAssist(java.lang.String[] messages)
Set the inlet assistance strings.

Parameters:
messages - an array of Strings that will be displayed as assistance when the mouse is held over the corresponding inlet.

setInletAssist

protected void setInletAssist(int index,
                              java.lang.String message)
Set one inlet assistance string.

Parameters:
index - the index of the inlet to set
message - a String that will be displayed as assistance when the mouse is held over the corresponding inlet.

setOutletAssist

protected void setOutletAssist(java.lang.String[] messages)
Set the outlet assistance strings.

Parameters:
messages - an array of Strings that will be displayed as assistance when the mouse is held over the corresponding outlet.

setOutletAssist

protected void setOutletAssist(int index,
                               java.lang.String message)
Set one outlet assistance string.

Parameters:
index - the index of the outlet to set
message - a String that will be displayed as assistance when the mouse is held over the corresponding outlet.

createInfoOutlet

protected void createInfoOutlet(boolean b)
Determine whether or not an info outlet is created. By default an extra outlet is appended to the end of the outlets requested in a class's constructor. This is the info outlet, and it is used to report information from attributes. If the class uses no attributes, or the designer of the class wishes to handle the getting of the attribute values manually, the info outlet may not be necessary. To get rid of it, call createInfoOutlet(false) in the class's constructor. This method is only valid in the constructor.

Parameters:
b - boolean that determines whether or not the info outlet will be created.

getInfoIdx

public int getInfoIdx()
Returns the index of the info outlet.

Returns:
the index of the info outlet. Returns -1 if no info outlet exists.

getNumInlets

public int getNumInlets()
Return the number of inlets.

Returns:
the number of inlets.

getInletType

public int getInletType(int idx)
Returns an inlet type.

Parameters:
idx - the index of the inlet to query
Returns:
the type of the queried inlet
See Also:
com.cycling74.max

getNumOutlets

public int getNumOutlets()
Returns the number of outlets.

Returns:
the number of outlets.

getOutletType

public int getOutletType(int idx)
Returns an outlet type.

Parameters:
idx - the index of the outlet to query
Returns:
the type of the queried outlet
See Also:
com.cycling74.max

getInletAssist

public java.lang.String getInletAssist(int inletIdx)
Describes what inlet inletIdx does.
Called by Max: returns an assist string for inlet inletIdx. Should never be called for an inlet that doesn't exist!
This implementation is pretty dumb. One should normally use the setInletAssist methods to provide inlet assistence to the user. This method can be overridden by subclasses if some special behavior is required.

Parameters:
inletIdx - the index of the inlet for which assistance has been requested
Returns:
a String that describes what the inlet does

bang

protected void bang()
Called by Max: inlet has received a bang value. Override this method in your subclass of MaxObject if you want it to do something useful. By default it does nothing.

See Also:
getInlet()

inlet

protected void inlet(int value)
Called by Max: inlet has received an int value. Override this method in your subclass of MaxObject if you want it to do something specific in response to an integer message. If you do not override it, but you have defined your own inlet(float) method, this default method will cast the incoming int to float and call inlet(float). If your subclass does not have either inlet(int) or inlet(float), this default method will call list(Atom[]) if it exists. If none of those methods exist it will call anything(String, Atom[]) with a message of "int" and a single-element in the Atom array with the value of the incoming int. To determine which inlet an int message arrived at in a multi inlet MaxObject call getInlet(). This will always contain the index of the inlet which last received a message.

Parameters:
value - the int value that the object has received
See Also:
getInlet()

inlet

protected void inlet(float value)
Called by Max: inlet has received a float value. Override this method in your subclass of MaxObject if you want it to do something specific. If you do not override it, but you have defined your own inlet(int) method, this default method will cast the incoming float to int and call inlet(float). If your subclass does not have either inlet(float) or inlet(int), this default method will call list(Atom[]) if it exists. If none of those methods exist it will call anything(String, Atom[]) with a message of "float" and a single-element in the Atom array with the value of the incoming float. To determine which inlet a float message arrived at in a multi inlet MaxObject call getInlet(). This will always contain the index of the inlet which last received a message.

Parameters:
value - the float value that the object has received
See Also:
getInlet()

list

protected void list(Atom[] atomArray)
Called by Max: inlet has received a list. Override this method in your subclass of MaxObject if you want it to do something specific. If you do not override it, but you have defined your own anything(String, Atom[]) method, this default method will pass the array to anything with a message of "list". If you have not defined your own anything method, this default method attempts to map the first element of the list to a matching inlet method. For example, if the first Atom represents an int it will call inlet(int) if you have it defined.

Parameters:
atomArray - the array of Atoms received by the object

list

protected void list(float[] f)
Called by Max: inlet has received a list of floats. This method is faster than list(Atom[]). Override this method in your subclass of MaxObject if you want it to do something specific. If you do not override it, this default method will pass the array to list(Atom[]).

Parameters:
f - the array of floats received by the object.

list

protected void list(int[] i)
Called by Max: inlet has received a list of ints. This method is faster than list(Atom[]). Override this method in your subclass of MaxObject if you want it to do something specific. If you do not override it, this default method will pass the array to list(Atom[]).

Parameters:
i - the array of ints received by the object.

anything

protected void anything(java.lang.String message,
                        Atom[] args)
Called by Max: inlet has received a message. Override this method in your subclass of MaxObject if you want it to do something specific. If there is a public method whose name and signature is identical to the incoming message, this method will not be called.

Parameters:
message - the incoming message
args - the Atom arguments attached to the incoming message

getCodeSourcePath

public java.lang.String getCodeSourcePath()
This method returns the native filesystem path of the class file or jar archive from which this class was loaded.

Returns:
absolute native file system path of the class file or jar archive containing the bytecode for this class.

postCodePath

public void postCodePath()

viewsource

public void viewsource()
Brings up the source code for the java class in an editor. A convenient way to edit, save, and compile your classes. Currently viewing the source of classes residing in jar files is not supported. Source code is searched for at the exact same level in the filesystem as the class file is residing. For instance, if you have a class com/boo/ya/Goober.class somewhere in the classpath it will attempt to find the file com/boo/ya/Goober.java. If the source file is not found at this location mxj will attempt to decompile the class file using JODE (http://jode.sourceforge.net) and display its output in the editor. This may not always be an accurate represenation of the original source. Class files decompiled from a jar are displayed in the editor but are non-editable. To edit these files you must first save them as a different file. This has to do with the difficulty of modifying jar file contents in place.


getInlet

protected int getInlet()
Returns the inlet of the last received message. Eg,
                public inlet(int i) 
                {
                        int index = getInlet();
                        post("int received in inlet "+index);
                }
                

Returns:
the inlet of the last received message.

getOutletAssist

public java.lang.String getOutletAssist(int outletIdx)
Describes what outlet outletIdx does.
Called by Max: returns an assist string for outlet outletIdx. Should never be called for an outlet that doesn't exist!
This implementation is pretty dumb. One should normally use the setOutletAssist methods to provide outlet assistence to the user. This method can be overridden by subclasses if some special behavior is required.

Parameters:
outletIdx - the index of the outlet for which assistance has been requested
Returns:
a String that describes what the outlet does

outletBang

public final boolean outletBang(int outletIdx)
Sends a bang.

Parameters:
outletIdx - the outlet index of the outlet to send the bang from.
Returns:
true if successful.

outlet

public final boolean outlet(int outletIdx,
                            int value)
Sends an int.

Parameters:
outletIdx - outlet number to send from
value - int to send
Returns:
true if successful.

outlet

public final boolean outlet(int outletIdx,
                            byte value)
Sends a byte.

Parameters:
outletIdx - outlet number to send from
value - byte to send
Returns:
true if successful.

outlet

public final boolean outlet(int outletIdx,
                            short value)
Sends a short.

Parameters:
outletIdx - outlet number to send from
value - short to send
Returns:
true if successful.

outlet

public final boolean outlet(int outletIdx,
                            long value)
Sends a long. Warning, information can be lost in the conversion from long to int!

Parameters:
outletIdx - outlet number to send from
value - long to send
Returns:
true if successful.

outlet

public final boolean outlet(int outletIdx,
                            float value)
Sends a float.

Parameters:
outletIdx - outlet number to send from
value - float to send
Returns:
true if successful.

outlet

public final boolean outlet(int outletIdx,
                            double value)
Sends a double. Warning, since the Max float atom type is a 32 bit floating point number information can be lost in the conversion from a java double to a native float!

Parameters:
outletIdx - outlet number to send from
value - double to send
Returns:
true if successful.

outlet

public final boolean outlet(int outletIdx,
                            java.lang.String message)
Sends a message with no arguments. This is equivalent to outlet(outletIdx, message, Atom.emptyArray).

Parameters:
outletIdx - outlet number to send from
message - message to send
Returns:
true if successful.

outlet

public final boolean outlet(int outletIdx,
                            char c)
Sends a char as a message with no arguments. The char is output as a symbol as opposed to its integer value.

Parameters:
outletIdx - outlet number to send from
c - char to send
Returns:
true if successful.

outlet

public final boolean outlet(int outletIdx,
                            boolean value)
Sends a 0 or a 1.

Parameters:
outletIdx - outlet number to send from
value - boolean value to send - true sends a 1, false sends a 0
Returns:
true if successful.

outlet

public final boolean outlet(int outletIdx,
                            java.lang.String message,
                            Atom[] args)
Sends a message.

Parameters:
outletIdx - outlet number to send from
message - message to send
args - Atom array to append as arguments to the message.
Returns:
true if successful.
Throws:
java.lang.NullPointerException - if message or args is null or if args contains null

outlet

public final boolean outlet(int outletIdx,
                            Atom value)
Sends the contents of the Atom out. Calls outlet(int, int), outlet(int, float), or outlet(int, String) depending on the content of the Atom.

Parameters:
outletIdx - outlet number to send from
value - the Atom to send
Returns:
true if successful.
Throws:
java.lang.NullPointerException - if a equals or contains null

outlet

public final boolean outlet(int outletIdx,
                            Atom[] array)
Sends an array of Atoms. If the output array begins with an Atom that represents an int or a float, the array is output as a list. If the output array begins with an Atom that represents a String, the array is output as a message and arguments. If the output array contains only one item, the single item is output by calling outlet(int, Atom).

Parameters:
outletIdx - outlet number to send from
array - the array of Atoms to send
Returns:
true if successful.
Throws:
java.lang.NullPointerException - if value equals or contains null

outlet

public final boolean outlet(int outletIdx,
                            int[] value)
Sends a list of ints.

Parameters:
outletIdx - outlet number to send from
value - list of ints to send
Returns:
true if successful.
Throws:
java.lang.NullPointerException - if value equals or contains null

outlet

public final boolean outlet(int outletIdx,
                            byte[] value)
Sends a list of bytes.

Parameters:
outletIdx - outlet number to send from
value - list of bytes to send
Returns:
true if successful.
Throws:
java.lang.NullPointerException - if value equals or contains null

outlet

public final boolean outlet(int outletIdx,
                            short[] value)
Sends a list of shorts.

Parameters:
outletIdx - outlet number to send from
value - list of shorts to send
Returns:
true if successful.
Throws:
java.lang.NullPointerException - if value equals or contains null

outlet

public final boolean outlet(int outletIdx,
                            long[] value)
Sends a list of longs. Warning, information can be lost in the conversion from long to int!

Parameters:
outletIdx - outlet number to send from
value - list of longs to send
Returns:
true if successful.
Throws:
java.lang.NullPointerException - if value equals or contains null

outlet

public final boolean outlet(int outletIdx,
                            float[] value)
Sends a list of floats.

Parameters:
outletIdx - outlet number to send from
value - list of floats to send
Returns:
true if successful.
Throws:
java.lang.NullPointerException - if value equals or contains null

outlet

public final boolean outlet(int outletIdx,
                            double[] value)
Sends a list of doubles. Warning, information can be lost in the conversion from java double to native float!

Parameters:
outletIdx - outlet number to send from
value - list of doubles to send
Returns:
true if successful.
Throws:
java.lang.NullPointerException - if value equals or contains null

outlet

public final boolean outlet(int outletIdx,
                            java.lang.String[] value)
Sends an array of Strings. The array will be sent as message (the first Atom) and arguments.

Parameters:
outletIdx - outlet number to send from
value - list of Strings to send
Returns:
true if successful.
Throws:
java.lang.NullPointerException - if value equals or contains null

outlet

public final boolean outlet(int outletIdx,
                            char[] value)
Sends an array of chars. The array will be sent as message (the first Atom) and arguments.

Parameters:
outletIdx - outlet number to send from
value - list of chars to send
Returns:
true if successful.
Throws:
java.lang.NullPointerException - if value equals or contains null

outlet

public final boolean outlet(int outletIdx,
                            boolean[] array)
Sends an array of booleans. The array will be sent as a list of 0s and 1s.

Parameters:
outletIdx - outlet number to send from
array - list of booleans to send
Returns:
true if successful.
Throws:
java.lang.NullPointerException - if value equals or contains null

outlet

public final boolean outlet(int outletIdx,
                            java.lang.String msg,
                            int value)
Sends a message with an int arg.

Parameters:
outletIdx - outlet number to send from
msg - Message to send
value - int argument to send
Returns:
true if successful.

outlet

public final boolean outlet(int outletIdx,
                            java.lang.String msg,
                            byte value)
Sends a message with a byte arg.

Parameters:
outletIdx - outlet number to send from
msg - Message to send
value - byte argument to send
Returns:
true if successful.

outlet

public final boolean outlet(int outletIdx,
                            java.lang.String msg,
                            short value)
Sends a message with an short arg.

Parameters:
outletIdx - outlet number to send from
msg - Message to send
value - short argument to send
Returns:
true if successful.

outlet

public final boolean outlet(int outletIdx,
                            java.lang.String msg,
                            long value)
Sends a message with an long arg.

Parameters:
outletIdx - outlet number to send from
msg - Message to send
value - long argument to send(will be truncated to int by Max)
Returns:
true if successful.

outlet

public final boolean outlet(int outletIdx,
                            java.lang.String msg,
                            float value)
Sends a message with a float arg.

Parameters:
outletIdx - outlet number to send from
msg - Message to send
value - float argument to send
Returns:
true if successful.

outlet

public final boolean outlet(int outletIdx,
                            java.lang.String msg,
                            double value)
Sends a message with a double arg. Warning, since the Max float atom type is a 32 bit floating point number information can be lost in the conversion from a java double to a native float!

Parameters:
outletIdx - outlet number to send from
msg - Message to send
value - double to send
Returns:
true if successful.

outlet

public final boolean outlet(int outletIdx,
                            java.lang.String msg,
                            java.lang.String value)
Sends a message with a String arg.

Parameters:
outletIdx - outlet number to send from
msg - Message to send
value - String argument to send
Returns:
true if successful.

outlet

public final boolean outlet(int outletIdx,
                            java.lang.String msg,
                            char c)
Sends a message with a char arg.

Parameters:
outletIdx - outlet number to send from
msg - Message to send
value - char argument to send
Returns:
true if successful.

outlet

public final boolean outlet(int outletIdx,
                            java.lang.String msg,
                            boolean value)
Sends a message with a boolean arg.

Parameters:
outletIdx - outlet number to send from
msg - Message to send
value - boolean value to send - true sends a 1, false sends a 0
Returns:
true if successful.

outlet

public final boolean outlet(int outletIdx,
                            java.lang.String msg,
                            Atom value)
Sends a message with an Atom arg.

Parameters:
outletIdx - outlet number to send from
msg - Message to send
value - Atom value to send.
Returns:
true if successful.

outlet

public final boolean outlet(int outletIdx,
                            java.lang.String msg,
                            int[] value)
Sends a message followed by an array of ints.

Parameters:
outletIdx - outlet number to send from
msg - Message to send
value - array ofint values to send.
Returns:
true if successful.

outlet

public final boolean outlet(int outletIdx,
                            java.lang.String msg,
                            byte[] value)
Sends a message followed by an array of bytes.

Parameters:
outletIdx - outlet number to send from
msg - Message to send
value - array ofbyte values to send.
Returns:
true if successful.

outlet

public final boolean outlet(int outletIdx,
                            java.lang.String msg,
                            short[] value)
Sends a message followed by an array of shorts.

Parameters:
outletIdx - outlet number to send from
msg - Message to send
value - array ofshort values to send.
Returns:
true if successful.

outlet

public final boolean outlet(int outletIdx,
                            java.lang.String msg,
                            long[] value)
Sends a message followed by an array of longs. !!WARNING: longs will be truncated to ints by Max. This is a convenience method.

Parameters:
outletIdx - outlet number to send from
msg - Message to send
value - array oflong values to send.
Returns:
true if successful.

outlet

public final boolean outlet(int outletIdx,
                            java.lang.String msg,
                            float[] value)
Sends a message followed by an array of floats.

Parameters:
outletIdx - outlet number to send from
msg - Message to send
value - array offloat values to send.
Returns:
true if successful.

outlet

public final boolean outlet(int outletIdx,
                            java.lang.String msg,
                            double[] value)
Sends a message followed by an array of doubles. !!WARNING: longs will be truncated to floats by Max. This is a convenience method.

Parameters:
outletIdx - outlet number to send from
msg - Message to send
value - array offloat values to send.
Returns:
true if successful.

outlet

public final boolean outlet(int outletIdx,
                            java.lang.String msg,
                            java.lang.String[] value)
Sends a message followed by an array of Strings.

Parameters:
outletIdx - outlet number to send from
msg - Message to send
value - array ofString values to send.
Returns:
true if successful.

outlet

public final boolean outlet(int outletIdx,
                            java.lang.String msg,
                            char[] value)
Sends a message followed by an array of chars.

Parameters:
outletIdx - outlet number to send from
msg - Message to send
value - array ofchar values to send.
Returns:
true if successful.

outlet

public final boolean outlet(int outletIdx,
                            java.lang.String msg,
                            boolean[] array)
Sends a message followed by an array of booleans.

Parameters:
outletIdx - outlet number to send from
msg - Message to send
value - array ofboolean values to send.true will be sent as 1 and false will be sent as 0.
Returns:
true if successful.

outletBangHigh

public final boolean outletBangHigh(int outletIdx)
Sends a bang out an outlet in the timer thread if overdrive is on. This is the same as using a "delay 0" object in the Max world.

Parameters:
outletIdx - the index of the outlet to send through
Returns:
true if successful.

outletHigh

public final boolean outletHigh(int outletIdx,
                                int value)
Sends an int out an outlet in the timer thread if overdrive is on. This is the same as using a "delay 0" object in the Max world.

Parameters:
outletIdx - the index of the outlet to send through
value - the value to send
Returns:
true if successful.
Throws:
java.lang.IndexOutOfBoundsException - if outletIdx is out of range

outletHigh

public final boolean outletHigh(int outletIdx,
                                float value)
Sends a float out an outlet in the timer thread. This is the same as using a "delay 0" object in the Max world.

Parameters:
outletIdx - the index of the outlet to send through
value - the value to send
Returns:
true if successful.
Throws:
java.lang.IndexOutOfBoundsException - if outletIdx is out of range

outletHigh

public final boolean outletHigh(int outletIdx,
                                double value)
Sends a double out an outlet in the timer thread. This is the same as using a "delay 0" object in the Max world. Warning, loss of precision can occur when converting from java double to native float!

Parameters:
outletIdx - the index of the outlet to send through
value - the value to send
Returns:
true if successful.
Throws:
java.lang.IndexOutOfBoundsException - if outletIdx is out of range

outletHigh

public final boolean outletHigh(int outletIdx,
                                java.lang.String message)
Sends a message with no arguments out an outlet in the timer thread. This is the same as using a "delay 0" object in the Max world.

Parameters:
outletIdx - the index of the outlet to send through
message - the message to send
Returns:
true if successful.
Throws:
java.lang.IndexOutOfBoundsException - if outletIdx is out of range

outletHigh

public final boolean outletHigh(int outletIdx,
                                java.lang.String message,
                                Atom[] args)
Sends a message and arguments out an outlet in the timer thread. This is the same as using a "delay 0" object in the Max world.

Parameters:
outletIdx - the index of the outlet to send through
message - the message to send
args - the arguments to append to the message
Returns:
true if successful.
Throws:
java.lang.IndexOutOfBoundsException - if outletIdx is out of range

outletHigh

public final boolean outletHigh(int outletIdx,
                                java.lang.String message,
                                int[] values)
Sends a message and arguments out an outlet in the timer thread. This is the same as using a "delay 0" object in the Max world.

Parameters:
outletIdx - the index of the outlet to send through
message - the message to send
args - the arguments to append to the message
Returns:
true if successful.
Throws:
java.lang.IndexOutOfBoundsException - if outletIdx is out of range

outletHigh

public final boolean outletHigh(int outletIdx,
                                java.lang.String message,
                                float[] values)
Sends a message and arguments out an outlet in the timer thread. This is the same as using a "delay 0" object in the Max world.

Parameters:
outletIdx - the index of the outlet to send through
message - the message to send
args - the arguments to append to the message
Returns:
true if successful.
Throws:
java.lang.IndexOutOfBoundsException - if outletIdx is out of range

outletHigh

public final boolean outletHigh(int outletIdx,
                                Atom[] value)
Sends a list out an outlet in the timer thread. This is the same as using a "delay 0" object in the Max world.

Parameters:
outletIdx - the index of the outlet to send through
value - the list of Atoms to send
Returns:
true if successful.
Throws:
java.lang.IndexOutOfBoundsException - if outletIdx is out of range

outletHigh

public final boolean outletHigh(int outletIdx,
                                int[] values)
Sends a list out an outlet in the timer thread. This is the same as using a "delay 0" object in the Max world.

Parameters:
outletIdx - the index of the outlet to send through
value - the list of Atoms to send
Returns:
true if successful.
Throws:
java.lang.IndexOutOfBoundsException - if outletIdx is out of range

outletHigh

public final boolean outletHigh(int outletIdx,
                                float[] values)
Sends a list out an outlet in the timer thread. This is the same as using a "delay 0" object in the Max world.

Parameters:
outletIdx - the index of the outlet to send through
value - the list of Atoms to send
Returns:
true if successful.
Throws:
java.lang.IndexOutOfBoundsException - if outletIdx is out of range

toString

public java.lang.String toString()
Return a human-readable version of this object.

Overrides:
toString in class java.lang.Object

save

protected void save()
Called by Max when the user saves the patch.
The typical use of this method is to save some information about the current state of the object in the patcher file. This is accomplished using the embedMessage method. embedMessage is only valid if called from within the save method and in no other context. This a typical overridden save method will consist of one or more embdedMessage calls.The save method does nothing by default - override this method in your MaxObject subclass to make it do something useful.

See Also:
embedMessage(java.lang.String, com.cycling74.max.Atom[])

loadbang

protected void loadbang()
Called by Max at loadbang time (ie, when the enclosing patch has finished loading). Override this method in your MaxObject subclass to make it do something useful. Your class can respond to the loadbang message in any way that it wants, but before implementing a method that responds to loadbang, keep in mind that the user can connect your object to the outlet of a loadbang object to perform initialization if necessary. Note that you do not get the loadbang message when the user creates a new instance of your object in the Patcher window, only when a Max file containing your class is loaded from disk. You can assume that all elements of a patch have been loaded and all connections have been made and are valid when the loadbang message is sent to your object.


dblclick

protected void dblclick()
Called by Max when the user double-clicks on the object box. Override this method in your MaxObject subclass to make it do something useful,for example, opening up a window to display information about the state of your object.


embedMessage

protected void embedMessage(java.lang.String msg,
                            Atom[] args)
Embed messages in a patcher file for initialization purposes.
Use this method to save messages that will be sent to the object when the patch is next opened. For instance, the following class saves the int variable importantData in the patcher file. When the patcher file is opened, the set method is called with the old value of importantData, just as if it had been sent in one of the object's inlets.
public class saveExample extends MaxObject {

        private int importantData;

        public void set(int i) {
                importantData = i;
        }

        public void get() {
                outlet(0, importantData);
        }

        public void save() {
                Atom[] data = new Atom[] {Atom.newAtom(importantData)};
                embedMessage("set", data);
        }

}
embedmessage can only be called from within the save method and is valid in no other context.

Parameters:
msg - the name of the method that will be called
args - the arguments to pass to the method
See Also:
save()

declareAttribute

protected void declareAttribute(java.lang.String name)
Declare an attribute with default getter and setter methods. Deafult getter and setters can only be generated for member variables with primative type int,float,boolean etc and String and Atom. Primative array types are also supported as well as String[] and Atom[]

Parameters:
name - the name of the variable to declare as an attribute

declareReadOnlyAttribute

protected void declareReadOnlyAttribute(java.lang.String name)
Declare an attribute with default getter method. Deafult getters can only be generated for member variables with primative type int,float,boolean etc and String and Atom. Primative array types are also supported as well as String[] and Atom[]

Parameters:
name - the name of the variable to declare as an attribute

declareAttribute

protected void declareAttribute(java.lang.String name,
                                java.lang.String getter,
                                java.lang.String setter)
Declare an attribute with specific getter and setter methods.
A setter method must return void and take as an argument the same type as the attribute variable. A getter method must take no arguments and return an Atom array. Tthis array will be appended as arguments to the name of the attribute and sent out of the info outlet.
To only set either the getter or the setter, declare the other method as null. For instance,
 declareAttribute("myAttribute", null, "setMyAttribute");
 
uses a specific setter method and the default getter method.
If an object is instantiated with attribute arguments (eg, @myAttribute) the setter method will be executed before the parent Max patch is well-formed and stable. Therefore it is critical that the setter method not execute any method that interacts with the Max universe - for instance, sending data out an outlet. Setting a MaxClock or MaxQelem whose Executable will interact with the Max universe has the potential to be similarly disastrous. For instance, an outlet call could be executed before the outlet is connected to anything valid.

Parameters:
name - the name of the variable to declare as an attribute
getter - the name of the getter method
setter - the name of the setter method

declareReadOnlyAttribute

protected void declareReadOnlyAttribute(java.lang.String name,
                                        java.lang.String getter)
Declare a readonly attribute with a specific getter method.
. A getter method must take no arguments and return an Atom array. This array will be appended as arguments to the name of the attribute and sent out of the info outlet.

Parameters:
name - the name of the variable to declare as a readonly attribute
getter - the name of the getter method

getAttr

public java.lang.Object getAttr(java.lang.String name)
Get the current value of a declared attribute as a java.lang.Object. It is the responsibility of the programmer to cast this value to the correct type. Primatively typed attributes are returned as instances of their wrapper class. For instance an int attribute will be returned as a java.lang.Integer. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
Returns:
attribute value as a java.lang.Object.
Throws:
MaxRuntimeException - if attr named name does not exist.

setAttr

public void setAttr(java.lang.String name,
                    java.lang.Object val)
Set the current value of a declared attribute. It is the responsibility of the programmer that the underlying type of val matches the type of the declared attribute. Primatively typed attributes are set using instances of their wrapper class. For instance when setting an int attribute the val argument should be an instance of java.lang.Integer. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
val - the value you wish to set it to.
Throws:
MaxRuntimeException - if attr named name does not exist.

setAttr

public void setAttr(java.lang.String name,
                    java.lang.Object[] args)

getAttrBool

public boolean getAttrBool(java.lang.String name)
Get the current value of a declared boolean attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
Returns:
attribute value.
Throws:
MaxRuntimeException - if attr named name does not exist.

getAttrBoolArray

public boolean[] getAttrBoolArray(java.lang.String name)
Get the current value of a declared boolean array attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
Returns:
attribute value.
Throws:
MaxRuntimeException - if attr named name does not exist.

getAttrByte

public float getAttrByte(java.lang.String name)
Get the current value of a declared byte attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
Returns:
attribute value.
Throws:
MaxRuntimeException - if attr named name does not exist.

getAttrByteArray

public byte[] getAttrByteArray(java.lang.String name)
Get the current value of a declared byte array attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
Returns:
attribute value.
Throws:
MaxRuntimeException - if attr named name does not exist.

getAttrChar

public char getAttrChar(java.lang.String name)
Get the current value of a declared char attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
Returns:
attribute value.
Throws:
MaxRuntimeException - if attr named name does not exist.

getAttrCharArray

public char[] getAttrCharArray(java.lang.String name)
Get the current value of a declared char array attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
Returns:
attribute value.
Throws:
MaxRuntimeException - if attr named name does not exist.

getAttrShort

public short getAttrShort(java.lang.String name)
Get the current value of a declared short attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
Returns:
attribute value.
Throws:
MaxRuntimeException - if attr named name does not exist.

getAttrShortArray

public short[] getAttrShortArray(java.lang.String name)
Get the current value of a declared short array attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
Returns:
attribute value.
Throws:
MaxRuntimeException - if attr named name does not exist.

getAttrInt

public int getAttrInt(java.lang.String name)
Get the current value of a declared int attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
Returns:
attribute value.
Throws:
MaxRuntimeException - if attr named name does not exist.

getAttrIntArray

public int[] getAttrIntArray(java.lang.String name)
Get the current value of a declared int array attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
Returns:
attribute value.
Throws:
MaxRuntimeException - if attr named name does not exist.

getLongAttr

public long getLongAttr(java.lang.String name)
Get the current value of a declared long attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
Returns:
attribute value.
Throws:
MaxRuntimeException - if attr named name does not exist.

getAttrLongArray

public long[] getAttrLongArray(java.lang.String name)
Get the current value of a declared long array attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
Returns:
attribute value.
Throws:
MaxRuntimeException - if attr named name does not exist.

getAttrFloat

public float getAttrFloat(java.lang.String name)
Get the current value of a declared float attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
Returns:
attribute value.
Throws:
MaxRuntimeException - if attr named name does not exist.

getAttrFloatArray

public float[] getAttrFloatArray(java.lang.String name)
Get the current value of a declared float array attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
Returns:
attribute value.
Throws:
MaxRuntimeException - if attr named name does not exist.

getAttrDouble

public double getAttrDouble(java.lang.String name)
Get the current value of a declared double attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
Returns:
attribute value.
Throws:
MaxRuntimeException - if attr named name does not exist.

getAttrDoubleArray

public double[] getAttrDoubleArray(java.lang.String name)
Get the current value of a declared double array attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
Returns:
attribute value.
Throws:
MaxRuntimeException - if attr named name does not exist.

getAttrString

public java.lang.String getAttrString(java.lang.String name)
Get the current value of a declared String attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
Returns:
attribute value.
Throws:
MaxRuntimeException - if attr named name does not exist.

getAttrStringArray

public java.lang.String[] getAttrStringArray(java.lang.String name)
Get the current value of a declared String array attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
Returns:
attribute value.
Throws:
MaxRuntimeException - if attr named name does not exist.

getAttrAtomArray

public Atom[] getAttrAtomArray(java.lang.String name)
Get the current value of a declared Atom array attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
Returns:
attribute value.
Throws:
MaxRuntimeException - if attr named name does not exist.

setAttr

public void setAttr(java.lang.String name,
                    boolean val)
Set the current value of a declared boolean attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
val - the valuse you wish to set it to.
Throws:
MaxRuntimeException - if attr named name does not exist.

setAttr

public void setAttr(java.lang.String name,
                    boolean[] val)
Set the current value of a declared boolean array attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
val - the valuse you wish to set it to.
Throws:
MaxRuntimeException - if attr named name does not exist.

setAttr

public void setAttr(java.lang.String name,
                    byte val)
Set the current value of a declared byte attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
val - the valuse you wish to set it to.
Throws:
MaxRuntimeException - if attr named name does not exist.

setAttr

public void setAttr(java.lang.String name,
                    byte[] val)
Set the current value of a declared byte array attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
val - the valuse you wish to set it to.
Throws:
MaxRuntimeException - if attr named name does not exist.

setAttr

public void setAttr(java.lang.String name,
                    char val)
Set the current value of a declared char attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
val - the valuse you wish to set it to.
Throws:
MaxRuntimeException - if attr named name does not exist.

setAttr

public void setAttr(java.lang.String name,
                    char[] val)
Set the current value of a declared char array attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
val - the valuse you wish to set it to.
Throws:
MaxRuntimeException - if attr named name does not exist.

setAttr

public void setAttr(java.lang.String name,
                    short val)
Set the current value of a declared short attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
val - the valuse you wish to set it to.
Throws:
MaxRuntimeException - if attr named name does not exist.

setAttr

public void setAttr(java.lang.String name,
                    short[] val)
Set the current value of a declared short array attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
val - the valuse you wish to set it to.
Throws:
MaxRuntimeException - if attr named name does not exist.

setAttr

public void setAttr(java.lang.String name,
                    int val)
Set the current value of a declared int attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
val - the valuse you wish to set it to.
Throws:
MaxRuntimeException - if attr named name does not exist.

setAttr

public void setAttr(java.lang.String name,
                    int[] val)
Set the current value of a declared int array attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
val - the valuse you wish to set it to.
Throws:
MaxRuntimeException - if attr named name does not exist.

setAttr

public void setAttr(java.lang.String name,
                    long val)
Set the current value of a declared long attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
val - the valuse you wish to set it to.
Throws:
MaxRuntimeException - if attr named name does not exist.

setAttr

public void setAttr(java.lang.String name,
                    long[] val)
Set the current value of a declared long array attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
val - the valuse you wish to set it to.
Throws:
MaxRuntimeException - if attr named name does not exist.

setAttr

public void setAttr(java.lang.String name,
                    float val)
Set the current value of a declared float attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
val - the valuse you wish to set it to.
Throws:
MaxRuntimeException - if attr named name does not exist.

setAttr

public void setAttr(java.lang.String name,
                    float[] val)
Set the current value of a declared float array attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
val - the valuse you wish to set it to.
Throws:
MaxRuntimeException - if attr named name does not exist.

setAttr

public void setAttr(java.lang.String name,
                    double val)
Set the current value of a declared double attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
val - the valuse you wish to set it to.
Throws:
MaxRuntimeException - if attr named name does not exist.

setAttr

public void setAttr(java.lang.String name,
                    double[] val)
Set the current value of a declared double array attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
val - the valuse you wish to set it to.
Throws:
MaxRuntimeException - if attr named name does not exist.

setAttr

public void setAttr(java.lang.String name,
                    java.lang.String val)
Set the current value of a declared String attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
val - the valuse you wish to set it to.
Throws:
MaxRuntimeException - if attr named name does not exist.

setAttr

public void setAttr(java.lang.String name,
                    java.lang.String[] val)
Set the current value of a declared String array attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
val - the valuse you wish to set it to.
Throws:
MaxRuntimeException - if attr named name does not exist.

setAttr

public void setAttr(java.lang.String name,
                    Atom[] val)
Set the current value of a declared Atom array attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Parameters:
name - the name of the previously declared attribute.
val - the valuse you wish to set it to.
Throws:
MaxRuntimeException - if attr named name does not exist.

getAttributeInfo

public AttributeInfo[] getAttributeInfo()
Get the array of AttributeInfo objects. One for each previously declared attribute. Attributes are declared using the declareAttribute methods of MaxObject.

Returns:
array of com.cycling74.max.AttributeInfo objects.

bail

protected static void bail(java.lang.String errormsg)
If called during your constructor bail will cause no instance of the class to be instantiated within max and the mxj box will show up in the patcher as invalid. For instance if you required arguments for your class which were not there you could use bail to print a usage message to the console.
    public class myobject extends MaxObject
    {
        private int _arg = 0;
        //called when someone types [mxj myobject] into a box
        public myobject()
        {
            bail("usage: [mxj myobject required_arg]");
        }
        //called when someone types [mxj myobject 24] into a box
        public myobject(int required_arg)
        {
            _arg = required_arg;
        }

        ...blah blah blah    
    }
    

Parameters:
error - or usage message you wish printed to the console.

gc

public void gc()
Invoke garbage collection via System.gc().


zap

public void zap()
Force the next class to be loaded by mxj to be loaded with a new MXJClassLoader.