/** A Playable that prints a message. Can be plugged into a MusicJob's start, repeat, or stop slots. */ package jmsltutorial; import com.softsynth.jmsl.*; public class MessagePrintingPlayable implements Playable { String message = "uninitialized"; MessagePrintingPlayable(String msg) { message = msg; } public double play(double playTime, Composable thing) { JMSL.out.println(thing.getName() + ": " + message); return playTime; } public static void main(String[] args) { // initialize a couple of stock MusicJobs MusicJob spot = new MusicJob(); MusicJob puff = new MusicJob(); // set their durations spot.setRepeatPause(2.0); puff.setRepeatPause(1.0); // set their repeat counts spot.setRepeats(2); puff.setRepeats(4); // Now build some custom Playables and plug them in! puff.addStartPlayable(new MessagePrintingPlayable("Puff Starting")); puff.addRepeatPlayable(new MessagePrintingPlayable("Puff Repeating (meow)")); puff.addStopPlayable(new MessagePrintingPlayable("Puff Stopped")); spot.addStartPlayable(new MessagePrintingPlayable("Spot Starting")); spot.addRepeatPlayable(new MessagePrintingPlayable("Spot Repeating (bow-wow)")); spot.addStopPlayable(new MessagePrintingPlayable("Spot Stopped")); spot.launch(JMSL.now()); puff.launch(JMSL.now()); } }