This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I am trying to get the MiniMusicCmdLine object to work using a different logic than is explained in the book. Instead of creating new shortmessage and MidiEvent object for every individual track, I have tried reusing the objects in the following way:
Sequencer player = MidiSystem.getSequencer(); player.open(); Sequence seq = new Sequence(Sequence.PPQ,4); Track track = seq.createTrack();
sm.setMessage(144, 1, note, 100); me = null; me = new MidiEvent(sm,1); track.add(me);
sm.setMessage(128, 1, note, 100); me = null; me = new MidiEvent(sm,16); track.add(me);
If I use the logic described in the book it works. But I thought it would also work the way I programmed it. I am obviously making a thinking error, but I can not see what it is. can someone explain please.