/** * @author Nick Didkovsky, (c) 2000 Nick Didkovsky */ package jmsltutorial; import java.awt.Color; import java.awt.Label; import com.softsynth.jmsl.*; import com.softsynth.jmsl.jsyn.JSynMusicDevice; import com.softsynth.jmsl.score.*; public class JScoreToot05 extends java.applet.Applet { Score score; ScoreFrame scoreFrame; 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, build score and display the scoreframe */ public void start() { synchronized (JMSL.class) { JSynMusicDevice.instance().open(); JMSL.clock.setAdvance(0.5); JMSL.scheduler = new EventScheduler(); JMSL.scheduler.start(); Orchestra orch = new Orchestra(); orch.addInstrument(new SuperBrass(5), "Brass"); orch.addInstrument(new SuperRingModBell(5, 0.2), "Ring Bell"); orch.buildMixer(); orch.getJMSLMixerContainer().panAmpChange(0, 0, 0.5); // fader 0 hard left orch.getJMSLMixerContainer().panAmpChange(1, 1, 0.5); // fader 1 hard right // num staves, width, height score = new Score(2, 800, 600); score.addMeasure(); score.setOrchestra(orch); scoreFrame = new ScoreFrame(); scoreFrame.addScore(score); // Add wide range white noise melody, to demonstrate converge to // mean double dur = 0.25; // 16th note for (int i = 0; i < 32; i++) { score.addNote(dur, NoteFactory.MIDDLE_C + JMSLRandom.choose(36), 0.5, dur * 0.8); score.getLastAddedNote().setBeamedOut(i % 4 != 3); } // a few things to make the score easier to read: // 1) force these two measures to fit on one line double drawableWidth = score.getScoreLayoutManager().getDrawableWidth(); score.getMeasure(0).setWidth(drawableWidth); score.getMeasure(1).setWidth(drawableWidth); // 2) lock width so measure does not calculate its own width score.getMeasure(0).setWidthSetByHand(true); score.getMeasure(1).setWidthSetByHand(true); // 3) clear some room above first staff since there will be high barred notes score.getMeasure(0).getStaff(0).setSpaceAbove(score.getMeasure(0).getStaff(0).getSpaceAbove() + 50); // Add your own transform to scoreFrame's menu scoreFrame.addUnaryCopyBufferTransform(new ConvergeToMeanTransform()); scoreFrame.addUnaryCopyBufferTransform(new HocketTransform()); scoreFrame.setSize(850, 500); scoreFrame.setVisible(true); 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(); } } }