/* * Created on Jan 2, 2006 by Nick * */ package jmsltestsuite; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import com.softsynth.jmsl.JMSLRandom; import com.softsynth.jmsl.score.*; /** * Exercise various notehead types. Not all of these will import into Finale vie Dolet/MusicXML * * @author Nick Didkovsky, (c) 2005 Nick Didkovsky, didkovn@mail.rockefeller.edu * */ public class Noteheads { public static void main(String[] args) { Score score = new Score(1, 800, 600); score.addMeasure(4, 4); // score.addMeasure(4, 4); score.getMeasure(0).getStaff(0).setClef(Clef.PERCUSSION_CLEF); // add notes to default track 0 score.addNote(1.0, 62, 0.5, 0.8); (score.addNote(0.5, 72, 0.5, 0.8)).setBeamedOut(true); score.addNote(0.5, 62, 0.5, 0.8); score.addNote(0.5, 0, 0, 0.8); score.addNote(0.5, 62, 0.5, 0.8); score.addNote(1, 72, 0.5, 0.8); // add some 8th notes to track 1 score.setCurrentTrackNumber(1); for (int i = 0; i < 8; i++) { Note n = score.addNote(0.5, 81, 0.5, 0.4); n.setBeamedOut(i % 2 == 0); n.setNoteHeadType(Note.NOTEHEAD_X); } int[] pitches = { 64, 65, 67, 69 }; int[] noteheadsForTesting = { Note.NOTEHEAD_SLASH, Note.NOTEHEAD_BLACK_DIAMOND, Note.NOTEHEAD_WHITE_DIAMOND, Note.NOTEHEAD_X, Note.NOTEHEAD_X_OVAL, Note.NOTEHEAD_X_DIAMOND, Note.NOTEHEAD_BLACK_TRIANGLE, Note.NOTEHEAD_WHITE_TRIANGLE, Note.NOTEHEAD_BLACK_INVERTEDTRIANGLE, Note.NOTEHEAD_WHITE_INVERTEDTRIANGLE }; score.setCurrentTrackNumber(0); for (int i = 0; i < noteheadsForTesting.length; i++) { for (int j = 0; j < 8; j++) { double duration = 0.5; Note n = score.addNote(duration, pitches[JMSLRandom.choose(pitches.length)], 0.5, duration * 0.8); n.setBeamedOut(j % 2 == 0); n.setNoteHeadType(noteheadsForTesting[i]); if (j == 0) { n.setText("NOTEHEAD: " + Note.noteheadNames[noteheadsForTesting[i]]); n.setTextOffsetY(55); } } } final ScoreFrame scoreFrame = new ScoreFrame(); scoreFrame.addScore(score); scoreFrame.pack(); scoreFrame.setVisible(true); scoreFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { scoreFrame.quit(); } }); } }