/** * Add measures with various time signatures to a JMSL score * * @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.Color; import java.awt.Label; import com.softsynth.jmsl.*; import com.softsynth.jmsl.score.*; public class JScoreToot01 extends java.applet.Applet { Score score; ScoreFrame scoreFrame; public void init() { // setIsApplet set to true to disable menu items that would // cause security exceptions when running as an applet JMSL.setIsApplet(true); JMSLRandom.randomize(); setBackground(Color.yellow); add(new Label("Your JMSL score will open in a new window")); } /* When applet starts up, display the scoreframe */ public void start() { synchronized (JMSL.class) { JMSL.clock = new DefaultMusicClock(); JMSL.clock.setAdvance(0.1); JMSL.scheduler = new EventScheduler(); JMSL.scheduler.start(); // 2 staves, width, height score = new Score(2, 800, 400); scoreFrame = new ScoreFrame(); scoreFrame.addScore(score); score.addMeasure(11, 16); score.addMeasure(3, 4); score.addMeasure(3, 8); score.addMeasure(5, 8); // add three measures with random time sigs score.addMeasure(JMSLRandom.choose(3, 7), (int) Math.pow(2, JMSLRandom.choose(2, 4))); score.addMeasure(JMSLRandom.choose(3, 7), (int) Math.pow(2, JMSLRandom.choose(2, 4))); score.addMeasure(JMSLRandom.choose(3, 7), (int) Math.pow(2, JMSLRandom.choose(2, 4))); scoreFrame.setVisible(true); scoreFrame.setSize(900, 600); score.render(); } } /* When applet stops, hide the scoreframe */ public void stop() { synchronized (JMSL.class) { if (scoreFrame != null) { scoreFrame.setVisible(false); scoreFrame.dispose(); Score.deleteCanvas(); SelectionBuffer.disposeEditFrame(); scoreFrame = null; score = null; } JMSL.scheduler.stop(); JMSL.closeMusicDevices(); } } }