package jmsltestsuite; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import com.softsynth.jmsl.*; import com.softsynth.jmsl.score.*; /** * This simply uses addNote(dur) to add notes to a Score. * Use this if you know what the duration values of your events are. * * It is *not* a test of the more sophisticated transcriber * * @author Nick Didkovsky and Phil Burk, copyright 2000 Nick Didkovsky and Phil Burk */ public class ScoreWithPlayables { public static void main(String args[]) { int w = 600; int h = 400; int numStaves = 1; Score score = new Score(numStaves, w, h, "Add Notes To a Score"); Measure m = score.addMeasure(); m.addStartPlayable(new Playable() { public double play(double time, Composable parent) throws InterruptedException { System.out.println(time + ": " + " measure's Playable is playing"); return time; }} ); m.getStaff(0).addStartPlayable(new Playable() { public double play(double time, Composable parent) throws InterruptedException { System.out.println(time + ": " + " staff's Playable is playing"); return time; }} ); double[] durations = { .75, .25, .875, .125, .75, .25, .875, .125 }; for (int i = 0; i < durations.length; i++) { score.addNote(durations[i], NoteFactory.MIDDLE_C + i, 0.5, durations[i] * 0.8); } ScoreFrame scoreFrame = new ScoreFrame(); scoreFrame.addScore(score); scoreFrame.setVisible(true); scoreFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { JMSL.closeMusicDevices(); System.exit(0); } }); } }