com.cycling74.max
Class MaxClock

java.lang.Object
  extended by com.cycling74.max.MaxClock

public class MaxClock
extends Object

Used to delay the execution of a block of code. Java implementation of a pdclock.

 
 import com.cycling74.max.*;
 
 class clocktest extends MaxObject implements Executable {
     MaxClock clock;
     float value; 
 
     public clocktest() {
         clock = new MaxClock(this); 
     }
     
     public void inlet(float f) {
         value = f;
         // ask to call execute after 250ms
         clock.delay(250);
     }
 
     // this is called after 250ms
     public void execute() {
         outlet(0, value)
     }
 }
 


Constructor Summary
MaxClock()
          Creates a pdclock without an executable.
MaxClock(Executable e)
          Creates a pdclock with an executable e.
MaxClock(Object o, String methodName)
          Creates a pdclock with a specific method on a object.
 
Method Summary
 void delay(double time)
          Time to wait until next tick.
protected  void finalize()
           
 Executable getExecutable()
          Returns the Executable for this clock.
static double getTime()
          Returns pure-data time in milliseconds.
 void release()
          Release the clock from pure-data.
 void setExecutable(Executable e)
          Set the Executable for this clock.
 void tick()
          The method to override if no Executable is provided.
 void unset()
          Cancels the last delay call.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MaxClock

public MaxClock()
Creates a pdclock without an executable.


MaxClock

public MaxClock(Executable e)
Creates a pdclock with an executable e.

Parameters:
e - the executable to execute when the clock will be triggerd.

MaxClock

public MaxClock(Object o,
                String methodName)
Creates a pdclock with a specific method on a object.

Parameters:
o - the object that holds the method
methodName - the name of the method to execute when the clock will be triggerd.
Method Detail

getExecutable

public Executable getExecutable()
Returns the Executable for this clock.

Returns:
the Executable for this clock

setExecutable

public void setExecutable(Executable e)
Set the Executable for this clock.

Parameters:
e - the Executable to call for this clock

tick

public void tick()
The method to override if no Executable is provided.


finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable

getTime

public static double getTime()
Returns pure-data time in milliseconds.

Returns:
pure-data time in milliseconds

delay

public void delay(double time)
Time to wait until next tick.

Parameters:
time - in miliseconds

release

public void release()
Release the clock from pure-data. The clock becomes unless afterwards.


unset

public void unset()
Cancels the last delay call.



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