[jmsl] Noteheads and NoteFactory bug

jmsl at music.columbia.edu jmsl at music.columbia.edu
Thu Feb 26 19:05:21 EST 2009


It looks like there may be a bug in the way NoteFactory handles  
noteheads.  NoteFactory.updateFromPitch(n) works properly, but these  
methods wipe out the notehead info:

NoteFactory.update(n);
NoteFactory.updateFromDur(n);

thanks,
Peter McCulloch

Here's sample code:

import java.awt.BorderLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;

import com.didkovsky.portview.swing.ViewFactorySwing;
import com.softsynth.jmsl.JMSL;
import com.softsynth.jmsl.score.Note;
import com.softsynth.jmsl.score.NoteFactory;
import com.softsynth.jmsl.score.Score;

public class TestNoteHeads {

	public static void main(String[] args) {
		JMSL.setViewFactory(new ViewFactorySwing());
		Score score = new Score(2);
		score.addMeasures(10);

		Note n = NoteFactory.makeNote(Note.QUARTER, 60., 0, 0);

		JFrame frame = new JFrame();
		frame.setLayout(new BorderLayout());

		frame.add(score.getScoreCanvas().getComponent());

		frame.addWindowStateListener(new WindowAdapter() {
			@Override
			public void windowClosed(WindowEvent e) {
				JMSL.closeMusicDevices();
				System.exit(0);
			}
		});

		frame.pack();

		frame.setVisible(true);

		n.setNoteHeadType(Note.NOTEHEAD_X);

		score.addNote(n);

		// This one is okay
		// NoteFactory.updateFromPitch(n);

		// These two are not
		NoteFactory.update(n);
		// NoteFactory.updateFromDur(n);
		
		System.out.println(n.getNoteHeadType());

	}

}



More information about the jmsl mailing list