/** * @author Nick Didkovsky, (c) 2000 Nick Didkovsky */ package jmsltutorial; import java.awt.Color; import java.awt.Label; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.JFrame; import com.softsynth.jmsl.JMSL; import com.softsynth.jmsl.score.NoteFactory; import com.softsynth.jmsl.score.Score; import com.softsynth.jmsl.score.ScoreFrame; import com.softsynth.jmsl.score.SelectionBuffer; public class JScoreToot06 extends JFrame { Score score; ScoreFrame scoreFrame; public void init() { setBackground(Color.yellow); add(new Label("Your JMSL score will open in a new window")); } /* build score and display the scoreframe */ public void start() { JMSL.clock.setAdvance(0.1); // 3 staves, width, height score = new Score(3, 800, 600); score.addMeasure(); // load up staff 0 double dur = 0.25; // 16th note for (int i = 0; i < 8; i++) { score.addNote(dur, NoteFactory.MIDDLE_C, 0.5, dur * 0.8); } score.rewind(); score.setCurrentStaffNumber(1); // load up staff 0 for (int i = 0; i < 8; i++) { score.addNote(dur, NoteFactory.MIDDLE_C + 12, 0.5, dur * 0.8); } scoreFrame = new ScoreFrame(); scoreFrame.addScore(score); scoreFrame.setSize(900, 600); scoreFrame.setVisible(true); score.render(); } public void stop() { if (scoreFrame != null) { scoreFrame.setVisible(false); scoreFrame.dispose(); Score.deleteCanvas(); SelectionBuffer.disposeEditFrame(); scoreFrame = null; score = null; } JMSL.scheduler.stop(); JMSL.closeMusicDevices(); } public static void main(String args[]) { JScoreToot06 test = new JScoreToot06(); test.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { test.stop(); System.exit(0); } }); test.init(); test.start(); test.pack(); test.setVisible(true); } }