package jmsltutorial;
import com.softsynth.jmsl.*;
public class HardCodedMusicJob extends MusicJob {
/** Override repeat() to provide your own functionality */
public double repeat(double playTime) {
System.out.println("I am a MusicJob");
return playTime; // return completion
time
}
public static void main(String args[]) {
HardCodedMusicJob myHardCodedMusicJob = new
HardCodedMusicJob(); // build an instance of our class
myHardCodedMusicJob.setRepeats(10);
// repeat 10 times
myHardCodedMusicJob.setRepeatPause(1.5);
// wait 1.5 seconds between repeats
myHardCodedMusicJob.launch(JMSL.now());
// fire away
}
}
Notice that we used setRepeatPause() to set the timing between repeats in the source above, while we added 0.5 seconds to the value returned by repeat() in the video. Both techniques work fine. We'd probably prefer to use setRepeatPause() if the timing changed algorithmically over the course of the piece.
Note also that every instance of this subclass of MusicJob will print the same message.
Next, we'll make the subclass more flexible.
Here's the MusicJob in action:
(C) Phil Burk and Nick Didkovsky, All Rights Reserved
JMSL is based upon HMSL (C) Phil Burk, Larry Polansky and David Rosenboom.