aboutsummaryrefslogtreecommitdiff
path: root/src/java/com/cycling74/msp/MSPPerformer.java
blob: 2201d823eeeac188463fb190d0e82d25598ad279 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.cycling74.msp;

import java.lang.reflect.Method;

/**
 * Process signals with a single method. Like MSPObject except that
 * the performer method will always be "perform" (and you override it).
 */
public abstract class MSPPerformer extends MSPObject implements MSPPerformable {

    /**
     * Called by PD with the dsp message is sended. This method will then
     * call dspsetup and map the method "perform" has the performer method. 
     * You don't have to override this method, use dspsetup if initialization
     * needs to be done before the signals starts processing.
     */
    public Method dsp(MSPSignal[] in, MSPSignal[] out) {
        dspsetup(in, out);
        return getPerformMethod("perform");
    }
    
    /**
     * Initialize the dsp state of the MSPPerformable. Override this if 
     * you have to initalize something before the signal starts 
     * processing.
     */
    public void dspsetup(MSPSignal[] in, MSPSignal[] out) {
    }

    /**
     * Process signal inlets/outlets. You must override this since it is
     * the main processing method.
     */
    public abstract void perform(MSPSignal[] in, MSPSignal[] out);

}