/** ColToot05.java Put two MusicJobs in a ParallelCollection. Plug message-printing Playables into the collection's startFunction, repeatFunction, and stopFunction. * @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 ColToot05 { 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(3); myParallelCollection.setRepeatPause(5); myParallelCollection.addStartPlayable(new MessagePrintingPlayable("Collection starts")); myParallelCollection.addRepeatPlayable(new MessagePrintingPlayable("Collection repeats")); myParallelCollection.addStopPlayable(new MessagePrintingPlayable("Collection stops")); } public void start() { JMSL.clock = new DefaultMusicClock(); myParallelCollection.launch(JMSL.now()); } public void stop() { myParallelCollection.finish(); } public static void main(String args[]) { System.out.println("Put two MusicJobs in a ParallelCollection.\n" + " Plug message-printing Playables into the \n" + " collection's startFunction, repeatFunction, and stopFunction."); ColToot05 colToot = new ColToot05(); colToot.init(); colToot.start(); JFrame jf = new JFrame("Close to quit"); jf.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { colToot.stop(); System.exit(0); } }); jf.setSize(200, 100); jf.setVisible(true); } }