/* * Created on Jan 27, 2006 by Nick * */ package jmsltestsuite; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import com.softsynth.jmsl.JMSL; import com.softsynth.jmsl.score.*; /** * Quarter notes that decellerate. Subclass Note and override getPerformanceData() to take complete * control of data actually performed, independent of notation. In this example, each quarter note slows * down a little more, like a ritard. Important to understand that a score built this way will not * save and load back with this note subclass. * * Thanks to Pavlos Marios for prompting this example. * * @author Nick Didkovsky, (c) 2005 Nick Didkovsky, didkovn@mail.rockefeller.edu * */ public class PavlosExperiment { public static void main(String[] args) { int w = 1000; int h = 750; int numStaves = 1; Score score = new Score(numStaves, w, h, "Add PavlosNotes to a Score. Will slow down."); score.addMeasure(); double durationScaler = 1.0; for (int i = 0; i < 8; i++) { PavlosNote pn = new PavlosNote(); Note n = NoteFactory.makeNote(1.0, 60 + i, 0.5, 0.8); Note.copyProperties(n, pn); pn.setDurationScaler(durationScaler); durationScaler *= 0.9; score.addNote(pn); } ScoreFrame scoreFrame = new ScoreFrame(); scoreFrame.addScore(score); scoreFrame.setVisible(true); scoreFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { JMSL.closeMusicDevices(); System.exit(0); } }); } } class PavlosNote extends Note { private double durationScaler = 1.0; public PavlosNote() { super(0, 0, 0, 0); } public double[] getPerformanceData() { double[] d = super.getPerformanceData(); System.out.println("PavlosNote durationscaler = " + durationScaler); d[0] /= durationScaler; JMSL.printDoubleArray(d); return d; } /** * @return Returns the durationScaler. */ public double getDurationScaler() { return durationScaler; } /** * @param durationScaler * The durationScaler to set. */ public void setDurationScaler(double durationScaler) { this.durationScaler = durationScaler; } }