package jmslexamples.jsyn2; import java.awt.event.ActionEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import com.softsynth.jmsl.JMSL; import com.softsynth.jmsl.MusicShape; import com.softsynth.jmsl.score.Orchestra; import com.softsynth.jmsl.score.Score; import com.softsynth.jmsl.score.ScoreFrame; import com.softsynth.jmsl.score.transcribe.BeatDivisionSchemeList; import com.softsynth.jmsl.score.transcribe.Transcriber; /** * Launch a MusicJob whose performance density is generated by a Myhill * Distribution. Provide GUI sliders for user to change density parameters. * * Transcribe the captured musical events and display a Score in musical staff * notation * * adapted to JSyn2 Dec 2016 * * @author Nick Didkovsky, copyright Nick Didkovsky 4/4/01 10:32AM */ public class EventDistributionsJSynDemoWithScore extends EventDistributionsJSynDemo { Score score; ScoreFrame scoreFrame; public void actionPerformed(ActionEvent e) { Object source = e.getSource(); if (source == startButton) { job.launch(JMSL.now()); } if (source == stopButton) { job.finish(); transcribeAndDisplay(); } } private void transcribeAndDisplay() { MusicShape s = (MusicShape) job.getMusicShapeLog().clone(); s.setConstrainedToLimits(false); s.integrate(0); s.print(); score = new Score(1, 800, 400); score.addMeasure(); Orchestra orch = new Orchestra(); orch.addInstrument(job.getInstrument()); score.setOrchestra(orch); BeatDivisionSchemeList.defaultSetup(); Transcriber transcriber = new Transcriber(); transcriber.setScore(score); transcriber.setSourceMusicShape(s); score.setCurrentStaffNumber(0); try { transcriber.transcribe(); } catch (Exception e) { e.printStackTrace(); } if (scoreFrame == null) { scoreFrame = new ScoreFrame(); } scoreFrame.addScore(score); scoreFrame.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { scoreFrame.setVisible(false); System.exit(0); } }); scoreFrame.pack(); scoreFrame.setVisible(true); } public static void main(String args[]) { EventDistributionsJSynDemoWithScore demo = new EventDistributionsJSynDemoWithScore(); demo.start(); demo.pack(); demo.setVisible(true); demo.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); } }