Package com.softsynth.jmsl
Class NonRealTimeMusicClock
java.lang.Object
com.softsynth.jmsl.NonRealTimeMusicClock
- All Implemented Interfaces:
MusicClock
public class NonRealTimeMusicClock extends java.lang.Object implements MusicClock
Clock runs as fast as possible, for non-realtime applications (like nonrealtime JSyn or loading a JavaSound Sequencer)
- Author:
- Phil Burk and Nick Didkovsky
-
Constructor Summary
Constructors Constructor Description NonRealTimeMusicClock() -
Method Summary
Modifier and Type Method Description doublegetAdvance()doublegetNativeRate()Return rate of underlying native clock.longgetNativeTicks()Override this method to support other integer based clocks like JSyn's.doublegetRate()doublenow()Use this time when you want to schedule a Composable to start in the very near future.doublerealTime()Use this time when you want to play something immediately.voidsetAdvance(double duration)Set amount of time to wake up early.voidsetRate(double rate)Set clock rate.voidsleepUntil(double time)Sleep until the specified time minus the advance time.voidsleepUntilNative(long wakeupTicks)Sleep until the specified native time.longtimeToNative(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 Details
-
NonRealTimeMusicClock
public NonRealTimeMusicClock()
-
-
Method Details
-
getNativeTicks
public long getNativeTicks()Description copied from interface:MusicClockOverride this method to support other integer based clocks like JSyn's.- Specified by:
getNativeTicksin interfaceMusicClock
-
getNativeRate
public double getNativeRate()Description copied from interface:MusicClockReturn rate of underlying native clock.- Specified by:
getNativeRatein interfaceMusicClock
-
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:
realTimein interfaceMusicClock- 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:
nowin interfaceMusicClock- Returns:
- realTime + advanceTime.
-
setAdvance
public void setAdvance(double duration)Set amount of time to wake up early.- Specified by:
setAdvancein interfaceMusicClock
-
getAdvance
public double getAdvance()- Specified by:
getAdvancein interfaceMusicClock- Returns:
- Amount of time to wake up early.
-
timeToNative
public long timeToNative(double time)Convert JMSL time to underlying native timer ticks.- Specified by:
timeToNativein interfaceMusicClock
-
sleepUntilNative
public void sleepUntilNative(long wakeupTicks) throws java.lang.InterruptedExceptionSleep until the specified native time.- Specified by:
sleepUntilNativein interfaceMusicClock- Throws:
java.lang.InterruptedException- thrown if Thread.interrupt() called.
-
sleepUntil
public void sleepUntil(double time) throws java.lang.InterruptedExceptionSleep until the specified time minus the advance time.- Specified by:
sleepUntilin interfaceMusicClock- 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:
setRatein interfaceMusicClock
-
getRate
public double getRate()- Specified by:
getRatein interfaceMusicClock- Returns:
- Clock rate in HZ.
-