package jmsltestsuite; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import com.softsynth.jmsl.JMSL; import com.softsynth.jmsl.score.*; /** * This simply uses addNote(dur) to add notes to a Score. Use this if you know * what the duration values of your events are. * * It is *not* a test of the more sophisticated transcriber * * @author Nick Didkovsky and Phil Burk, copyright 2000 Nick Didkovsky and Phil * Burk */ public class ScoreTestNoteAccidentalPolicy2 { static String policyName(byte policy) { String[] name = { "normal", "never", "always" }; return name[policy]; } public static void main(String args[]) { int w = 1000; int h = 750; int numStaves = 1; Score score = new Score(numStaves, w, h, "test note accidental policy"); score.addMeasure(4, 4); double dur = 1; byte[] policies = { Note.ACCIDENTAL_SHOW_NORMAL, Note.ACCIDENTAL_SHOW_ALWAYS, Note.ACCIDENTAL_SHOW_NEVER, Note.ACCIDENTAL_SHOW_NORMAL , Note.ACCIDENTAL_SHOW_NORMAL }; double[] pitches = { 64.5, 68, 75, 79.5, 84 }; for (int i = 0; i < policies.length; i++) { Note notes[] = new Note[pitches.length]; double rootPitch = pitches[0]; notes[0] = score.addNote(dur, rootPitch, 0.5, dur * 0.8); for (int intervalIndex = 1; intervalIndex < pitches.length; intervalIndex++) { notes[intervalIndex] = notes[0].addInterval(pitches[intervalIndex]); } for (int noteIndex = 0; noteIndex < notes.length; noteIndex++) { notes[noteIndex].setAccidentalVisibilityPolicy(policies[i]); } notes[0].setText(policyName(policies[i])); notes[0].setTextOffsetY(30); } ScoreFrame scoreFrame = new ScoreFrame(); scoreFrame.addScore(score); scoreFrame.setVisible(true); scoreFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { JMSL.closeMusicDevices(); System.exit(0); } }); } }