|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.cycling74.max.MaxObject
public class MaxObject
Main object to extend to use with pd. The name of this class will reflect the name of the pdj object when it is instanciated.
Here is a basic guideline for using the MaxObject:
import com.cycling74.max.*;
public class example extends MaxObject {
// called when arguments are used in object creation
public example(Atom args[]) {
for(int i=0;i<args.length;i++) {
post("args:" + args[i].toString());
}
}
// this method will be called when a float is sended to the object
public inlet(float f) {
post("hello float:" + f);
outlet(0, f);
}
// this method will be called when symbol callme is sended to the object
public callme(Atom args[]) {
post("hello object:" + args[0]);
outlet(0, args[0]);
}
// this method will be called when bang is sended to the object
public bang() {
post("hello bang");
outletBang(0);
}
}
Compile this class by adding pdj.jar on the classpath and put the example.class in the classes directory found in your pdj home. You can also edit directly this class in the classes directory and pdj will try to compile it for you.
| Field Summary | |
|---|---|
static String[] |
EMPTY_STRING_ARRAY
Defined in the original MXJ API; don't know what it is used for... |
static int[] |
NO_INLETS
Use this to declare that your object has no inlets. |
static int[] |
NO_OUTLETS
Use this to declare that your object has no outlets. |
| Constructor Summary | |
|---|---|
protected |
MaxObject()
Default constructor for MaxObject. |
| Method Summary | |
|---|---|
protected void |
anything(String symbol,
Atom[] args)
Called by PD when pdj receives an un-overriden method. |
protected static void |
bail(String errormsg)
Bail will throw an exception upon object instanciation. |
protected void |
bang()
Called by PD when pdj receives a bang from an inlet. |
protected void |
createInfoOutlet(boolean flag)
Tells the constructor to create a info outlet. |
protected void |
declareAttribute(String name)
Creates a attribute with default setter and getter. |
protected void |
declareInlets(int[] types)
Declare the inlets used by this object. |
protected void |
declareIO(int in,
int out)
Quickie method for declaring both inlet and outlet that will use any type of message (DataTypes.ANYTHING) |
protected void |
declareOutlets(int[] types)
Declare the outlets used by this object. |
protected void |
declareReadOnlyAttribute(String name)
Creates a attribute with default getter no setter. |
protected void |
declareTypedIO(String ins,
String outs)
Used to defined typed input and output for this object. |
protected void |
embedMessage(String msg,
Atom[] args)
NOT USED IN PD. |
static void |
error(String message)
Will show an error message in the pure-data console. |
void |
gc()
Useless, but in the original API. |
static Object |
getContext()
NOT USED IN PD. Throws UnsupportdOperationException |
static com.cycling74.io.ErrorStream |
getErrorStream()
Returns the error stream of PDJ. |
int |
getInfoIdx()
Returns the index of the info outlet |
protected int |
getInlet()
Returns the index of the inlet that has just received a message. |
int |
getInletType(int idx)
Returns the type the inlet at index 'idx'. |
String |
getName()
Returns the object name. |
int |
getNumInlets()
Returns the number of inlets declared. |
int |
getNumOutlets()
Returns the number of outlets declared. |
int |
getOutletType(int idx)
Returns the type of the outlet at index 'idx'. |
MaxPatcher |
getParentPatcher()
Returns the object representing the pd patch. |
static com.cycling74.io.PostStream |
getPostStream()
Returns the output stream of PDJ. |
protected void |
inlet(float f)
Called by PD when pdj receives a float from an inlet. |
protected void |
inlet(int i)
This will be called if pd sends a float and the float method is not overridden. |
protected void |
list(Atom[] args)
Called by PD when pdj receives a list of atoms. |
protected void |
loadbang()
Called by PD when the current patch issue a loadbang message. |
void |
notifyDeleted()
This method is called when the object is deleted by the user. |
static void |
ouch(String message)
Will show an error message in the pure-data console and crash pure-data. |
boolean |
outlet(int outlet,
Atom value)
Sends atom value to outlet x. |
boolean |
outlet(int outlet,
Atom[] value)
Sends atoms to outlet x. |
boolean |
outlet(int outlet,
byte value)
Sends a byte to outlet x. |
boolean |
outlet(int outlet,
byte[] value)
Sends byte to outlet x. |
boolean |
outlet(int outlet,
char value)
Sends a char to outlet x. |
boolean |
outlet(int outlet,
char[] value)
Sends char to outlet x. |
boolean |
outlet(int outlet,
double value)
Sends a double to outlet x. |
boolean |
outlet(int outlet,
double[] value)
Sends doubles to outlet x. |
boolean |
outlet(int outlet,
float value)
Sends a float to outlet x. |
boolean |
outlet(int outlet,
float[] value)
Sends floats to outlet x. |
boolean |
outlet(int outlet,
int value)
Sends a int to outlet x. |
boolean |
outlet(int outlet,
int[] value)
Sends ints to outlet x. |
boolean |
outlet(int outlet,
long value)
Sends a long to outlet x. |
boolean |
outlet(int outlet,
long[] value)
Sends longs to outlet x. |
boolean |
outlet(int outlet,
short value)
Sends a short to outlet x. |
boolean |
outlet(int outlet,
short[] value)
Sends shorts to outlet x. |
boolean |
outlet(int outlet,
String value)
Sends a symbol to outlet x. |
boolean |
outlet(int outlet,
String[] value)
Sends symbols to outlet x. |
boolean |
outlet(int outlet,
String message,
Atom[] value)
Sends message with argument to outlet x. |
boolean |
outletBang(int outlet)
Sends a bang to outlet x. |
boolean |
outletBangHigh(int outlet)
|
boolean |
outletHigh(int outlet,
Atom[] value)
|
boolean |
outletHigh(int outlet,
double value)
|
boolean |
outletHigh(int outlet,
float value)
|
boolean |
outletHigh(int outlet,
int value)
|
boolean |
outletHigh(int outlet,
String value)
|
boolean |
outletHigh(int outlet,
String msg,
Atom[] args)
|
static void |
post(String message)
Will show an info message in the pure-data console. |
protected void |
save()
NOT USED IN PD. |
protected void |
setInletAssist(int index,
String message)
NOT USED IN PD. |
protected void |
setInletAssist(String[] messages)
NOT USED IN PD. |
void |
setName(String name)
Sets the object name. |
protected void |
setOutletAssist(int index,
String message)
NOT USED IN PD. |
protected void |
setOutletAssist(String[] messages)
NOT USED IN PD. |
static void |
showException(String message,
Throwable t)
Show the exception in the pure-data console with a message. |
static void |
showException(Throwable t)
Show the exeception in the pure-data console. |
void |
viewsource()
NOT USED IN PD. |
void |
zap()
Refresh/reinitialize the PDJ classloader. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int[] NO_INLETS
public static final int[] NO_OUTLETS
public static final String[] EMPTY_STRING_ARRAY
| Constructor Detail |
|---|
protected MaxObject()
| Method Detail |
|---|
public static void error(String message)
message - the string to showpublic static void post(String message)
message - the string to showpublic static void ouch(String message)
message - the message to show when you make pd crashpublic static void showException(Throwable t)
t - the exception it self
public static void showException(String message,
Throwable t)
message - the message that comes with the exceptiont - the exception it selfpublic String getName()
public void setName(String name)
name - pdj object namepublic void notifyDeleted()
protected static void bail(String errormsg)
errormsg - the error message to showprotected void declareInlets(int[] types)
types - the type of message that this inlet will use.DataTypesprotected void declareOutlets(int[] types)
types - the type of message that this inlet will use.DataTypes
protected void declareTypedIO(String ins,
String outs)
ins - list of inlet to createouts - list of outlet to create
protected void declareIO(int in,
int out)
in - the number of inlet to createout - the number of outlet to createprotected void declareAttribute(String name)
name - name of the java field in this class to map.protected void declareReadOnlyAttribute(String name)
name - name of the java field in this class to map.protected void createInfoOutlet(boolean flag)
flag - false to prevent the creation of the info outletpublic int getInletType(int idx)
idx - the outlet position
public int getOutletType(int idx)
idx - the outlet position
public int getNumInlets()
public int getNumOutlets()
protected void loadbang()
protected int getInlet()
public int getInfoIdx()
public final boolean outletBang(int outlet)
outlet - the outlet number to use
public final boolean outlet(int outlet,
float value)
outlet - the outlet number to usevalue - the float value
public final boolean outlet(int outlet,
float[] value)
outlet - the outlet number to usevalue - the array of float to send
public final boolean outlet(int outlet,
String value)
outlet - the outlet number to usevalue - the symbol
public final boolean outlet(int outlet,
String[] value)
outlet - the outlet number to usevalue - the array of symbol to send
public final boolean outlet(int outlet,
byte value)
outlet - the outlet number to usevalue - the byte value
public final boolean outlet(int outlet,
byte[] value)
outlet - the outlet number to usevalue - the array of byte to send
public final boolean outlet(int outlet,
char value)
outlet - the outlet number to usevalue - the char value
public final boolean outlet(int outlet,
char[] value)
outlet - the outlet number to usevalue - the array of char to send
public final boolean outlet(int outlet,
short value)
outlet - the outlet number to usevalue - the short value
public final boolean outlet(int outlet,
short[] value)
outlet - the outlet number to usevalue - the array of short to send
public final boolean outlet(int outlet,
int value)
outlet - the outlet number to usevalue - the int value
public final boolean outlet(int outlet,
int[] value)
outlet - the outlet number to usevalue - the array of int to send
public final boolean outlet(int outlet,
long value)
outlet - the outlet number to usevalue - the long value
public final boolean outlet(int outlet,
long[] value)
outlet - the outlet number to usevalue - the array of longs to send
public final boolean outlet(int outlet,
double value)
outlet - the outlet number to usevalue - the double value
public final boolean outlet(int outlet,
double[] value)
outlet - the outlet number to usevalue - the array of double to send
public final boolean outlet(int outlet,
String message,
Atom[] value)
outlet - the outlet number to usemessage - the message symbol namevalue - the arguments
public final boolean outlet(int outlet,
Atom value)
outlet(int, float) otherwise outlet(int, String)
outlet - the outlet number to usevalue - the atom value to send
public final boolean outlet(int outlet,
Atom[] value)
outlet(outlet, Atom value) will be called. If the
first element of the array is a float/int, list will be
appended to the message. Otherwise, the first atom will be the
message and the rest of it the arguments.
outlet - the outlet number to usevalue - the arguments
protected void bang()
getInlet() to know which inlet has received the message.
protected void inlet(int i)
getInlet() to know which inlet has
received the message.
i - int valueprotected void inlet(float f)
getInlet() to know which inlet has received the message.
f - float value received from the inletprotected void list(Atom[] args)
getInlet() to know which inlet has received the message.
args - the list
protected void anything(String symbol,
Atom[] args)
getInlet()
to know which inlet has received the message.
symbol - first atom symbol representationargs - the arguments of the messagepublic final boolean outletBangHigh(int outlet)
public final boolean outletHigh(int outlet,
int value)
public final boolean outletHigh(int outlet,
float value)
public final boolean outletHigh(int outlet,
double value)
public final boolean outletHigh(int outlet,
String value)
public final boolean outletHigh(int outlet,
String msg,
Atom[] args)
public final boolean outletHigh(int outlet,
Atom[] value)
public static com.cycling74.io.PostStream getPostStream()
public static com.cycling74.io.ErrorStream getErrorStream()
public void viewsource()
public static Object getContext()
UnsupportdOperationException
public MaxPatcher getParentPatcher()
protected void save()
protected void setInletAssist(String[] messages)
protected void setInletAssist(int index,
String message)
protected void setOutletAssist(String[] messages)
protected void setOutletAssist(int index,
String message)
protected void embedMessage(String msg,
Atom[] args)
public void gc()
public void zap()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||