/** * Add algorithmically generated notes to a JMSL score. Notice that when there * are more notes than there are measures to accomodate them, that measures are * added as needed. * * @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 JScoreToot03 extends java.applet.Applet { Score score; ScoreFrame scoreFrame; /* * Build data when the applet initializes, and send JMSL's STDOut to a * TextArea */ public void init() { JMSL.setIsApplet(true); 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); score.addMeasure(); scoreFrame = new ScoreFrame(); scoreFrame.addScore(score); // 4 quarter notes double dur = 1.0; // qtr note for (int i = 0; i < 4; i++) { score.addNote(dur, NoteFactory.MIDDLE_C + i * 3, 0.5, dur * 0.8); } 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(); } } }