/* * Created on May 18, 2006 * */ 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.*; public class MultiTrackExpressionMarks { public static void main(String[] args) { JMSL.setViewFactory(new ViewFactorySwing()); // one staff, 800x600 pixel canvas Score score = new Score(1, 1200, 600); // IMPORTANT!!! Call setNumTracksPerStaff() right after the constructor and before adding // measures. Else you will need to manage heterogeneous numbers of tracks in the staves of // various measures yourself score.setNumTracksPerStaff(4); score.setUseLegacyMultiTrackOrientation(false); // new! 2020-09-15 double zoom = 0.5; score.getScoreLayoutManager().setZoom(zoom); // score.getControlPanel().setZoom(zoom); score.addMeasure(4, 4); score.setInstrumentNamesVisible(false); double basePitch = 60; // 2020-09-14 Investigate problem with multitrack cresc rendering when cresc spans measure // breaks. for (int t = 0; t < score.getNumTracksPerStaff(); t++) { score.setCurrentTrackNumber(t); score.rewind(); double pitch = basePitch + t * 19; double duration = 1.0; Note note = null; int numberOfNotesinCresc = 8; for (int noteKounter = 0; noteKounter < numberOfNotesinCresc; noteKounter++) { note = score.addNote(duration, pitch, 0.5, duration * 0.8); if (noteKounter < numberOfNotesinCresc - 1) { note.setSlurredOut(true); if (t == 0) note.setCrescOut(true); else note.setDecrescOut(true); } if (t == 0 && (noteKounter < 2 || noteKounter > 5)) { note.setSlurredOut(false); } } note.setCrescOut(false); note.setDecrescOut(false); note.setSlurredOut(false); } int[] marks = { Note.MARK_ACCENT, Note.MARK_ACCENT_STACCATO, Note.MARK_ACCENT_TENUTO, Note.MARK_FERMATA, Note.MARK_HARMONIC, Note.MARK_INVERTED_MORDANT, Note.MARK_MORDANT, Note.MARK_STACCATO, Note.MARK_TENUTO, Note.MARK_TRILL, Note.MARK_TRILL_FLAT, Note.MARK_TRILL_NATURAL, Note.MARK_TRILL_SHARP, Note.MARK_WEDGE, Note.MARK_WEDGE_STACCATO, Note.MARK_NONE }; int numNotes = marks.length; for (int t = 0; t < Math.min(2, score.getNumTracksPerStaff()); t++) { score.setCurrentTrackNumber(t); score.rewind(); double pitch = basePitch + t * 19; double duration = 1.0; Note note = null; for (int noteKounter = 0; noteKounter < numNotes; noteKounter++) { note = score.addNote(duration, pitch, 0.5, duration * 0.8); note.addMark(marks[noteKounter]); if (noteKounter % 4 < 3) { if (t == 0) note.setCrescOut(true); else note.setDecrescOut(true); } } note.setCrescOut(false); note.setDecrescOut(false); } final ScoreFrame scoreFrame = new ScoreFrame(); scoreFrame.addScore(score); scoreFrame.pack(); scoreFrame.setVisible(true); score.getControlPanel().setZoom(1); scoreFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { scoreFrame.quit(); } }); } }