com.cycling74.msp
Class MSPObject

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

public abstract class MSPObject
extends MaxObject

Main object to extend to use dsp with pd. You will need to use the pdj~ external if you want to process signals. Before the dsp starts processing, the method dsp will be called and it must return the performer method that will process each dsp cycles.

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;
       }
   }
 }
 


Field Summary
static Class MSP_SIGNAL_ARRAY_CLZ
           
static int SIGNAL
          Use this value to indentify a signal intlet/outlet to the method declareInlet/declareOutlet.
 
Fields inherited from class com.cycling74.max.MaxObject
EMPTY_STRING_ARRAY, NO_INLETS, NO_OUTLETS
 
Constructor Summary
MSPObject()
           
 
Method Summary
protected  void declareInlets(int[] types)
          Declare the inlets used by this object.
protected  void declareOutlets(int[] types)
          Declare the outlets used by this object.
abstract  Method dsp(MSPSignal[] ins, MSPSignal[] outs)
          Initialize the dsp state.
protected  void dspstate(boolean dspRunning)
          This method is called when the dsp is start/stop.
protected  Method getPerformMethod(String methodName)
          Quicky method to be used with dsp(MSPSignal[], MSPSignal[]).
protected  void setNoInPlace(boolean copyBuffer)
          Force to copy of each MSPBuffer when performer is called.
 
Methods inherited from class com.cycling74.max.MaxObject
anything, bail, bang, createInfoOutlet, declareAttribute, declareIO, declareReadOnlyAttribute, declareTypedIO, embedMessage, error, gc, getContext, getErrorStream, getInfoIdx, getInlet, getInletType, getName, getNumInlets, getNumOutlets, getOutletType, getParentPatcher, getPostStream, inlet, inlet, list, loadbang, notifyDeleted, ouch, outlet, outlet, outlet, outlet, outlet, outlet, outlet, outlet, outlet, outlet, outlet, outlet, outlet, outlet, outlet, outlet, outlet, outlet, outlet, outletBang, outletBangHigh, outletHigh, outletHigh, outletHigh, outletHigh, outletHigh, outletHigh, post, save, setInletAssist, setInletAssist, setName, setOutletAssist, setOutletAssist, showException, showException, viewsource, zap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SIGNAL

public static final int SIGNAL
Use this value to indentify a signal intlet/outlet to the method declareInlet/declareOutlet.

See Also:
Constant Field Values

MSP_SIGNAL_ARRAY_CLZ

public static final Class MSP_SIGNAL_ARRAY_CLZ
Constructor Detail

MSPObject

public MSPObject()
Method Detail

dsp

public abstract Method dsp(MSPSignal[] ins,
                           MSPSignal[] outs)
Initialize the dsp state. From the numbers of input/output this method must return a performing method.

Parameters:
ins - input signals
outs - output signals
Returns:
the method to execute at each dsp cycle

getPerformMethod

protected Method getPerformMethod(String methodName)
Quicky method to be used with dsp(MSPSignal[], MSPSignal[]). It will return the method name methodName with signature (MSPSignal[], MSPSignal[]) in the current class.

Parameters:
methodName - the name of the method in the current class
Returns:
the method reflection

setNoInPlace

protected void setNoInPlace(boolean copyBuffer)
Force to copy of each MSPBuffer when performer is called. Right now, on pdj the MSPBuffer is always copied.

Parameters:
copyBuffer - true if you need to copyBuffer

dspstate

protected void dspstate(boolean dspRunning)
This method is called when the dsp is start/stop. NOT USED ON PD.

Parameters:
dspRunning - true if the dsp is running

declareInlets

protected void declareInlets(int[] types)
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.

Overrides:
declareInlets in class MaxObject
Parameters:
types - the type of message that this inlet will use.
See Also:
DataTypes

declareOutlets

protected void declareOutlets(int[] types)
Declare the outlets used by this object. Use MSPObject.SIGNAL to define a signal outlet.

Overrides:
declareOutlets in class MaxObject
Parameters:
types - the type of message that this inlet will use.
See Also:
DataTypes


This API is based on mxj for Max/MSP by Cycling74. Please see original MXJ implementation.