com.softsynth.jmsl
Class DefaultMusicClock

java.lang.Object
  extended by com.softsynth.jmsl.DefaultMusicClock
All Implemented Interfaces:
MusicClock
Direct Known Subclasses:
SynthClock

public class DefaultMusicClock
extends java.lang.Object
implements MusicClock

Default clock for JMSL uses Java millisecond timer.

Author:
Phil Burk and Nick Didkovsky

Constructor Summary
DefaultMusicClock()
           
 
Method Summary
 double getAdvance()
           
 double getNativeRate()
          Return rate of underlying native clock.
 long getNativeTicks()
          Override this method to support other integer based clocks like JSyn's.
 double getRate()
           
 double now()
          Use this time when you want to schedule a Composable to start in the very near future.
 double realTime()
          Use this time when you want to play something immediately.
 void setAdvance(double duration)
          Set amount of time to wake up early.
 void setRate(double rate)
          Set clock rate.
 void sleepUntil(double time)
          Sleep until the specified time minus the advance time.
 void sleepUntilNative(long wakeupTicks)
          Sleep until the specified native time.
 long timeToNative(double time)
          Convert JMSL time to underlying native timer ticks.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultMusicClock

public DefaultMusicClock()
Method Detail

getNativeTicks

public long getNativeTicks()
Description copied from interface: MusicClock
Override this method to support other integer based clocks like JSyn's.

Specified by:
getNativeTicks in interface MusicClock

getNativeRate

public double getNativeRate()
Description copied from interface: MusicClock
Return rate of underlying native clock.

Specified by:
getNativeRate in interface MusicClock

realTime

public double realTime()
Use this time when you want to play something immediately. This is typically used as a result of a user input such as a keyPressed event. If you schedule a sequence with this time, then the first note will happen as soon as possible. But there may be a slight shortening of the time the first and second note because of the time it takes to process the first note.

Specified by:
realTime in interface MusicClock
Returns:
Current time.

now

public double now()
Use this time when you want to schedule a Composable to start in the very near future. All of the scheduled events in that Composable will occur with consistent timing.

Specified by:
now in interface MusicClock
Returns:
realTime() + advanceTime.

setAdvance

public void setAdvance(double duration)
Set amount of time to wake up early.

Specified by:
setAdvance in interface MusicClock

getAdvance

public double getAdvance()
Specified by:
getAdvance in interface MusicClock
Returns:
Amount of time to wake up early.

timeToNative

public long timeToNative(double time)
Convert JMSL time to underlying native timer ticks.

Specified by:
timeToNative in interface MusicClock

sleepUntilNative

public void sleepUntilNative(long wakeupTicks)
                      throws java.lang.InterruptedException
Sleep until the specified native time.

Specified by:
sleepUntilNative in interface MusicClock
Throws:
java.lang.InterruptedException - thrown if Thread.interrupt() called.

sleepUntil

public void sleepUntil(double time)
                throws java.lang.InterruptedException
Sleep until the specified time minus the advance time.

Specified by:
sleepUntil in interface MusicClock
Throws:
java.lang.InterruptedException - thrown if Thread.interrupt() called. MOD PB 5/27/99 6:26PM

setRate

public void setRate(double rate)
Set clock rate.

Specified by:
setRate in interface MusicClock

getRate

public double getRate()
Specified by:
getRate in interface MusicClock
Returns:
Clock rate in HZ.