/* * Created on Apr 14, 2008 by Nick * */ package jmsltestsuite; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.util.Enumeration; import com.softsynth.jmsl.score.*; /** * Set the text of selected notes to their pitches Select notes and look for * "PitchToTextTransform" in the Note menu */ public class PitchToTextTransform extends NotePropertiesTransform { public PitchToTextTransform() { setName("PitchToTextTransform"); } public void operate(Score score, SelectionBuffer selectionBuffer) { for (Enumeration e = selectionBuffer.elements(); e.hasMoreElements();) { Note note = (Note) e.nextElement(); double pitch = note.getPitchData(); note.setText(pitch + ""); note.setTextOffsetY(20); } score.setDirty(true, getName()); } public static void main(String[] args) { Score score = new Score(1, 1500, 1000); score.addMeasure(1, 4); double[] mantissas = { 0, 0.1, 0.2, 0.24, 0.25, 0.3, 0.4, 0.5, 0.6, 0.74, 0.75, 0.8, 0.9 }; double basePitch = 60; for (int i = 0; i < 24; i++) { for (int j = 0; j < mantissas.length; j++) { double pitch = i + basePitch + mantissas[j]; score.addNote(1.0, pitch, 0.5, 0.8); } Measure m = score.getMeasure(score.size() - 1); m.setDoubleBar(true); } final ScoreFrame scoreFrame = new ScoreFrame(); scoreFrame.addNotePropertiesTransform(new PitchToTextTransform()); scoreFrame.addScore(score); scoreFrame.pack(); scoreFrame.setVisible(true); scoreFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { scoreFrame.quit(); } }); } }