/** 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 javax.swing.JFrame; import com.softsynth.jmsl.DefaultMusicClock; import com.softsynth.jmsl.JMSL; import com.softsynth.jmsl.MusicJob; import com.softsynth.jmsl.ParallelCollection; public class ColToot04 { ParallelCollection myParallelCollection; MusicJob mj1; MusicJob mj2; /* Build our hierarchy */ public void init() { // 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); } public void start() { JMSL.clock = new DefaultMusicClock(); myParallelCollection.launch(JMSL.now()); } /* Shut down the Collection when applet stops */ public void stop() { myParallelCollection.finish(); } public static void main(String args[]) { System.out.println("Put two MusicJobs in a ParallelCollection."); ColToot04 colToot04 = new ColToot04(); colToot04.init(); colToot04.start(); JFrame jf = new JFrame("Close to quit"); jf.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { colToot04.stop(); System.exit(0); } }); jf.setSize(200, 100); jf.setVisible(true); } }