/* * Created on Jan 9, 2011 by Nick * */ package jmsltestsuite; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import com.softsynth.jmsl.JMSLRandom; import com.softsynth.jmsl.score.Score; import com.softsynth.jmsl.score.ScoreFrame; public class TestNoteRangeSelection { Score score; ScoreFrame scoreFrame; int numStaves = 4; void buildScore() { score = new Score(numStaves, 1100, 800); scoreFrame = new ScoreFrame(); scoreFrame.addScore(score); scoreFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent arg0) { System.exit(0); } }); } void populateScore() { score.addMeasure(); for (int trackIndex = 0; trackIndex < 2; trackIndex++) { double pitch = trackIndex == 0 ? 60 : 72; score.setCurrentTrackNumber(trackIndex); for (int staffIndex = 0; staffIndex < numStaves; staffIndex++) { score.rewind(); score.setCurrentStaffNumber(staffIndex); for (int noteNumber = 0; noteNumber < 20; noteNumber++) { score.addNote(1.0, pitch + JMSLRandom.choose(-1, 1), 0.5, 0.8); } } } } void showScore() { scoreFrame.setVisible(true); } public static void main(String[] args) { TestNoteRangeSelection testNoteRangeSelection = new TestNoteRangeSelection(); testNoteRangeSelection.buildScore(); testNoteRangeSelection.populateScore(); testNoteRangeSelection.showScore(); // select all notes in specified range testNoteRangeSelection.score.getEditManager().selectAllNotesInRange(1, 2, 2, 3, 0, 2); // select all notes of pitch class 11 (of a 12 tone scale) in specified range testNoteRangeSelection.score.getEditManager().selectAllNotesInRange(0, testNoteRangeSelection.score.size(), 0, testNoteRangeSelection.score.getNumStaves(), 0, testNoteRangeSelection.score.getNumTracksPerStaff(), 11, 12); } }