From a764e59e1d3a8e330f0d484fdb26b35ca3f0b2e4 Mon Sep 17 00:00:00 2001
From: Hans-Christoph Steiner Here is a basic guideline for using the MSPObject:
+ * import com.cycling74.max.*;
+ * import com.cycling74.msp.*;
+ * import java.lang.reflection.Method;
+ *
+ * public class panner extends MSPObject {
+ * float left = 1, right = 1;
+ *
+ * public panner() {
+ * declareInlets( new int[] { SIGNAL, DataTypes.ANYTHING } );
+ * declareOutlets( new int[] { SIGNAL, SIGNAL } );
+ * }
+ *
+ * // From 0..127
+ * public void inlet(float val) {
+ * if ( val > 64 ) {
+ * right = 1;
+ * left = ((127-val) / 64);
+ * } else {
+ * left = 1;
+ * right = val / 64;
+ * }
+ * }
+ *
+ * public Method dsp(MSPSignal[] ins, MSPSignal[] outs) {
+ * return getPerformMethod("perform");
+ * }
+ *
+ * public void perform(MSPSignal[] ins, MSPSignal[] outs) {
+ * for (int i=0;i<ins[0].n;i++) {
+ * outs[0].vec[i] = ins[0].vec[i] * left;
+ * outs[1].vec[i] = ins[0].vec[i] * right;
+ * }
+ * }
+ * }
+ *
methodName
with signature
+ * (MSPSignal[], MSPSignal[]) in the current class.
+ * @param methodName the name of the method in the current class
+ * @return the method reflection
+ */
+ protected Method getPerformMethod(String methodName) {
+ try {
+ Method m = getClass().getDeclaredMethod(methodName, new Class[] {
+ MSP_SIGNAL_ARRAY_CLZ, MSP_SIGNAL_ARRAY_CLZ });
+ return m;
+ } catch ( NoSuchMethodException e ) {
+ error("pdj~: method: " + methodName + " not found in class in:" + getClass().toString());
+ }
+ return null;
+ }
+
+ /**
+ * Force to copy of each MSPBuffer when performer is called. Right now,
+ * on pdj the MSPBuffer is always copied.
+ * @param copyBuffer true if you need to copyBuffer
+ */
+ protected void setNoInPlace(boolean copyBuffer) {
+ //this.copyBuffer = copyBuffer;
+ }
+
+ /**
+ * This method is called when the dsp is start/stop.
+ * NOT USED ON PD.
+ * @param dspRunning true if the dsp is running
+ */
+ protected void dspstate(boolean dspRunning) {
+ }
+
+
+ /**
+ * Declare the inlets used by this object. Use MSPObject.SIGNAL
+ * to define a signal inlet. Note: any signal inlet won't
+ * be able to process any atom messages.
+ */
+ protected void declareInlets(int[] types) {
+ int i, inlets = 0;
+ for (i=0;i