/* * Created on Dec 3, 2005 * */ package jmsltestsuite; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import com.didkovsky.portview.swing.ViewFactorySwing; import com.softsynth.jmsl.JMSL; import com.softsynth.jmsl.score.*; /** * Put four tracks of music on one staff. This could be any int, just change * score.setNumTracksPerStaff(4) to another value * * @author Nick Didkovsky, didkovn@mail.rockefeller.edu * */ public class FourTracksPerStaff { public static void main(String[] args) { JMSL.setViewFactory(new ViewFactorySwing()); // one staff, 800x600 pixel canvas Score score = new Score(1, 800, 600); // IMPORTANT!!! Call setNumTracksPerStaff() right after the constructor and before adding // measures. Else you will need to manage heterogenous numbers of tracks in the staves of // various measures yourself score.setNumTracksPerStaff(4); score.addMeasure(4, 4); double basePitch = 48; for (int t = 0; t < score.getNumTracksPerStaff(); t++) { score.setCurrentTrackNumber(t); double pitch = basePitch + t * 12; double powerOfTwo = Math.pow(2, t); double duration = 2.0 / powerOfTwo; int numNotes = (int) (4 / duration); System.out.println("track " + t + ", pitch " + pitch + ", duration " + duration + ", numNotes=" + numNotes); for (int noteKounter = 0; noteKounter < numNotes; noteKounter++) { Note note = score.addNote(duration, pitch, 0.5, duration * 0.8); // beam 16th notes: note.setBeamedOut(duration == 0.25 && noteKounter % 4 < 3); } } final ScoreFrame scoreFrame = new ScoreFrame(); scoreFrame.addScore(score); scoreFrame.pack(); scoreFrame.setVisible(true); scoreFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { scoreFrame.quit(); } }); } }