/** ColToot04.java Put two MusicJobs in a ParallelCollection. * @author Phil Burk and Nick Didkovsky */ /* * (C) 1997 Phil Burk and Nick Didkovsky, All Rights Reserved * JMSL is based upon HMSL (C) Phil Burk, Larry Polansky and David Rosenboom. */ package jmsltutorial; import java.awt.TextArea; import com.softsynth.jmsl.*; public class ColToot04 extends java.applet.Applet { ParallelCollection myParallelCollection; MusicJob mj1; MusicJob mj2; TextArea myTextArea; /* Build our hierarchy when the applet initializes, and send JMSL's STDOut to a TextArea */ public void init() { // initialize the TextArea with 15 rows, 40 columns myTextArea = new TextArea(15, 40); // Add the TextArea to the applet's layout add(myTextArea); // Hand this TextArea to a new TextAreaSTDOut, and use it for JMSL.out JMSL.setSTDOut(new TextAreaSTDOut(myTextArea)); // initialize collection with vanilla MusicJobs myParallelCollection = new ParallelCollection(); mj1 = new MusicJob(); mj2 = new MusicJob(); MessagePrintingPlayable mppf1 = new MessagePrintingPlayable("Starts"); MessagePrintingPlayable mppf2 = new MessagePrintingPlayable(" Stops"); mj1.addStartPlayable(mppf1); mj2.addStartPlayable(mppf1); mj1.addStopPlayable(mppf2); mj2.addStopPlayable(mppf2); mj1.setRepeatPause(2.0); mj2.setRepeatPause(2.0); myParallelCollection.add(mj1); myParallelCollection.add(mj2); myParallelCollection.setRepeats(20); } /* When applet starts up, launch collection */ public void start() { JMSL.clock = new DefaultMusicClock(); myParallelCollection.launch(JMSL.now()); } /* Shut down the Collection when applet stops */ public void stop() { myParallelCollection.finish(); } }