Converting from JMSL time to JSyn time
Recall that JMSL schedules its Composables with time measured as a Java double, where 1.0 equals 1 second. JSyn uses a clock with integer "ticks" (where 1 is a tiny fraction of a second). Therefore, JMSL Composables that want to bang JSyn units need to convert their playTime to JSyn time. JMSL's SynthClock allows for this.
* To tell JMSL to use a native JSyn clock, we do the following:
JMSL.clock = new com.softsynth.jmsl.jsyn.SynthClock();* To convert from JMSL time to JSyn time follow this example:
// Convert JMSL's playTime to a time usable by JSyn ... int onTime = (int) JMSL.clock.timeToNative(playTime); int offTime = (int) JMSL.clock.timeToNative(playTime + someDuration); someCircuit.somePort.set(onTime, someValue); someCircuit.somePort.set(offTime, someOtherValue);Note that another way to calculate a future time (like offTime above) would be to convert the duration to native ticks and add to onTime, like so:
int onTime = (int) JMSL.clock.timeToNative(playTime); int offTime = onTime + (int) ( JMSL.clock.getNativeRate() * someDuration ); ...etc...
To summarize, the conversion of JMSL time to JSyn time requires:
|Previous||Tutorial Index||Tutorial Contents||Next|
(C) 1997 Phil Burk and Nick Didkovsky, All Rights Reserved JMSL is based upon HMSL (C) Phil Burk, Larry Polansky and David Rosenboom.